From 14821e28286d773ad5ff2c13510e39c5eb117daf Mon Sep 17 00:00:00 2001
From: kongzy <kongzy>
Date: 星期五, 05 七月 2024 13:46:32 +0800
Subject: [PATCH] update

---
 exam-system/src/main/resources/mapper/system/ExCourseChapterMapper.xml |   50 ++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 42 insertions(+), 8 deletions(-)

diff --git a/exam-system/src/main/resources/mapper/system/ExCourseChapterMapper.xml b/exam-system/src/main/resources/mapper/system/ExCourseChapterMapper.xml
index 69815db..e552f0f 100644
--- a/exam-system/src/main/resources/mapper/system/ExCourseChapterMapper.xml
+++ b/exam-system/src/main/resources/mapper/system/ExCourseChapterMapper.xml
@@ -14,18 +14,42 @@
         <result property="updateBy"       column="update_by"       />
         <result property="updateTime"     column="update_time"     />
         <result property="remark"         column="remark"          />
-        <collection property="chapterPeriods" ofType="com.gkhy.exam.system.domain.ExCourseChapterPeriod" select="getChapterPeriodById" column="{chapterId=id}"/>
+        <collection property="chapterPeriods" ofType="com.gkhy.exam.system.domain.ExCourseChapterPeriod" select="getChapterPeriodByChapterId" column="{chapterId=id,status=filterStatus}"/>
+    </resultMap>
+
+    <resultMap type="com.gkhy.exam.system.domain.ExCourseChapterPeriod" id="ExPeriodResult">
+        <result property="id"       column="id"       />
+        <result property="name"    column="name"    />
+        <result property="courseId"     column="course_id"     />
+        <result property="chapterId"     column="chapter_id"     />
+        <result property="status"         column="status"          />
+        <result property="companyId"         column="company_id"          />
+        <result property="resourceId"         column="resource_id"          />
+        <result property="period"         column="period"          />
+        <result property="sort"         column="sort"          />
+        <result property="version"         column="version"          />
+        <result property="createBy"       column="create_by"       />
+        <result property="createTime"     column="create_time"     />
+        <result property="updateBy"       column="update_by"       />
+        <result property="updateTime"     column="update_time"     />
+        <result property="remark"         column="remark"          />
+        <association property="resource" javaType="com.gkhy.exam.system.domain.ExResource" resultMap="ExResourceResult" />
+    </resultMap>
+
+    <resultMap type="com.gkhy.exam.system.domain.ExResource" id="ExResourceResult">
+        <result property="id"       column="resource_id"       />
+        <result property="name"       column="resource_name"       />
+        <result property="resourcePath"       column="resource_path"       />
     </resultMap>
 
     <sql id="selectChapterVo">
-        select a.id, a.name, a.course_id, a.status,a.company_id, a.sort,a.version, a.create_by, a.create_time, a.update_by, a.update_time, a.remark,
-               b.id as period_id,a.id as chapter_id,b.name as period_name,b.resource_id
+        select a.id, a.name, a.course_id, a.status,a.company_id, a.sort,a.version, a.create_by, a.create_time, a.update_by, a.update_time, a.remark
         from ex_course_chapter a
-        left join ex_course_chapter_period b on b.chapter_id=a.id
     </sql>
 
     <select id="selectChapterList" resultMap="ExChapterResult">
-        <include refid="selectChapterVo"/>
+        select a.id, a.name, a.course_id, a.status,a.company_id, a.sort,a.version, a.create_by, a.create_time, a.update_by, a.update_time, a.remark,#{status} as filterStatus
+        from ex_course_chapter a
         <where>
             and a.course_id=#{courseId}
             <if test="name != null and name != ''">
@@ -49,7 +73,10 @@
 
 
     <select id="selectChapterByCourseId" resultMap="ExChapterResult">
-        select * from ex_course_chapter where course_id=#{courseId}
+        select *,#{status} as filterStatus from ex_course_chapter where course_id=#{courseId}
+        <if test="status!=null">
+            and status=#{status}
+        </if>
         order by sort asc,id desc
     </select>
 
@@ -57,8 +84,15 @@
         select count(1) from ex_course_chapter where course_id=#{courseId}
     </select>
 
-    <select id="getChapterPeriodById" resultType="com.gkhy.exam.system.domain.ExCourseChapterPeriod">
-        select * from ex_course_chapter_period where chapter_id=#{chapterId}
+    <select id="getChapterPeriodByChapterId" resultMap="ExPeriodResult">
+        select a.id,a.name,a.course_id,a.chapter_id,a.status,a.company_id,a.resource_id,
+               b.resource_length as period,b.name as resource_name,b.resource_path from ex_course_chapter_period a
+        left join ex_resource b on b.id=a.resource_id
+        where a.chapter_id=#{chapterId}
+        <if test="status!=null">
+            a.status=#{status}
+        </if>
+        order by a.sort asc,a.id desc
     </select>
 
     <select id="selectPeriodCountById" resultType="java.lang.Integer">

--
Gitblit v1.9.2