소스 검색

Merge branch 'develop3.0' of http://106.12.23.251:10080/TEAMMODEL/TEAMModelOS into develop3.0

liqk 5 년 전
부모
커밋
28a903e39f
1개의 변경된 파일45개의 추가작업 그리고 10개의 파일을 삭제
  1. 45 10
      TEAMModelOS/Controllers/Analysis/AchievementController.cs

+ 45 - 10
TEAMModelOS/Controllers/Analysis/AchievementController.cs

@@ -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)
         {
         {