|
@@ -1235,33 +1235,33 @@ namespace TEAMModelOS.Controllers.Analysis
|
|
if (RedisHelper.Instance != null)
|
|
if (RedisHelper.Instance != null)
|
|
{
|
|
{
|
|
|
|
|
|
- List<ExamInfo> info = await RedisHelper.CacheShellAsync(CacheCosmosPrefix + "FindExamInfo",
|
|
|
|
- ShaHashHelper.GetSHA1(JsonNetHelper.ToJson(request.@params)), timeoutSeconds, () => { return FindExamInfoToRedis(request.@params); });
|
|
|
|
|
|
+ List<ExamInfo> info = await RedisHelper.CacheShellAsync(CacheCosmosPrefix + request.method,
|
|
|
|
+ ShaHashHelper.GetSHA1(JsonNetHelper.ToJson(request.@params)), timeoutSeconds, () => { return FindExamInfoRedis(request.@params,request.method); });
|
|
builder.Data(info);
|
|
builder.Data(info);
|
|
|
|
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- List<ExamInfo> info = await FindExamInfoToRedis(request.@params);
|
|
|
|
|
|
+ List<ExamInfo> info = await FindExamInfoRedis(request.@params,request.method);
|
|
builder.Data(info);
|
|
builder.Data(info);
|
|
}
|
|
}
|
|
return builder.build();
|
|
return builder.build();
|
|
}
|
|
}
|
|
|
|
|
|
- public async Task<List<ExamInfo>> FindExamInfoToRedis(Dictionary<string, object> dict)
|
|
|
|
|
|
+ public async Task<List<ExamInfo>> FindExamInfoRedis(Dictionary<string, object> dict,string method)
|
|
{
|
|
{
|
|
try {
|
|
try {
|
|
List<ExamInfo> info = await azureCosmosDBRepository.FindByDict<ExamInfo>(dict);
|
|
List<ExamInfo> info = await azureCosmosDBRepository.FindByDict<ExamInfo>(dict);
|
|
if (RedisHelper.Instance != null)
|
|
if (RedisHelper.Instance != null)
|
|
{
|
|
{
|
|
- if (!RedisHelper.Exists(CacheCosmosPrefix + "FindExamInfo"))
|
|
|
|
|
|
+ if (!RedisHelper.Exists(CacheCosmosPrefix + method))
|
|
{
|
|
{
|
|
- await RedisHelper.HSetAsync(CacheCosmosPrefix + "FindExamInfo", ShaHashHelper.GetSHA1(JsonNetHelper.ToJson(dict)), info);
|
|
|
|
|
|
+ await RedisHelper.HSetAsync(CacheCosmosPrefix + method, ShaHashHelper.GetSHA1(JsonNetHelper.ToJson(dict)), info);
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- await RedisHelper.HSetAsync(CacheCosmosPrefix + "FindExamInfo", ShaHashHelper.GetSHA1(JsonNetHelper.ToJson(dict)), info);
|
|
|
|
- await RedisHelper.ExpireAsync(CacheCosmosPrefix + "FindExamInfo", timeoutSeconds);
|
|
|
|
|
|
+ await RedisHelper.HSetAsync(CacheCosmosPrefix + method, ShaHashHelper.GetSHA1(JsonNetHelper.ToJson(dict)), info);
|
|
|
|
+ await RedisHelper.ExpireAsync(CacheCosmosPrefix + method, timeoutSeconds);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return info;
|
|
return info;
|
|
@@ -1275,12 +1275,47 @@ namespace TEAMModelOS.Controllers.Analysis
|
|
public async Task<BaseJosnRPCResponse> FindExamPaper(JosnRPCRequest<Dictionary<string, object>> request)
|
|
public async Task<BaseJosnRPCResponse> FindExamPaper(JosnRPCRequest<Dictionary<string, object>> request)
|
|
{
|
|
{
|
|
JsonRPCResponseBuilder builder = JsonRPCResponseBuilder.custom();
|
|
JsonRPCResponseBuilder builder = JsonRPCResponseBuilder.custom();
|
|
|
|
+ if (RedisHelper.Instance != null)
|
|
|
|
+ {
|
|
|
|
|
|
- List<ExamPaper> info = await azureCosmosDBRepository.FindByDict<ExamPaper>(request.@params);
|
|
|
|
- builder.Data(info);
|
|
|
|
|
|
+ List<ExamPaper> info = await RedisHelper.CacheShellAsync(CacheCosmosPrefix + request.method,
|
|
|
|
+ ShaHashHelper.GetSHA1(JsonNetHelper.ToJson(request.@params)), timeoutSeconds, () => { return FindExamPaperRedis(request.@params, request.method); });
|
|
|
|
+ builder.Data(info);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ List<ExamPaper> info = await FindExamPaperRedis(request.@params, request.method);
|
|
|
|
+ builder.Data(info);
|
|
|
|
+ }
|
|
|
|
|
|
return builder.build();
|
|
return builder.build();
|
|
}
|
|
}
|
|
|
|
+ public async Task<List<ExamPaper>> FindExamPaperRedis(Dictionary<string, object> dict, string method)
|
|
|
|
+ {
|
|
|
|
+ try
|
|
|
|
+ {
|
|
|
|
+ List<ExamPaper> info = await azureCosmosDBRepository.FindByDict<ExamPaper>(dict);
|
|
|
|
+ if (RedisHelper.Instance != null)
|
|
|
|
+ {
|
|
|
|
+ if (!RedisHelper.Exists(CacheCosmosPrefix + method))
|
|
|
|
+ {
|
|
|
|
+ await RedisHelper.HSetAsync(CacheCosmosPrefix + method, ShaHashHelper.GetSHA1(JsonNetHelper.ToJson(dict)), info);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ await RedisHelper.HSetAsync(CacheCosmosPrefix + method, ShaHashHelper.GetSHA1(JsonNetHelper.ToJson(dict)), info);
|
|
|
|
+ await RedisHelper.ExpireAsync(CacheCosmosPrefix + method, timeoutSeconds);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return info;
|
|
|
|
+ }
|
|
|
|
+ catch (Exception e)
|
|
|
|
+ {
|
|
|
|
+ throw new BizException(e.Message);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
[HttpPost("FindExamAnswer")]
|
|
[HttpPost("FindExamAnswer")]
|
|
public async Task<BaseJosnRPCResponse> FindExamAnswer(JosnRPCRequest<Dictionary<string, object>> request)
|
|
public async Task<BaseJosnRPCResponse> FindExamAnswer(JosnRPCRequest<Dictionary<string, object>> request)
|
|
{
|
|
{
|