Bläddra i källkod

抽题模板缓存结构小题信息改为hash

xiatian 1 år sedan
förälder
incheckning
d6d8c4ecff

+ 14 - 0
examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/enums/QuestionDifficulty.java

@@ -1,5 +1,7 @@
 package cn.com.qmth.examcloud.core.questions.base.enums;
 
+import org.apache.commons.lang3.StringUtils;
+
 public enum QuestionDifficulty {
 	HARD("难"), MEDIUM("中"), EASY("易");
 
@@ -12,5 +14,17 @@ public enum QuestionDifficulty {
 	public String getName() {
 		return name;
 	}
+	
+	public static QuestionDifficulty getByName(String name) {
+		if(StringUtils.isBlank(name)) {
+			return null;
+		}
+		for(QuestionDifficulty e:QuestionDifficulty.values()) {
+			if(name.equals(e.getName())) {
+				return e;
+			}
+		}
+		return null;
+	}
 
 }

+ 6 - 1
examcloud-core-questions-dao/src/main/java/cn/com/qmth/examcloud/core/questions/dao/entity/PaperStruct.java

@@ -15,7 +15,12 @@ import java.util.Map;
 
 public class PaperStruct extends IdBase {
 
-    @Indexed(unique = true)
+    /**
+	 * 
+	 */
+	private static final long serialVersionUID = -1195997869648753373L;
+
+	@Indexed(unique = true)
     private String name;// 试卷结构名称
 
     private Double totalScore;// 总分

+ 2 - 2
examcloud-core-questions-dao/src/main/java/cn/com/qmth/examcloud/core/questions/dao/entity/RandomPaperQuestion.java

@@ -18,8 +18,8 @@ public class RandomPaperQuestion extends MongoBaseEntity {
 	private String randomPaperId;
 
 	private Long courseId;
-//	 精确结构:大题号-结构序号(1开始)-公开/非公开-难度  |  示例:1-1-true-
-//	  蓝图结构:大题号-一级属性id-二级属性id-公开/非公开-难度  |  示例:1-1-60efd3e85d030a52bb08b1e8-60efd3e85d030a52bb08b1e9-true-
+//	 精确结构:大题号-结构序号(1开始)-公开/非公开-难度  |  示例:1-1-true-HARD
+//	  蓝图结构:大题号-一级属性id-二级属性id-公开/非公开-难度  |  示例:1-1-60efd3e85d030a52bb08b1e8-60efd3e85d030a52bb08b1e9-true-HARD
 	private String key;
 
 	private String questionId;

+ 4 - 3
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/bean/randompaper/StructQuestionCheckDto.java

@@ -4,6 +4,7 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 
+import cn.com.qmth.examcloud.core.questions.base.enums.QuestionDifficulty;
 import cn.com.qmth.examcloud.core.questions.dao.entity.PaperDetailStruct;
 import cn.com.qmth.examcloud.core.questions.dao.entity.dto.CoursePropertyNumberDto;
 import cn.com.qmth.examcloud.core.questions.dao.entity.dto.PaperDetailUnitStructDto;
@@ -11,7 +12,7 @@ import cn.com.qmth.examcloud.core.questions.dao.entity.dto.PaperDetailUnitStruct
 public class StructQuestionCheckDto {
 	private Set<String> usedQuesIds = new HashSet<>();
 	private Boolean pub;
-	private String difficulty;
+	private QuestionDifficulty difficulty;
 	private PaperDetailUnitStructDto us;
 	private Integer index;
 	private Integer detailNumber;
@@ -71,11 +72,11 @@ public class StructQuestionCheckDto {
 		this.pub = pub;
 	}
 
-	public String getDifficulty() {
+	public QuestionDifficulty getDifficulty() {
 		return difficulty;
 	}
 
-	public void setDifficulty(String difficulty) {
+	public void setDifficulty(QuestionDifficulty difficulty) {
 		this.difficulty = difficulty;
 	}
 

+ 14 - 8
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/cache/RandomPaperCache.java

@@ -1,21 +1,19 @@
 package cn.com.qmth.examcloud.core.questions.service.cache;
 
-import java.util.List;
 import java.util.Map;
 
-import cn.com.qmth.examcloud.core.questions.dao.entity.RandomPaperQuestion;
-
 public class RandomPaperCache {
+	private String id;
 	private String name;
 
 	private String paperStructId;
 
 	/**
-	 * key描述 精确结构:大题号-结构序号(1开始)-公开/非公开-难度 | 示例:1-1-true-
+	 * key描述 精确结构:大题号-结构序号(1开始)-公开/非公开-难度 | 示例:1-1-true-HARD
 	 * 蓝图结构:大题号-一级属性id-二级属性id-公开/非公开-难度 |
-	 * 示例:1-1-60efd3e85d030a52bb08b1e8-60efd3e85d030a52bb08b1e9-true-
+	 * 示例:1-1-60efd3e85d030a52bb08b1e8-60efd3e85d030a52bb08b1e9-true-HARD
 	 */
-	private Map<String, List<RandomPaperQuestion>> questionMap;
+	private Map<String, Integer> questionMap;
 
 	public String getPaperStructId() {
 		return paperStructId;
@@ -25,11 +23,11 @@ public class RandomPaperCache {
 		this.paperStructId = paperStructId;
 	}
 
-	public Map<String, List<RandomPaperQuestion>> getQuestionMap() {
+	public Map<String, Integer> getQuestionMap() {
 		return questionMap;
 	}
 
-	public void setQuestionMap(Map<String, List<RandomPaperQuestion>> questionMap) {
+	public void setQuestionMap(Map<String, Integer> questionMap) {
 		this.questionMap = questionMap;
 	}
 
@@ -41,4 +39,12 @@ public class RandomPaperCache {
 		this.name = name;
 	}
 
+	public String getId() {
+		return id;
+	}
+
+	public void setId(String id) {
+		this.id = id;
+	}
+
 }