Преглед изворни кода

开发章节试卷(作业)中间表加个TYPE区分章节与课时

zhaosongshan пре 7 месеци
родитељ
комит
939c073a70

+ 1 - 1
snowy-plugin/snowy-plugin-exam/snowy-plugin-exam-api/src/main/java/vip/xiaonuo/exam/api/CourseChapterPaperApi.java

@@ -8,5 +8,5 @@ import java.util.Map;
  */
 public interface CourseChapterPaperApi {
     // 查询章节试卷(作业) 按章节ID chapterId 查询,按用户ID userId 查询个人记录
-    List<Map<String,Object>> queryListByChapterId(String chapterId, String userId);
+    List<Map<String,Object>> queryListByChapterId(String chapterId, String userId, String type);
 }

+ 10 - 0
snowy-plugin/snowy-plugin-exam/snowy-plugin-exam-func/src/main/java/vip/xiaonuo/exam/domain/CourseChapterPaper.java

@@ -10,6 +10,8 @@ package vip.xiaonuo.exam.domain;
 public class CourseChapterPaper {
     String chapterId;
     String paperId;
+    //chapterId的ID type 0 章节 1课时
+    String type;
 
     public String getChapterId() {
         return chapterId;
@@ -26,4 +28,12 @@ public class CourseChapterPaper {
     public void setPaperId(String paperId) {
         this.paperId = paperId;
     }
+
+    public String getType() {
+        return type;
+    }
+
+    public void setType(String type) {
+        this.type = type;
+    }
 }

+ 10 - 3
snowy-plugin/snowy-plugin-exam/snowy-plugin-exam-func/src/main/java/vip/xiaonuo/exam/mapper/mapping/CourseChapterPaperMapper.xml

@@ -4,9 +4,10 @@
     <resultMap id="BaseResultMap" type="vip.xiaonuo.exam.domain.CourseChapterPaper">
         <result column="CHAPTER_ID" jdbcType="VARCHAR" property="chapterId" />
         <result column="PAPER_ID" jdbcType="VARCHAR" property="paperId" />
+        <result column="TYPE" jdbcType="VARCHAR" property="type" />
     </resultMap>
     <sql id="Base_Column_List">
-        CHAPTER_ID, PAPER_ID
+        CHAPTER_ID, PAPER_ID, TYPE
     </sql>
     <select id="queryList" resultMap="BaseResultMap" parameterType="vip.xiaonuo.exam.domain.CourseChapterPaper">
         select
@@ -19,10 +20,13 @@
         <if test="paperId != null">
             and PAPER_ID = #{paperId,jdbcType=VARCHAR}
         </if>
+        <if test="type != null">
+            and TYPE = #{type,jdbcType=VARCHAR}
+        </if>
     </select>
     <insert id="add" parameterType="vip.xiaonuo.exam.domain.CourseChapterPaper">
-        insert into COURSE_CHAPTER_PAPER (CHAPTER_ID, PAPER_ID)
-        values (#{chapterId,jdbcType=VARCHAR}, #{paperId,jdbcType=VARCHAR})
+        insert into COURSE_CHAPTER_PAPER (CHAPTER_ID, PAPER_ID, TYPE)
+        values (#{chapterId,jdbcType=VARCHAR}, #{paperId,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR})
     </insert>
     <delete id="delete" parameterType="vip.xiaonuo.exam.domain.CourseChapterPaper">
         delete from COURSE_CHAPTER_PAPER
@@ -33,5 +37,8 @@
         <if test="paperId != null">
             and PAPER_ID = #{paperId,jdbcType=VARCHAR}
         </if>
+        <if test="type != null">
+            and TYPE = #{type,jdbcType=VARCHAR}
+        </if>
     </delete>
 </mapper>

+ 2 - 1
snowy-plugin/snowy-plugin-exam/snowy-plugin-exam-func/src/main/java/vip/xiaonuo/exam/service/impl/ExamPaperServiceImpl.java

@@ -217,7 +217,7 @@ public class ExamPaperServiceImpl extends BaseServiceImpl<ExamPaper> implements
      * @return List<Map<String, Object>>
      */
     @Override
-    public List<Map<String, Object>> queryListByChapterId(String chapterId, String userId) {
+    public List<Map<String, Object>> queryListByChapterId(String chapterId, String userId, String type) {
         List<Map<String, Object>> resultList = new ArrayList<>();
         try {
             if(chapterId == null || StringUtils.isEmpty(userId)){
@@ -225,6 +225,7 @@ public class ExamPaperServiceImpl extends BaseServiceImpl<ExamPaper> implements
             }
             CourseChapterPaper param = new CourseChapterPaper();
             param.setChapterId(chapterId);
+            param.setType(type);
             // 全部的试卷(作业)关联关系
             List<CourseChapterPaper> courseChapterList = courseChapterPaperService.queryList(param);
             if(courseChapterList.isEmpty()){