From f0f00e9ba8a755e4317e029d73b69a92ad9f9df1 Mon Sep 17 00:00:00 2001
From: kongzy <kongzy>
Date: 星期六, 14 九月 2024 17:02:41 +0800
Subject: [PATCH] update

---
 exam-system/src/main/resources/mapper/system/ExCoursePhaseMapper.xml |   29 ++++++++++++++++++++++++++---
 1 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/exam-system/src/main/resources/mapper/system/ExCoursePhaseMapper.xml b/exam-system/src/main/resources/mapper/system/ExCoursePhaseMapper.xml
index e843609..fc7cc68 100644
--- a/exam-system/src/main/resources/mapper/system/ExCoursePhaseMapper.xml
+++ b/exam-system/src/main/resources/mapper/system/ExCoursePhaseMapper.xml
@@ -15,11 +15,16 @@
         <result property="updateBy"       column="update_by"       />
         <result property="updateTime"     column="update_time"     />
         <result property="remark"         column="remark"          />
-        <result property="coursePeriod"         column="course_period"          />
+        <result property="courseName"         column="course_name"          />
+        <result property="companyName"         column="company_name"          />
+        <result property="studentCount"         column="student_count"          />
+        <result property="finishCount"         column="finish_count"          />
+        <association property="coursePeriod" javaType="java.lang.Long"  select="getCoursePeriod" column="{courseId=course_id}"/>
+        <association property="finishCount" javaType="java.lang.Integer"  select="getFinishStudentCount" column="{courseId=course_id,phaseId=id}"/>
     </resultMap>
 
     <sql id="selectCoursePhaseVo">
-        select a.id, a.name, a.code, a.company_id, a.course_id,a.level,a.del_flag,a.version, a.create_by, a.create_time, a.update_by, a.update_time, a.remark,b.period as course_period
+        select a.id, a.name, a.code, a.company_id, a.course_id,a.level,a.del_flag,a.version, a.create_by, a.create_time, a.update_by, a.update_time, a.remark,b.name as course_name
         from ex_course_phase a
         left join ex_course b on b.id=a.course_id
     </sql>
@@ -29,7 +34,12 @@
     </update>
 
     <select id="selectCoursePhaseList" resultMap="ExCoursePhaseResult">
-        <include refid="selectCoursePhaseVo"/>
+        select a.id, a.name, a.code, a.company_id, a.course_id,a.level,a.del_flag,a.version, a.create_by, a.create_time, a.update_by, a.update_time, a.remark,
+               b.name as course_name,c.name as company_name,
+               (select count(1) from ex_phase_student where phase_id=a.id) as student_count
+        from ex_course_phase a
+        left join ex_course b on b.id=a.course_id
+        left join sys_company c on c.id=a.company_id
         <where>
             and a.del_flag=0
             <if test="name != null and name != ''">
@@ -43,6 +53,9 @@
             </if>
             <if test="courseId != null and courseId != ''">
                 AND a.course_id =#{courseId}
+            </if>
+            <if test="level != null">
+                AND a.level =#{level}
             </if>
         </where>
         order by a.create_time desc
@@ -61,4 +74,14 @@
         select count(1) from ex_course_phase where del_flag=0 and courde_id=#{courseId}
     </select>
 
+    <select id="getCoursePeriod" resultType="java.lang.Long">
+        select sum(b.resource_length) from ex_course_chapter_period a
+        inner join ex_resource b on a.resource_id=b.id
+        where a.course_id=#{courseId}
+    </select>
+
+    <select id="getFinishStudentCount" resultType="java.lang.Integer">
+        select count(1) from (select student_id,count(1) as study_count from ex_student_study  where phase_id=#{phaseId} group by student_id) as a
+        where a.study_count=(select count(1) as period_count from ex_course_chapter_period  where course_id=#{courseId})
+    </select>
 </mapper>

--
Gitblit v1.9.2