fix 增加redis缓存优化速度
This commit is contained in:
@@ -14,6 +14,7 @@ using SqlSugar;
|
||||
using Kurisu.SqlSugar.Extensions;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Kurisu.Core.CustomClass;
|
||||
using Kurisu.AspNetCore;
|
||||
|
||||
namespace Dlhis.ScheduledTask.TaskAssignment.Services.Implements;
|
||||
|
||||
@@ -52,7 +53,7 @@ public class AssignmentService : IAssignmentService
|
||||
deivceTamplate.Brand,
|
||||
FuncStr = deivce.Funcs.ToString(),
|
||||
deviceTask.UserNo,
|
||||
deviceTask.UserCode,
|
||||
UserCode = ga.Code,
|
||||
UserName = ga.Name,
|
||||
ga.DepartmentNo,
|
||||
DepartmentName = department.Name,
|
||||
@@ -282,25 +283,21 @@ public class AssignmentService : IAssignmentService
|
||||
{
|
||||
var task = await _dbContext.Queryable<DeviceTaskEntity>().Where(x => x.Id == taskId).FirstAsync();
|
||||
task.ThrowIfNull("该任务不存在");
|
||||
|
||||
(task.Status != DeviceTaskStatusEnumType.Process).ThrowIfTrue($"设备任务下发状态需为{DeviceTaskStatusEnumType.Process.GetDescription()}");
|
||||
|
||||
return Scoped.Request.Value.Create((sp) =>
|
||||
{
|
||||
var faceUrlOptions = sp.GetService<IOptions<FaceUrlOptions>>().Value;
|
||||
var dataProtectionProvider = sp.GetService<IDataProtectionProvider>();
|
||||
var faceUrlOptions = App.GetServiceProvider(true).GetService<IOptions<FaceUrlOptions>>().Value;
|
||||
var dataProtectionProvider = App.GetServiceProvider(true).GetService<IDataProtectionProvider>();
|
||||
|
||||
var timeLimitedDataProtector = dataProtectionProvider
|
||||
.CreateProtector("down:face")
|
||||
.ToTimeLimitedDataProtector();
|
||||
var timeLimitedDataProtector = dataProtectionProvider
|
||||
.CreateProtector("down:face")
|
||||
.ToTimeLimitedDataProtector();
|
||||
|
||||
var userCode = task.UserCode;
|
||||
var userCode = await _dbContext.Queryable<GainfoEntity>().Where(x => x.No == task.UserNo).Select(x => x.Code).SingleAsync();
|
||||
|
||||
var key = $"face:{userCode}";
|
||||
var token = timeLimitedDataProtector.Protect(key, TimeSpan.FromSeconds(faceUrlOptions.Limit));
|
||||
var key = $"face:{userCode}";
|
||||
var token = timeLimitedDataProtector.Protect(key, TimeSpan.FromSeconds(faceUrlOptions.Limit));
|
||||
|
||||
return faceUrlOptions.Url + token;
|
||||
});
|
||||
return faceUrlOptions.Url + token;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user