Browse Source

删除无用代码:$redis.paper.prefix

deason 5 years ago
parent
commit
bf2d085e7b

+ 2 - 0
examcloud-core-questions-api-provider/src/main/java/cn/com/qmth/examcloud/core/questions/api/QuesController.java

@@ -82,6 +82,7 @@ public class QuesController extends ControllerSupport {
 
         //清除缓存
         this.clearQuestionCache(question.getId());
+
         return new ResponseEntity<Object>(HttpStatus.OK);
     }
 
@@ -110,6 +111,7 @@ public class QuesController extends ControllerSupport {
 
         //清除缓存
         this.clearQuestionCache(id);
+
         return new ResponseEntity<Object>(HttpStatus.OK);
     }
 

+ 1 - 9
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/impl/PaperDetailUnitServiceImpl.java

@@ -17,7 +17,6 @@ import cn.com.qmth.examcloud.web.redis.RedisClient;
 import org.apache.commons.collections.CollectionUtils;
 import org.bson.types.ObjectId;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
 import org.springframework.data.domain.Sort;
 import org.springframework.data.domain.Sort.Direction;
 import org.springframework.data.domain.Sort.Order;
@@ -61,9 +60,6 @@ public class PaperDetailUnitServiceImpl implements PaperDetailUnitService {
     @Autowired
     RedisClient redisClient;
 
-    @Value("${$redis.paper.prefix}")
-    private String redisPaperPrefix;
-
     /**
      * 根据Id获得对应的试题对象
      *
@@ -181,12 +177,8 @@ public class PaperDetailUnitServiceImpl implements PaperDetailUnitService {
         Paper paper = detailUnit.getPaper();
         paperDetailUnitRepo.deleteById(id);
 
-        //清除缓存
-        if (paper.getPaperType() == PaperType.GENERATE) {
-            redisClient.delete(redisPaperPrefix + ":" + paper.getId());
-        }
-
         if (detailUnit.getQuestion() != null) {
+            //清除缓存
             this.clearQuestionCache(detailUnit.getQuestion().getId());
         }
 

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

@@ -39,7 +39,6 @@ import org.docx4j.wml.Text;
 import org.nlpcn.commons.lang.util.StringUtil;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
 import org.springframework.data.domain.*;
 import org.springframework.data.domain.Sort.Direction;
 import org.springframework.data.domain.Sort.Order;
@@ -133,9 +132,6 @@ public class PaperServiceImpl implements PaperService {
     @Autowired
     private RedisClient redisClient;
 
-    @Value("${$redis.paper.prefix}")
-    private String redisPaperPrefix;
-
     @Autowired
     private CoursePaperCloudService coursePaperCloudService;
 
@@ -446,8 +442,8 @@ public class PaperServiceImpl implements PaperService {
         paperDetailService.deletePaperDetailsByPapers(papers);
         paperRepo.deleteAll(papers);
 
-        //清除缓存
         for (String paperId : paperIds) {
+            //清除缓存
             redisClient.delete(CACHE_PREFIX_EXTRACT_EXAM_PAPER + paperId);
             basePaperCache.remove(paperId);
         }
@@ -944,10 +940,7 @@ public class PaperServiceImpl implements PaperService {
         paperDetailUnitRepo.saveAll(saveUnits);
 
         //清除缓存
-        if (paper.getPaperType() == PaperType.GENERATE) {
-            redisClient.delete(redisPaperPrefix + ":" + paper.getId());
-            basePaperCache.remove(paper.getId());
-        }
+        basePaperCache.remove(paper.getId());
 
         formatPaper(paper, user);
         return paper;