Przeglądaj źródła

更新数据库字段

deason 6 lat temu
rodzic
commit
e6fe6034b7

+ 46 - 48
examcloud-core-print-dao/src/main/java/cn/com/qmth/examcloud/core/print/entity/ObjectiveQuestionStructure.java

@@ -10,10 +10,7 @@ package cn.com.qmth.examcloud.core.print.entity;
 import cn.afterturn.easypoi.excel.annotation.Excel;
 import cn.com.qmth.examcloud.core.print.common.IdEntity;
 
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.Index;
-import javax.persistence.Table;
+import javax.persistence.*;
 
 /**
  * 客观题信息(用于Excel导出)
@@ -55,26 +52,6 @@ public class ObjectiveQuestionStructure extends IdEntity {
     @Excel(name = "试卷名称", orderNum = "2")
     @Column(length = 100)
     private String paperName;
-    /**
-     * 试卷类型(如:A、B)
-     */
-    @Excel(name = "试卷类型", orderNum = "3")
-    @Column(length = 50)
-    private String paperType;
-    /**
-     * 题目类型
-     *
-     * @See QuesStructType.java
-     */
-    @Excel(name = "题目类型", orderNum = "6")
-    @Column(length = 50)
-    private String questionType;
-    /**
-     * 标准答案
-     */
-    @Excel(name = "标准答案", orderNum = "7")
-    @Column(length = 50)
-    private String answer;
     /**
      * 大题号
      */
