|
@@ -21,13 +21,11 @@ import cn.com.qmth.examcloud.core.questions.dao.*;
|
|
|
import cn.com.qmth.examcloud.core.questions.dao.entity.*;
|
|
|
import cn.com.qmth.examcloud.core.questions.service.*;
|
|
|
import cn.com.qmth.examcloud.core.questions.service.bean.dto.*;
|
|
|
-import cn.com.qmth.examcloud.core.questions.service.cache.BasePaperCache;
|
|
|
import cn.com.qmth.examcloud.core.questions.service.config.UpYunProperty;
|
|
|
import cn.com.qmth.examcloud.core.questions.service.export.ExportPaperAbstractService;
|
|
|
-import cn.com.qmth.examcloud.core.questions.service.rpc.PrintCoursePaperClient;
|
|
|
-import cn.com.qmth.examcloud.web.redis.RedisClient;
|
|
|
import com.google.gson.Gson;
|
|
|
import main.java.com.UpYun;
|
|
|
+import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.apache.commons.io.FileUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.docx4j.XmlUtils;
|
|
@@ -45,6 +43,7 @@ import org.springframework.data.domain.Sort.Order;
|
|
|
import org.springframework.data.mongodb.core.MongoTemplate;
|
|
|
import org.springframework.data.mongodb.core.query.Criteria;
|
|
|
import org.springframework.data.mongodb.core.query.Query;
|
|
|
+import org.springframework.data.redis.core.RedisTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.Assert;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
@@ -59,7 +58,7 @@ import java.util.*;
|
|
|
import java.util.regex.Matcher;
|
|
|
import java.util.regex.Pattern;
|
|
|
|
|
|
-import static cn.com.qmth.examcloud.core.questions.service.cache.Constants.CACHE_KEY_PAPER_FOR_DTO;
|
|
|
+import static cn.com.qmth.examcloud.core.questions.service.cache.Constants.CACHE_KEY_PAPER;
|
|
|
|
|
|
|
|
|
* @author chenken
|
|
@@ -111,32 +110,20 @@ public class PaperServiceImpl implements PaperService {
|
|
|
@Autowired
|
|
|
private QuestionAudioServiceImpl questionAudioService;
|
|
|
|
|
|
- @Autowired
|
|
|
- private QuestionAudioRepo questionAudioRepo;
|
|
|
-
|
|
|
@Autowired
|
|
|
private ExportServiceManageRepo exportServiceManageRepo;
|
|
|
|
|
|
- @Autowired
|
|
|
- private PrintCoursePaperClient printCoursePaperClient;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private CoursePaperCloudService coursePaperCloudService1;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private BasePaperCache basePaperCache;
|
|
|
-
|
|
|
@Autowired
|
|
|
private UpYunProperty upYunProperty;
|
|
|
|
|
|
@Autowired
|
|
|
- private RedisClient redisClient;
|
|
|
+ private RedisTemplate<String, Object> redisTemplate;
|
|
|
|
|
|
@Autowired
|
|
|
private CoursePaperCloudService coursePaperCloudService;
|
|
|
|
|
|
@Autowired
|
|
|
- CourseService courseService;
|
|
|
+ private CourseService courseService;
|
|
|
|
|
|
public static final String TEMP_FILE_EXP = "docxExport/";
|
|
|
|
|
@@ -278,9 +265,8 @@ public class PaperServiceImpl implements PaperService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- redisClient.delete(CACHE_KEY_PAPER_FOR_DTO + paperExp.getId());
|
|
|
- basePaperCache.remove(paperExp.getId());
|
|
|
+
|
|
|
+ this.clearPaperCache(paperExp.getId());
|
|
|
|
|
|
return msgMap;
|
|
|
}
|
|
@@ -444,8 +430,7 @@ public class PaperServiceImpl implements PaperService {
|
|
|
|
|
|
for (String paperId : paperIds) {
|
|
|
|
|
|
- redisClient.delete(CACHE_KEY_PAPER_FOR_DTO + paperId);
|
|
|
- basePaperCache.remove(paperId);
|
|
|
+ this.clearPaperCache(paperId);
|
|
|
}
|
|
|
|
|
|
msg = "success";
|
|
@@ -805,8 +790,7 @@ public class PaperServiceImpl implements PaperService {
|
|
|
paperRepo.save(paper);
|
|
|
|
|
|
|
|
|
- redisClient.delete(CACHE_KEY_PAPER_FOR_DTO + paper.getId());
|
|
|
- basePaperCache.remove(paper.getId());
|
|
|
+ this.clearPaperCache(paper.getId());
|
|
|
}
|
|
|
|
|
|
|
|
@@ -940,7 +924,7 @@ public class PaperServiceImpl implements PaperService {
|
|
|
paperDetailUnitRepo.saveAll(saveUnits);
|
|
|
|
|
|
|
|
|
- basePaperCache.remove(paper.getId());
|
|
|
+ this.clearPaperCache(paper.getId());
|
|
|
|
|
|
formatPaper(paper, user);
|
|
|
return paper;
|
|
@@ -1762,5 +1746,14 @@ public class PaperServiceImpl implements PaperService {
|
|
|
}
|
|
|
return 0;
|
|
|
}
|
|
|
-}
|
|
|
|
|
|
+ private void clearPaperCache(String paperId) {
|
|
|
+
|
|
|
+ final String patternKey = CACHE_KEY_PAPER + "*" + paperId;
|
|
|
+ Set<String> keys = redisTemplate.keys(patternKey);
|
|
|
+ if (CollectionUtils.isNotEmpty(keys)) {
|
|
|
+ redisTemplate.delete(keys);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+}
|