deason 6 ani în urmă
părinte
comite
388e823b4e

+ 40 - 0
examcloud-core-print-service/src/main/java/cn/com/qmth/examcloud/core/print/service/CommonService.java

@@ -8,8 +8,12 @@
 package cn.com.qmth.examcloud.core.print.service;
 
 import cn.com.qmth.examcloud.core.print.common.jpa.SqlWrapper;
+import cn.com.qmth.examcloud.core.print.entity.ObjectiveQuestionStructure;
+import cn.com.qmth.examcloud.core.print.entity.SubjectiveQuestionStructure;
+import cn.com.qmth.examcloud.core.print.enums.QuesStructType;
 import cn.com.qmth.examcloud.core.print.service.bean.common.ExamCourseInfo;
 import cn.com.qmth.examcloud.core.print.service.bean.common.ExamInfo;
+import cn.com.qmth.examcloud.core.print.service.bean.questionstructure.PaperQuestionStructureInfo;
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -76,4 +80,40 @@ public class CommonService {
         return this.getExamCourseList(orgId, examId, null, null);
     }
 
+    public PaperQuestionStructureInfo findStructureByPaperId(String paperId) {
+        // just mock data todo
+        PaperQuestionStructureInfo info = new PaperQuestionStructureInfo();
+
+        ObjectiveQuestionStructure objective = new ObjectiveQuestionStructure();
+        objective.setExamId(1L);
+        objective.setCourseId(1L);
+        objective.setCourseCode("123456");
+        objective.setCourseName("测试课程");
+        objective.setPaperId("abc");
+        objective.setPaperName("测试试卷");
+        objective.setPaperType("A");
+        objective.setQuestionType(QuesStructType.SINGLE_ANSWER_QUESTION.name());
+        objective.setAnswer("1");
+        objective.setSectionNum(1);
+        objective.setUnitNum(1);
+        objective.setUnitScore(2.0);
+        info.addObjective(objective);
+
+        SubjectiveQuestionStructure subjective = new SubjectiveQuestionStructure();
+        subjective.setExamId(1L);
+        subjective.setCourseId(1L);
+        subjective.setCourseCode("123456");
+        subjective.setCourseName("测试课程");
+        subjective.setPaperId("abc");
+        subjective.setPaperName("测试试卷");
+        subjective.setPaperType("A");
+        subjective.setSectionNum(1);
+        subjective.setSectionName("简答题");
+        subjective.setUnitNum(1);
+        subjective.setUnitScore(2.0);
+        info.addSubjective(subjective);
+
+        return info;
+    }
+
 }

+ 15 - 0
examcloud-core-print-service/src/main/java/cn/com/qmth/examcloud/core/print/service/bean/questionstructure/PaperQuestionStructureInfo.java

@@ -11,6 +11,7 @@ import cn.com.qmth.examcloud.commons.web.cloud.api.JsonSerializable;
 import cn.com.qmth.examcloud.core.print.entity.ObjectiveQuestionStructure;
 import cn.com.qmth.examcloud.core.print.entity.SubjectiveQuestionStructure;
 
+import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -30,6 +31,20 @@ public class PaperQuestionStructureInfo implements JsonSerializable {
      */
     private List<SubjectiveQuestionStructure> subjectives;
 
+    public void addObjective(ObjectiveQuestionStructure objective) {
+        if (objectives == null) {
+            objectives = new ArrayList<>();
+        }
+        objectives.add(objective);
+    }
+
+    public void addSubjective(SubjectiveQuestionStructure subjective) {
+        if (subjectives == null) {
+            subjectives = new ArrayList<>();
+        }
+        subjectives.add(subjective);
+    }
+
     public List<ObjectiveQuestionStructure> getObjectives() {
         return objectives;
     }

+ 8 - 1
examcloud-core-print-service/src/main/java/cn/com/qmth/examcloud/core/print/service/impl/QuestionStructureServiceImpl.java

@@ -9,12 +9,16 @@ package cn.com.qmth.examcloud.core.print.service.impl;
 
 import cn.com.qmth.examcloud.core.print.repository.ObjectiveQuestionStructureRepository;
 import cn.com.qmth.examcloud.core.print.repository.SubjectiveQuestionStructureRepository;
+import cn.com.qmth.examcloud.core.print.service.CommonService;
 import cn.com.qmth.examcloud.core.print.service.QuestionStructureService;
+import cn.com.qmth.examcloud.core.print.service.bean.questionstructure.PaperQuestionStructureInfo;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import javax.validation.constraints.NotNull;
+
 /**
  * @author: fengdesheng
  * @since: 2018/10/17
@@ -26,9 +30,12 @@ public class QuestionStructureServiceImpl implements QuestionStructureService {
     private SubjectiveQuestionStructureRepository subjectiveQuestionStructureRepository;
     @Autowired
     private ObjectiveQuestionStructureRepository objectiveQuestionStructureRepository;
+    @Autowired
+    private CommonService commonService;
 
     @Override
-    public void savePaperQuestionStructure(Long examId, String paperId) {
+    public void savePaperQuestionStructure(@NotNull Long examId, @NotNull String paperId) {
+        PaperQuestionStructureInfo info = commonService.findStructureByPaperId(paperId);
         //todo
     }