Explorar el Código

update cache param.

deason hace 5 años
padre
commit
fca090fa7d

+ 11 - 4
examcloud-core-questions-api-provider/src/main/java/cn/com/qmth/examcloud/core/questions/api/ExtractConfigController.java

@@ -11,6 +11,7 @@ import cn.com.qmth.examcloud.core.questions.service.ExtractConfigFileService;
 import cn.com.qmth.examcloud.core.questions.service.ExtractConfigService;
 import cn.com.qmth.examcloud.core.questions.service.bean.CouresInfo;
 import cn.com.qmth.examcloud.core.questions.service.bean.dto.ExportPaperInfoModel;
+import cn.com.qmth.examcloud.core.questions.service.cache.ExtractConfigCache;
 import cn.com.qmth.examcloud.web.support.ControllerSupport;
 import cn.com.qmth.examcloud.web.support.Naked;
 import io.swagger.annotations.ApiOperation;
@@ -24,7 +25,6 @@ import org.springframework.http.ResponseEntity;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.*;
 
-import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -50,6 +50,9 @@ public class ExtractConfigController extends ControllerSupport {
     @Autowired
     private ExtractConfigFileService extractConfigFileService;
 
+    @Autowired
+    private ExtractConfigCache extractConfigCache;
+
     @ApiOperation(value = "根据考试ID和课程ID获取调卷规则", notes = "根据考试ID和课程ID获取调卷规则")
     @GetMapping(value = "/findPageExtractConfig/{currentPage}/{pageSize}")
     public ResponseEntity<Object> findPageExtractConfig(@PathVariable int currentPage,
@@ -67,13 +70,17 @@ public class ExtractConfigController extends ControllerSupport {
     }
 
     @ApiOperation(value = "保存调卷规则", notes = "保存调卷规则")
-    @PutMapping(value = "/extractConfig/{isbuildFile}")
-    public ResponseEntity<Object> saveExtractConfig(HttpServletRequest request, @PathVariable Integer isbuildFile, @RequestBody ExtractConfig extractConfig) {
+    @PutMapping(value = "/extractConfig/{isBuildFile}")
+    public ResponseEntity<Object> saveExtractConfig(@PathVariable Integer isBuildFile, @RequestBody ExtractConfig extractConfig) {
         try {
             User user = getAccessUser();
             extractConfig.setOrgId(user.getRootOrgId() + "");
             extractConfig.setOrgName(user.getRootOrgName());
-            extractConfigFileService.saveExtractConfigAndBuildPaperFile(extractConfig, isbuildFile, user);
+            extractConfigFileService.saveExtractConfigAndBuildPaperFile(extractConfig, isBuildFile, user);
+
+            //清除缓存
+            extractConfigCache.remove(extractConfig.getExamId(), extractConfig.getCourseCode());
+
             return new ResponseEntity<>(HttpStatus.OK);
         } catch (Exception e) {
             logger.error(e.getMessage(), e);

+ 1 - 1
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/ExtractConfigProviderService.java

@@ -21,7 +21,7 @@ public interface ExtractConfigProviderService {
     /**
      * 获取调卷规则信息
      */
-    public ExtractConfigCacheBean getExtractConfig(Long examId, String courseCode, String groupCode);
+    public ExtractConfigCacheBean getExtractConfig(Long examId, String courseCode);
 
     /**
      * 获取调卷规则调取的试卷结构

+ 1 - 6
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/cache/ExtractConfigCache.java

@@ -17,7 +17,6 @@ public class ExtractConfigCache extends RandomObjectRedisCache<ExtractConfigCach
     public ExtractConfigCacheBean loadFromResource(Object... keys) {
         Long examId = (Long) keys[0];
         String courseCode = String.valueOf(keys[1]);
-        String groupCode = String.valueOf(keys[2]);
 
         if (examId == null) {
             throw new StatusException("400", "examId is null");
@@ -27,11 +26,7 @@ public class ExtractConfigCache extends RandomObjectRedisCache<ExtractConfigCach
             throw new StatusException("400", "courseCode is empty");
         }
 
-        if (StringUtils.isBlank(groupCode)) {
-            throw new StatusException("400", "groupCode is empty");
-        }
-
-        return extractConfigProviderService.getExtractConfig(examId, courseCode, groupCode);
+        return extractConfigProviderService.getExtractConfig(examId, courseCode);
     }
 
     @Override

+ 2 - 2
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/impl/ExtractConfigProviderServiceImpl.java

@@ -75,7 +75,7 @@ public class ExtractConfigProviderServiceImpl implements ExtractConfigProviderSe
     private SysProperty sysProperty;
 
     @Override
-    public ExtractConfigCacheBean getExtractConfig(Long examId, String courseCode, String groupCode) {
+    public ExtractConfigCacheBean getExtractConfig(Long examId, String courseCode) {
         ExtractConfig extractConfig = extractConfigService.findConfig(new ExtractConfig(examId, courseCode));
         if (extractConfig == null) {
             throw new StatusException("500", "该课程调卷规则未制定,请联系学校!");
@@ -115,7 +115,7 @@ public class ExtractConfigProviderServiceImpl implements ExtractConfigProviderSe
     public ExtractConfigPaper getDefaultPaper(Long examId, String courseCode, String groupCode) {
         log.info("调卷开始...");
 
-        ExtractConfigCacheBean extractConfigCache = CacheHelper.getExtractConfig(examId, courseCode, groupCode);
+        ExtractConfigCacheBean extractConfigCache = CacheHelper.getExtractConfig(examId, courseCode);
         if (extractConfigCache == null) {
             throw new StatusException("500", "该课程调卷规则未制定,请联系学校!");
         }

+ 2 - 2
examcloud-core-questions-starter/src/main/java/cn/com/qmth/examcloud/core/questions/starter/DemoController.java

@@ -56,9 +56,9 @@ public class DemoController {
         ExtractConfigPaper extractConfigPaper = extractConfigProviderService.getDefaultPaper(examId, courseCode, groupCode);
         log.info("调卷的试卷结构缓存:" + extractConfigPaper.getDefaultPaper().getName());
 
-        ExtractConfigCacheBean extractConfigCacheBean = CacheHelper.getExtractConfig(examId, courseCode, groupCode);
+        ExtractConfigCacheBean extractConfigCacheBean = CacheHelper.getExtractConfig(examId, courseCode);
         log.info("--->调卷规则缓存: " + extractConfigCacheBean.getDetails().size());
-        //extractConfigCache.remove(examId, courseCode, groupCode);
+        //extractConfigCache.remove(examId, courseCode);
 
         ExtractConfigPaperCacheBean extractConfigPaperCacheBean = CacheHelper.getExtractConfigPaper(examId, courseCode, groupCode, paperId);
         log.info("--->调卷规则的试卷结构缓存: " + extractConfigPaperCacheBean.getDefaultPaper().getName());