@@ -90,6 +67,27 @@ public class ObjectiveQuestionStructure extends IdEntity {
      */
     @Excel(name = "分数", orderNum = "8")
     private Double unitScore;
+    /**
+     * 标准答案
+     */
+    @Excel(name = "标准答案", orderNum = "7")
+    @Column(length = 50)
+    private String answer;
+    /**
+     * 题目类型
+     *
+     * @See QuesStructType.java
+     */
+    @Excel(name = "题目类型", orderNum = "6")
+    @Column(length = 50)
+    private String questionType;
+    /**
+     * 试卷类型(如:A、B)
+     * 该字段不持久化到数据库
+     */
+    @Excel(name = "试卷类型", orderNum = "3")
+    @Transient
+    private String paperType;
 
     public Long getExamId() {
         return examId;
@@ -139,30 +137,6 @@ public class ObjectiveQuestionStructure extends IdEntity {
         this.paperName = paperName;
     }
 
-    public String getPaperType() {
-        return paperType;
-    }
-
-    public void setPaperType(String paperType) {
-        this.paperType = paperType;
-    }
-
-    public String getQuestionType() {
-        return questionType;
-    }
-
-    public void setQuestionType(String questionType) {
-        this.questionType = questionType;
-    }
-
-    public String getAnswer() {
-        return answer;
-    }
-
-    public void setAnswer(String answer) {
-        this.answer = answer;
-    }
-
     public Integer getSectionNum() {
         return sectionNum;
     }
@@ -187,4 +161,28 @@ public class ObjectiveQuestionStructure extends IdEntity {
         this.unitScore = unitScore;
     }
 
+    public String getAnswer() {
+        return answer;
+    }
+
+    public void setAnswer(String answer) {
+        this.answer = answer;
+    }
+
+    public String getQuestionType() {
+        return questionType;
+    }
+
+    public void setQuestionType(String questionType) {
+        this.questionType = questionType;
+    }
+
+    public String getPaperType() {
+        return paperType;
+    }
+
+    public void setPaperType(String paperType) {
+        this.paperType = paperType;
+    }
+
 }

+ 24 - 25
examcloud-core-print-dao/src/main/java/cn/com/qmth/examcloud/core/print/entity/SubjectiveQuestionStructure.java

@@ -10,10 +10,7 @@ package cn.com.qmth.examcloud.core.print.entity;
 import cn.afterturn.easypoi.excel.annotation.Excel;
 import cn.com.qmth.examcloud.core.print.common.IdEntity;
 
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.Index;
-import javax.persistence.Table;
+import javax.persistence.*;
 
 /**
  * 主观题信息(用于Excel导出)
@@ -55,11 +52,6 @@ public class SubjectiveQuestionStructure extends IdEntity {
     @Excel(name = "试卷名称", orderNum = "2")
     @Column(length = 100)
     private String paperName;
-    /**
-     * 试卷类型(如:A、B)
-     */
-    @Excel(name = "试卷类型", orderNum = "3")
-    private String paperType;
     /**
      * 大题号
      */
@@ -82,6 +74,13 @@ public class SubjectiveQuestionStructure extends IdEntity {
      */
     @Excel(name = "满分", orderNum = "7")
     private Double unitScore;
+    /**
+     * 试卷类型(如:A、B)
+     * 该字段不持久化到数据库
+     */
+    @Excel(name = "试卷类型", orderNum = "3")
+    @Transient
+    private String paperType;
 
     public Long getExamId() {
         return examId;
@@ -91,14 +90,6 @@ public class SubjectiveQuestionStructure extends IdEntity {
         this.examId = examId;
     }
 
-    public String getPaperId() {
-        return paperId;
-    }
-
-    public void setPaperId(String paperId) {
-        this.paperId = paperId;
-    }
-
     public Long getCourseId() {
         return courseId;
     }
@@ -123,20 +114,20 @@ public class SubjectiveQuestionStructure extends IdEntity {
         this.courseName = courseName;
     }
 
-    public String getPaperName() {
-        return paperName;
+    public String getPaperId() {
+        return paperId;
     }
 
-    public void setPaperName(String paperName) {
-        this.paperName = paperName;
+    public void setPaperId(String paperId) {
+        this.paperId = paperId;
     }
 
-    public String getPaperType() {
-        return paperType;
+    public String getPaperName() {
+        return paperName;
     }
 
-    public void setPaperType(String paperType) {
-        this.paperType = paperType;
+    public void setPaperName(String paperName) {
+        this.paperName = paperName;
     }
 
     public Integer getSectionNum() {
@@ -171,4 +162,12 @@ public class SubjectiveQuestionStructure extends IdEntity {
         this.unitScore = unitScore;
     }
 
+    public String getPaperType() {
+        return paperType;
+    }
+
+    public void setPaperType(String paperType) {
+        this.paperType = paperType;
+    }
+
 }

+ 0 - 2
examcloud-core-print-dao/src/main/resources/db-schema.sql

@@ -87,7 +87,6 @@ CREATE TABLE ec_prt_objective_question_structure (
   exam_id       bigint(20)          DEFAULT NULL,
   paper_id      varchar(50)         DEFAULT NULL,
   paper_name    varchar(100)        DEFAULT NULL,
-  paper_type    varchar(50)         DEFAULT NULL,
   question_type varchar(50)         DEFAULT NULL,
   section_num   int(11)             DEFAULT NULL,
   unit_num      int(11)             DEFAULT NULL,
@@ -191,7 +190,6 @@ CREATE TABLE ec_prt_subjective_question_structure (
   exam_id       bigint(20)          DEFAULT NULL,
   paper_id      varchar(50)         DEFAULT NULL,
   paper_name    varchar(100)        DEFAULT NULL,
-  paper_type    varchar(255)        DEFAULT NULL,
   section_name  varchar(100)        DEFAULT NULL,
   section_num   int(11)             DEFAULT NULL,
   unit_num      int(11)             DEFAULT NULL,

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

@@ -60,12 +60,20 @@ public class QuestionStructureServiceImpl implements ExamQuestionStructureServic
         //保存客观题数据
         List<ObjectiveQuestionStructure> objectives = info.getObjectives();
         if (objectives != null && !objectives.isEmpty()) {
+            for (ObjectiveQuestionStructure structure : objectives) {
+                structure.setExamId(examId);
+                structure.setPaperId(paperId);
+            }
             objectiveQuestionStructureRepository.save(info.getObjectives());
         }
 
         //保存主观题数据
         List<SubjectiveQuestionStructure> subjectives = info.getSubjectives();
         if (subjectives != null && !subjectives.isEmpty()) {
+            for (SubjectiveQuestionStructure structure : subjectives) {
+                structure.setExamId(examId);
+                structure.setPaperId(paperId);
+            }
             subjectiveQuestionStructureRepository.save(info.getSubjectives());
         }
     }