|
@@ -3,7 +3,11 @@ package cn.com.qmth.examcloud.core.examwork.service.cache;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import cn.com.qmth.examcloud.core.examwork.service.ExamService;
|
|
|
+import cn.com.qmth.examcloud.commons.helpers.DynamicEnum;
|
|
|
+import cn.com.qmth.examcloud.commons.helpers.DynamicEnumManager;
|
|
|
+import cn.com.qmth.examcloud.core.examwork.base.enums.ExamProperty;
|
|
|
+import cn.com.qmth.examcloud.core.examwork.dao.ExamPropertyRepo;
|
|
|
+import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamPropertyEntity;
|
|
|
import cn.com.qmth.examcloud.support.cache.bean.ExamPropertyCacheBean;
|
|
|
import cn.com.qmth.examcloud.web.cache.RandomObjectRedisCache;
|
|
|
|
|
@@ -11,19 +15,29 @@ import cn.com.qmth.examcloud.web.cache.RandomObjectRedisCache;
|
|
|
public class ExamPropertyCache extends RandomObjectRedisCache<ExamPropertyCacheBean> {
|
|
|
|
|
|
@Autowired
|
|
|
- private ExamService examService;
|
|
|
+ ExamPropertyRepo examPropertyRepo;
|
|
|
|
|
|
@Override
|
|
|
public ExamPropertyCacheBean loadFromResource(Object... keys) {
|
|
|
Long examId = (Long) keys[0];
|
|
|
String key = (String) keys[1];
|
|
|
|
|
|
- String value = examService.getExamProperty(examId, key);
|
|
|
+ DynamicEnumManager manager = ExamProperty.getDynamicEnumManager();
|
|
|
+ DynamicEnum de = manager.getByName(key);
|
|
|
+
|
|
|
+ ExamPropertyEntity examPropertyEntity = examPropertyRepo.findByExamIdAndKeyId(examId,
|
|
|
+ de.getId());
|
|
|
|
|
|
ExamPropertyCacheBean b = new ExamPropertyCacheBean();
|
|
|
b.setExamId(examId);
|
|
|
b.setKey(key);
|
|
|
- b.setValue(value);
|
|
|
+
|
|
|
+ if (null == examPropertyEntity) {
|
|
|
+ b.setHasValue(false);
|
|
|
+ return b;
|
|
|
+ }
|
|
|
+
|
|
|
+ b.setValue(examPropertyEntity.getValue());
|
|
|
return b;
|
|
|
}
|
|
|
|