|
@@ -0,0 +1,53 @@
|
|
|
+package cn.com.qmth.examcloud.core.questions.service.cache;
|
|
|
+
|
|
|
+import cn.com.qmth.examcloud.commons.exception.StatusException;
|
|
|
+import cn.com.qmth.examcloud.core.questions.service.ExtractConfigProviderService;
|
|
|
+import cn.com.qmth.examcloud.support.cache.bean.ExtractConfigPaperCacheBean;
|
|
|
+import cn.com.qmth.examcloud.web.cache.RandomObjectRedisCache;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+@Component
|
|
|
+public class ExtractConfigPaperCache extends RandomObjectRedisCache<ExtractConfigPaperCacheBean> {
|
|
|
+ @Autowired
|
|
|
+ private ExtractConfigProviderService extractConfigProviderService;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ExtractConfigPaperCacheBean loadFromResource(Object... keys) {
|
|
|
+ Long examId = (Long) keys[0];
|
|
|
+ String courseCode = String.valueOf(keys[1]);
|
|
|
+ String groupCode = String.valueOf(keys[2]);
|
|
|
+ String paperId = String.valueOf(keys[3]);
|
|
|
+
|
|
|
+ if (examId == null) {
|
|
|
+ throw new StatusException("400", "examId is null");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isBlank(courseCode)) {
|
|
|
+ throw new StatusException("400", "courseCode is empty");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isBlank(groupCode)) {
|
|
|
+ throw new StatusException("400", "groupCode is empty");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isBlank(paperId)) {
|
|
|
+ throw new StatusException("400", "paperId is empty");
|
|
|
+ }
|
|
|
+
|
|
|
+ ExtractConfigPaperCacheBean cacheBean = extractConfigProviderService.getExtractConfigPaper(examId, courseCode, groupCode, paperId);
|
|
|
+ return cacheBean;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected String getKeyPrefix() {
|
|
|
+ return "Q_PAPER:EXTRACT_CONFIG_PAPER_";
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected int getTimeout() {
|
|
|
+ return 10 * 60;// N分钟
|
|
|
+ }
|
|
|
+
|
|
|
+}
|