|
@@ -1,6 +1,9 @@
|
|
package cn.com.qmth.examcloud.core.questions.starter;
|
|
package cn.com.qmth.examcloud.core.questions.starter;
|
|
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
+import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
|
|
|
|
import org.junit.Test;
|
|
import org.junit.Test;
|
|
import org.junit.runner.RunWith;
|
|
import org.junit.runner.RunWith;
|
|
@@ -14,8 +17,10 @@ import org.springframework.test.context.junit4.SpringRunner;
|
|
import cn.com.qmth.examcloud.commons.base.logging.ExamCloudLog;
|
|
import cn.com.qmth.examcloud.commons.base.logging.ExamCloudLog;
|
|
import cn.com.qmth.examcloud.commons.base.logging.ExamCloudLogFactory;
|
|
import cn.com.qmth.examcloud.commons.base.logging.ExamCloudLogFactory;
|
|
import cn.com.qmth.examcloud.core.questions.dao.PaperDetailUnitRepo;
|
|
import cn.com.qmth.examcloud.core.questions.dao.PaperDetailUnitRepo;
|
|
|
|
+import cn.com.qmth.examcloud.core.questions.dao.QuesRepo;
|
|
import cn.com.qmth.examcloud.core.questions.dao.entity.Paper;
|
|
import cn.com.qmth.examcloud.core.questions.dao.entity.Paper;
|
|
import cn.com.qmth.examcloud.core.questions.dao.entity.PaperDetailUnit;
|
|
import cn.com.qmth.examcloud.core.questions.dao.entity.PaperDetailUnit;
|
|
|
|
+import cn.com.qmth.examcloud.core.questions.dao.entity.Question;
|
|
import cn.com.qmth.examcloud.core.questions.service.temp.DdExcelService;
|
|
import cn.com.qmth.examcloud.core.questions.service.temp.DdExcelService;
|
|
import cn.com.qmth.examcloud.core.questions.service.temp.vo.TestOption;
|
|
import cn.com.qmth.examcloud.core.questions.service.temp.vo.TestOption;
|
|
import cn.com.qmth.examcloud.core.questions.service.temp.vo.TestPaper;
|
|
import cn.com.qmth.examcloud.core.questions.service.temp.vo.TestPaper;
|
|
@@ -77,6 +82,9 @@ public class DdCollegeUtilTest {
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
DdExcelService ddExcelService;
|
|
DdExcelService ddExcelService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ QuesRepo quesRepo;
|
|
|
|
|
|
/* @Test
|
|
/* @Test
|
|
public void updatePaperType(){
|
|
public void updatePaperType(){
|
|
@@ -105,7 +113,139 @@ public class DdCollegeUtilTest {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+ @Test
|
|
|
|
+ public void saveQuestionTest(){
|
|
|
|
+ Map<String, String> map = new HashMap<String, String>();
|
|
|
|
+ map.put("a", "a");
|
|
|
|
+ Question question = new Question();
|
|
|
|
+ question.setOrgId("wwh");
|
|
|
|
+ question.setQuesBody("wwh");
|
|
|
|
+ question.setQuesAnswer("wwh");
|
|
|
|
+ question.setIsolated(true);
|
|
|
|
+ question.setProperties(map);
|
|
|
|
+
|
|
|
|
+ Map<String, String> map2 = new HashMap<String, String>();
|
|
|
|
+ map2.put("a", "a");
|
|
|
|
+ map2.put("b", "b");
|
|
|
|
+ Question question2 = new Question();
|
|
|
|
+ question2.setOrgId("wwh");
|
|
|
|
+ question2.setQuesBody("wwh");
|
|
|
|
+ question2.setQuesAnswer("wwh");
|
|
|
|
+ question2.setIsolated(true);
|
|
|
|
+ question2.setProperties(map2);
|
|
|
|
+
|
|
|
|
+ Map<String, String> map3 = new HashMap<String, String>();
|
|
|
|
+ map3.put("a", "a");
|
|
|
|
+ map3.put("b", "b");
|
|
|
|
+ map3.put("c", "c");
|
|
|
|
+ Question question3 = new Question();
|
|
|
|
+ question3.setOrgId("wwh");
|
|
|
|
+ question3.setQuesBody("wwh");
|
|
|
|
+ question3.setQuesAnswer("wwh");
|
|
|
|
+ question3.setIsolated(true);
|
|
|
|
+ question3.setProperties(map3);
|
|
|
|
+
|
|
|
|
+ Map<String, String> map4 = new HashMap<String, String>();
|
|
|
|
+ map4.put("d", "d");
|
|
|
|
+ Question question4 = new Question();
|
|
|
|
+ question4.setOrgId("wwh");
|
|
|
|
+ question4.setQuesBody("wwh");
|
|
|
|
+ question4.setQuesAnswer("wwh");
|
|
|
|
+ question4.setIsolated(true);
|
|
|
|
+ question4.setProperties(map4);
|
|
|
|
+
|
|
|
|
+ List<Question> list = new ArrayList<Question>();
|
|
|
|
+ list.add(question);
|
|
|
|
+ list.add(question2);
|
|
|
|
+ list.add(question3);
|
|
|
|
+ list.add(question4);
|
|
|
|
+
|
|
|
|
+ quesRepo.save(list);
|
|
|
|
+ System.out.println("插入完毕...");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Test
|
|
|
|
+ public void queryQuestionTest(){
|
|
|
|
+ Map<String, String> map = new HashMap<String, String>();
|
|
|
|
+ map.put("a", "a");
|
|
|
|
+ Query query = new Query();
|
|
|
|
+ for(Map.Entry<String, String> entry:map.entrySet()){
|
|
|
|
+ String key = "properties." + entry.getKey();
|
|
|
|
+ query.addCriteria(Criteria.where(key).is(entry.getValue()));
|
|
|
|
+ }
|
|
|
|
+ long count = this.mongoTemplate.count(query, Question.class);
|
|
|
|
+ List<Question> questionList = this.mongoTemplate.find(query, Question.class);
|
|
|
|
+ System.out.println("第一次查询:");
|
|
|
|
+ System.out.println("count:"+ count);
|
|
|
|
+ for(Question question:questionList){
|
|
|
|
+ System.out.println("question:"+question.getProperties());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Map<String, String> map2 = new HashMap<String, String>();
|
|
|
|
+ map2.put("d", "d");
|
|
|
|
+ Query query2 = new Query();
|
|
|
|
+ for(Map.Entry<String, String> entry:map2.entrySet()){
|
|
|
|
+ String key = "properties." + entry.getKey();
|
|
|
|
+ query2.addCriteria(Criteria.where(key).is(entry.getValue()));
|
|
|
|
+ }
|
|
|
|
+ long count2 = this.mongoTemplate.count(query2, Question.class);
|
|
|
|
+ List<Question> questionList2 = this.mongoTemplate.find(query2, Question.class);
|
|
|
|
+ System.out.println("第二次查询:");
|
|
|
|
+ System.out.println("count:"+ count2);
|
|
|
|
+ for(Question question:questionList2){
|
|
|
|
+ System.out.println("question:"+question.getProperties());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Map<String, String> map3 = new HashMap<String, String>();
|
|
|
|
+ map3.put("a", "a");
|
|
|
|
+ map3.put("b", "b");
|
|
|
|
+ Query query3 = new Query();
|
|
|
|
+ for(Map.Entry<String, String> entry:map3.entrySet()){
|
|
|
|
+ String key = "properties." + entry.getKey();
|
|
|
|
+ query3.addCriteria(Criteria.where(key).is(entry.getValue()));
|
|
|
|
+ }
|
|
|
|
+ long count3 = this.mongoTemplate.count(query3, Question.class);
|
|
|
|
+ List<Question> questionList3 = this.mongoTemplate.find(query3, Question.class);
|
|
|
|
+ System.out.println("第三次查询:");
|
|
|
|
+ System.out.println("count:"+ count3);
|
|
|
|
+ for(Question question:questionList3){
|
|
|
|
+ System.out.println("question:"+question.getProperties());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Map<String, String> map4 = new HashMap<String, String>();
|
|
|
|
+ map4.put("a", "a");
|
|
|
|
+ map4.put("b", "b");
|
|
|
|
+ map4.put("c", "c");
|
|
|
|
+ Query query4 = new Query();
|
|
|
|
+ for(Map.Entry<String, String> entry:map4.entrySet()){
|
|
|
|
+ String key = "properties." + entry.getKey();
|
|
|
|
+ query4.addCriteria(Criteria.where(key).is(entry.getValue()));
|
|
|
|
+ }
|
|
|
|
+ long count4 = this.mongoTemplate.count(query4, Question.class);
|
|
|
|
+ List<Question> questionList4 = this.mongoTemplate.find(query4, Question.class);
|
|
|
|
+ System.out.println("第四次查询:");
|
|
|
|
+ System.out.println("count:"+ count4);
|
|
|
|
+ for(Question question:questionList4){
|
|
|
|
+ System.out.println("question:"+question.getProperties());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Map<String, String> map5 = new HashMap<String, String>();
|
|
|
|
+ map5.put("a", "a");
|
|
|
|
+ map5.put("d", "d");
|
|
|
|
+ Query query5 = new Query();
|
|
|
|
+ for(Map.Entry<String, String> entry:map5.entrySet()){
|
|
|
|
+ String key = "properties." + entry.getKey();
|
|
|
|
+ query5.addCriteria(Criteria.where(key).is(entry.getValue()));
|
|
|
|
+ }
|
|
|
|
+ long count5 = this.mongoTemplate.count(query5, Question.class);
|
|
|
|
+ List<Question> questionList5 = this.mongoTemplate.find(query5, Question.class);
|
|
|
|
+ System.out.println("第五次查询:");
|
|
|
|
+ System.out.println("count:"+ count5);
|
|
|
|
+ for(Question question:questionList5){
|
|
|
|
+ System.out.println("question:"+question.getProperties());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|