教育训练处考试制证系统后端
zhangf
2024-09-11 1a316551c8e46b793904090cfa84781bf77fef2a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.gkhy.exam.institutionalaccess.mapper.ThBatchMapper">
    <select id="listByPage" resultType="com.gkhy.exam.institutionalaccess.model.vo.ThBatchVO">
        select
            id,
            uuid,
            batch_name,
            institution_id,
            institution_name,
            train_org_name,
            have_exam,
            status,
            del_flag,
            create_time,
            update_time,
            actual_start_time,
            actual_end_time,
            expect_start_time,
            expect_end_time,
            subject_code
        from th_batch where del_flag = 0
        <if test="query.institutionId != null">
            and institution_id = #{query.institutionId}
        </if>
        <if test="query.batchName != null and query.batchName != ''">
            and batch_name like concat('%', #{query.batchaName}, '%')
        </if>
        <if test="query.subjectCode != null and query.subjectCode != ''">
            and subject_code like concat(#{query.subjectCode}, '%')
        </if>
        <if test="query.trainOrgName != null and query.trainOrgName != ''">
            and train_org_name = #{query.trainOrgName}, '%')
        </if>
        <if test="query.startTime != null"><!-- 开始时间检索 -->
            and date_format(actual_start_time,'%y-%m-%d') &gt;= date_format(#{query.startTime},'%y-%m-%d')
        </if>
        <if test="query.endTime != null"><!-- 结束时间检索 -->
            and date_format(actual_start_time,'%y-%m-%d') &lt;= date_format(#{query.endTime},'%y-%m-%d')
        </if>
        order by id desc
 
    </select>
    <!--批量插入-->
    <insert id="insertBatch">
        INSERT INTO th_batch (id, uuid, institution_id, institution_name,batch_name,have_exam,status,
        batch_lesson_num,train_org_name, del_flag,create_time,update_time,create_by,update_by,
            actual_start_time,actual_end_time,expect_start_time,expect_end_time,subject_code) VALUES
        <foreach collection="batchList" separator="," item="item">
            (#{item.id},#{item.uuid},#{item.institutionId},#{item.institutionName},#{item.batchName},#{item.haveExam},#{item.status},
            #{item.batchLessonNum},#{item.trainOrgName},#{item.delFlag},#{item.createTime},
            #{item.updateTime},#{item.createBy},#{item.updateBy},#{item.actualStartTime},#{item.actualEndTime},#{item.expectStartTime},#{item.expectEndTime},#{item.subjectCode})
        </foreach>
    </insert>
 
    <!--批量修改-->
    <update id="updateBatch" parameterType="java.util.List" >
        <foreach collection="batchList" item="item" index="index" separator=";">
            UPDATE th_batch
            <set>
                <if test="item.batchName != null and item.batchName != ''" >
                    `batch_name` = #{item.batchName},
                </if>
                <if test="item.uuid != null and item.uuid != ''" >
                    uuid = #{item.uuid},
                </if>
                <if test="item.haveExam != null" >
                    have_exam = #{item.haveExam},
                </if>
                <if test="item.status != null" >
                    status = #{item.status},
                </if>
                <if test="item.batchLessonNum != null" >
                    batch_lesson_num = #{item.batchLessonNum},
                </if>
                <if test="item.delFlag != null" >
                    del_flag = #{item.delFlag},
                </if>
                <if test="item.trainOrgName != null and item.trainOrgName != ''" >
                    train_org_name = #{item.trainOrgName},
                </if>
                <if test="item.institutionId != null" >
                    institution_id = #{item.institutionId},
                </if>
                <if test="item.institutionName != null and item.institutionName != ''" >
                    institution_name = #{item.institutionName},
                </if>
                <if test="item.updateBy != null and item.updateBy != ''" >
                    update_by = #{item.updateBy},
                </if>
                <if test="item.updateTime != null" >
                    update_time = #{item.updateTime},
                </if>
                <if test="item.actualStartTime != null" >
                    actual_start_time = #{item.actualStartTime},
                </if>
                <if test="item.actualEndTime != null" >
                    actual_end_time = #{item.actualEndTime},
                </if>
                <if test="item.expectStartTime != null" >
                    expect_start_time = #{item.expectStartTime},
                </if>
                <if test="item.expectEndTime != null" >
                    expect_end_time = #{item.expectEndTime},
                </if>
                <if test="item.subjectCode != null and item.subjectCode != ''" >
                    subject_code = #{item.subjectCode}
                </if>
            </set>
            where id = #{item.id}
        </foreach>
    </update>
 
    <!-- <update id="updateBatch" parameterType="java.util.List" >
         <foreach collection="batchList" item="item" index="index" separator=";">
             UPDATE th_batch
             <set>
                 <if test="item.batchName != null and item.batchName != ''" >
                     batch_name = #{item.batchName},
                 </if>
                 <if test="item.haveExam != null" >
                     have_exam = #{item.haveExam},
                 </if>
                 <if test="item.status != null" >
                     status = #{item.status},
                 </if>
                 <if test="item.delFlag != null" >
                     del_flag = #{item.delFlag},
                 </if>
                 <if test="item.trainOrgName != null and item.trainOrgName != ''" >
                     train_org_name = #{item.trainOrgName},
                 </if>
                 <if test="item.institutionId != null" >
                     institution_id = #{item.institutionId},
                 </if>
                 <if test="item.institutionName != null and item.institutionName != ''" >
                     institution_name = #{item.institutionName},
                 </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="getByUuids" resultType="com.gkhy.exam.institutionalaccess.entity.ThBatch">
        select id, uuid, institution_id, institution_name,batch_name,have_exam,status,
        batch_lesson_num,train_org_name,actual_start_time,actual_end_time,expect_start_time,expect_end_time,subject_code
        from th_batch
        where del_flag = 0 and uuid in
        <foreach collection="batchUuids" item="uuid" index ="index" open="(" close=")" separator=",">
            #{uuid}
        </foreach>
    </select>
 
    <select id="getBatchNameByUuids" resultType="com.gkhy.exam.institutionalaccess.entity.ThBatch">
        select id, uuid, batch_name
        from th_batch
        where del_flag = 0 and uuid in
        <foreach collection="batchUuids" item="uuid" index ="index" open="(" close=")" separator=",">
            #{uuid}
        </foreach>
    </select>
 
</mapper>