From 790c2ba4a0b46edf191e3bac84931f796bd42b8f Mon Sep 17 00:00:00 2001
From: zhangf <1603559716@qq.com>
Date: 星期三, 24 七月 2024 09:02:49 +0800
Subject: [PATCH] 三方对接接口优化

---
 exam-system/src/main/resources/mapper/institutionaccess/ThBatchCourseMapper.xml |   90 ++++++++++++++++++++++++++++++++++++++------
 1 files changed, 77 insertions(+), 13 deletions(-)

diff --git a/exam-system/src/main/resources/mapper/institutionaccess/ThBatchCourseMapper.xml b/exam-system/src/main/resources/mapper/institutionaccess/ThBatchCourseMapper.xml
index a96188b..2488a30 100644
--- a/exam-system/src/main/resources/mapper/institutionaccess/ThBatchCourseMapper.xml
+++ b/exam-system/src/main/resources/mapper/institutionaccess/ThBatchCourseMapper.xml
@@ -4,7 +4,7 @@
 
     <update id="deleteByBatchUuidAndCourseUuid" parameterType="java.util.List" >
         <foreach collection="list" item="item" index="index" separator=";">
-            UPDATE batch_course
+            UPDATE th_batch_course
             <set>
                 <if test="item.delFlag != null" >
                     del_flag = #{item.delFlag}
@@ -14,28 +14,92 @@
             and course_uuid = #{item.courseUuid}
         </foreach>
     </update>
+    <update id="deleteByBatchUuid"  >
 
-    <select id="getListByBatchUuids" resultType="com.gkhy.exam.institutionalaccess.model.vo.ThBatchCourseVO">
-        select bc.*,c.course_name from th_batch_course bc
-        left join th_course c on c.uuid = bc.course_uuid
-        where bc.del_flag = 0
-        and bc.batch_uuid in
-        <foreach collection="batchUuids" item="batchUuid" open="(" close=")" separator=",">
-            #{batchUuid}
-        </foreach>
-    </select>
+            UPDATE th_batch_course
+            set del_flag = 2
+            where batch_uuid = #{batchUuid}
+
+    </update>
 
     <select id="getListByBatchUuid" resultType="com.gkhy.exam.institutionalaccess.model.vo.ThBatchCourseVO">
         SELECT
             bc.*,
-            c.course_name ,
-            (SELECT sum(cc.duration) from th_course_chapter cc where cc.course_uuid = bc.course_uuid) duration
+            (
+                SELECT
+                    sum( cc.duration )
+                FROM
+                    th_batch_course_chapter cc
+                WHERE
+                    cc.course_uuid = bc.course_uuid
+                  AND cc.del_flag = 0
+                  AND cc.batch_uuid = bc.batch_uuid
+            ) duration
         FROM
             th_batch_course bc
-            LEFT JOIN th_course c ON c.uuid = bc.course_uuid
         WHERE
             bc.del_flag = 0
           AND bc.batch_uuid = #{batchUuid}
     </select>
+
+    <!--批量插入-->
+    <insert id="insertBatch">
+        INSERT INTO th_batch_course (id, course_uuid,course_name,course_lesson_num,batch_uuid,
+                                     institution_id,
+        train_org_name, del_flag,create_time,update_time,create_by,update_by) VALUES
+        <foreach collection="courseList" separator="," item="item">
+            (#{item.id},#{item.courseUuid},#{item.courseName},#{item.courseLessonNum},
+             #{item.batchUuid},#{item.institutionId},
+            #{item.trainOrgName},#{item.delFlag},#{item.createTime},
+            #{item.updateTime},#{item.createBy},#{item.updateBy})
+        </foreach>
+    </insert>
+
+    <!--批量修改-->
+    <update id="updateBatch" parameterType="java.util.List" >
+        <foreach collection="courseList" item="item" index="index" separator=";">
+            UPDATE th_batch_course
+            <set>
+                <if test="item.courseUuid != null and item.courseUuid != ''" >
+                    course_uuid = #{item.courseUuid},
+                </if>
+                <if test="item.courseName != null and item.courseName != ''" >
+                    course_name = #{item.courseName},
+                </if>
+                <if test="item.courseLessonNum != null" >
+                    course_lesson_num = #{item.courseLessonNum},
+                </if>
+                <if test="item.batchUuid != null and item.batchUuid != ''" >
+                    batch_uuid = #{item.batchUuid},
+                </if>
+                <if test="item.institutionId != null" >
+                    institution_id = #{item.institutionId},
+                </if>
+                <if test="item.trainOrgName != null and item.trainOrgName != ''" >
+                    train_org_name = #{item.trainOrgName},
+                </if>
+                <if test="item.delFlag != null" >
+                    del_flag = #{item.delFlag},
+                </if>
+                <if test="item.updateBy != null and item.updateBy != ''" >
+                    update_by = #{item.updateBy},
+                </if>
+                <if test="item.updateTime != null" >
+                    update_time = #{item.updateTime}
+                </if>
+            </set>
+            where id = #{item.id}
+        </foreach>
+    </update>
+
+    <select id="getByBatchUuids" resultType="com.gkhy.exam.institutionalaccess.entity.ThBatchCourse">
+        select id, course_uuid,course_name,course_lesson_num,batch_uuid,
+        institution_id,train_org_name
+        from th_batch_course
+        where del_flag = 0 and batch_uuid in
+        <foreach collection="batchUuids" item="batchUuid" index ="index" open="(" close=")" separator=",">
+            #{batchUuid}
+        </foreach>
+    </select>
 </mapper>
 

--
Gitblit v1.9.2