From 7f25606654ebe94b5d82cfd9f74275989c71538d Mon Sep 17 00:00:00 2001
From: 龚焕茏 <2842157468@qq.com>
Date: 星期二, 16 七月 2024 11:47:40 +0800
Subject: [PATCH] feat:默认选中当前部门

---
 src/main/resources/mapper/ExamTemplatesMapper.xml |   66 +++++++++++++++++++++-----------
 1 files changed, 43 insertions(+), 23 deletions(-)

diff --git a/src/main/resources/mapper/ExamTemplatesMapper.xml b/src/main/resources/mapper/ExamTemplatesMapper.xml
index 3e2fda7..8dffc26 100644
--- a/src/main/resources/mapper/ExamTemplatesMapper.xml
+++ b/src/main/resources/mapper/ExamTemplatesMapper.xml
@@ -16,12 +16,12 @@
 
     <sql id="Base_Column_List">
         id
-        , name, paper_type, suggest_time, title_name, ctime, status, menu_ids,start_time,end_time
+        , name, paper_type, suggest_time, title_name, ctime, status, menu_ids,start_time,end_time, dept_id
     </sql>
 
     <insert id="add" parameterType="com.mindskip.xzs.domain.ExamTemplates" useGeneratedKeys="true" keyProperty="id">
-        insert into t_exam_templates (name, paper_type, suggest_time, title_name, ctime, status, menu_ids,start_time,end_time)
-        values (#{name}, #{paperType}, #{suggestTime}, #{titleName}, #{ctime}, #{status}, #{menuIds},#{startTime},#{endTime})
+        insert into t_exam_templates (name, paper_type, dept_id, suggest_time, title_name, ctime, status, menu_ids,start_time,end_time,create_user)
+        values (#{name}, #{paperType}, #{deptId}, #{suggestTime}, #{titleName}, #{ctime}, #{status}, #{menuIds},#{startTime},#{endTime}, #{createUser})
     </insert>
 
     <select id="getTime" resultMap="BaseResultMap">
@@ -34,28 +34,11 @@
 
     <select id="gets" resultMap="BaseResultMap" parameterType="com.mindskip.xzs.domain.vo.ExamTemplatesVO">
         select
-        e.*
+        DISTINCT  e.id
+        , e.name, e.paper_type, e.suggest_time, e.title_name, e.ctime, e.status, e.menu_ids,e.start_time,e.end_time,e.ctime
         from t_exam_templates e
         inner join t_exam_templates_user u on e.id = u.templates_id
         <where>
-            paper_type != 7
-            <if test="status != null">
-                and e.status = 0
-            </if>
-            <if test="status == null">
-                and e.status is null
-            </if>
-            <if test="userId != null">
-                and u.user_id = #{userId}
-            </if>
-        </where>
-        union all
-        select
-        e.*
-        from t_exam_templates e
-        inner join t_exam_templates_user u on e.id = u.templates_id
-        <where>
-            paper_type = 7
             <if test="status != null">
                 and e.status = 0
             </if>
@@ -69,6 +52,43 @@
                 and #{now} between e.start_time and e.end_time
             </if>
         </where>
+    </select>
+
+    <select id="getByadmins" resultMap="BaseResultMap" parameterType="com.mindskip.xzs.domain.vo.ExamTemplatesVO">
+        select
+        DISTINCT  e.id
+        , e.name, e.paper_type, e.suggest_time, e.title_name, e.ctime, e.status, e.menu_ids,e.start_time,e.end_time, e.create_user
+        from t_exam_templates e
+        left join t_exam_templates_user u on e.id = u.templates_id
+        LEFT JOIN t_exam_templates_subject ts ON e.id = ts.templates_id
+        LEFT JOIN t_subject s ON ts.subject_id = s.id
+        <where>
+            <if test="status != null">
+                and e.status = 0
+            </if>
+            <if test="status == null">
+                and e.status is null
+            </if>
+            <if test="userId != null">
+                and u.user_id = #{userId}
+            </if>
+            <if test="deptId != null and deptId.size() > 0">
+                and e.dept_id in <foreach collection="deptId" item="item" separator="," open="(" close=")"> #{item} </foreach>
+            </if>
+            <if test="name != null and name != ''">
+                and INSTR(e.name, #{name})
+            </if>
+            <if test="subjectId != null and subjectId.length > 0">
+                and s.id in <foreach collection="subjectId" item="item" separator="," open="(" close=")"> #{item} </foreach>
+            </if>
+            <if test="period != null and period.size() > 0">
+                and e.ctime between #{period[0]} and #{period[1]}
+            </if>
+            <if test="now !=null">
+                and #{now} between e.start_time and e.end_time
+            </if>
+        </where>
+        GROUP BY e.id
     </select>
 
     <select id="getById" resultMap="BaseResultMap">
@@ -88,4 +108,4 @@
         where id = #{id}
     </delete>
 
-</mapper>
\ No newline at end of file
+</mapper>

--
Gitblit v1.8.0