linzhijie
2021-03-11 c33914ba0a98c823c4b4d7da21cdd476906c9924
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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
<?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.ots.project.exam.mapper.EntTestPackageMapper">
    
    <resultMap type="EntTestPackage" id="EntTestPackageResult">
        <result property="id"    column="id"    />
        <result property="prodId"    column="prod_id"    />
        <result property="userId"    column="user_id"    />
        <result property="testName"    column="test_name"    />
        <result property="prodName"    column="prod_name"    />
        <result property="testType"    column="test_type"    />
        <result property="testArea"    column="test_area"    />
        <result property="langType"    column="lang_type"    />
        <result property="testEmail"    column="test_email"    />
        <result property="frameTextContentId"    column="frame_text_content_id"    />
        <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="invalidTime"    column="invalid_time"    />
        <result property="paramCodes"    column="param_codes"    />
        <result property="status"    column="status"    />
        <result property="template"    column="template"    />
        <result property="remark"    column="remark"    />
        <result property="userName"    column="user_name"    />
        <result property="autoSendReport"    column="auto_send_report"    />
        <result property="hrTemplate"    column="hrTemplate"    />
        <result property="reportTemplateId"    column="report_template_id"    />
        <result property="position"    column="position"    />
        <result property="professionalCategory"    column="professional_category"    />
        <result property="superiorPosition"    column="superior_position"    />
        <result property="phonenumber"    column="phonenumber"    />
    </resultMap>
 
    <sql id="selectEntTestPackageVo">
        select id,prod_id, p.user_id, test_name,prod_name, test_type, test_area, lang_type, test_email, frame_text_content_id, create_by, create_time, update_by, update_time, invalid_time,p.param_codes, status, template,remark, auto_send_report,report_template_id,p.hrTemplate, p.position,p.superior_position, p.professional_category from ent_test_package p
    </sql>
 
    <sql id="selectEntTestPackageSuVo">
        select p.id, p.prod_id, p.user_id, p.test_name, p.prod_name, p.test_type, p.test_area, p.lang_type, p.test_email, p.frame_text_content_id, p.create_by, p.create_time, p.update_by, p.update_time, p.invalid_time,p.param_codes, p.status, p.template, p.remark, p.auto_send_report, p.report_template_id,p.hrTemplate, p.position,p.superior_position, p.professional_category, u.user_name from ent_test_package p
        left join sys_user u on u.user_id = p.user_id
    </sql>
 
    <select id="selectEntTestPackageList" parameterType="EntTestPackage" resultMap="EntTestPackageResult">
        select id,prod_id, p.user_id, p.test_name,p.prod_name, p.test_type, p.test_area, p.lang_type, p.test_email, p.frame_text_content_id, p.create_by, p.create_time, p.update_by, p.update_time, p.invalid_time,p.param_codes, p.status, p.template,p.remark,u.user_name,p.auto_send_report,p.report_template_id,p.hrTemplate,u.phonenumber from ent_test_package p
        left join sys_user u on u.user_id = p.user_id
        <where>  
            <if test="userId != null "> and p.user_id = #{userId}</if>
            <if test="testName != null  and testName != ''"> and p.test_name like concat('%', #{testName}, '%')</if>
            <if test="userName != null  and userName != ''"> and u.user_name like concat('%', #{userName}, '%')</if>
            <if test="testType != null  and testType != ''"> and p.test_type = #{testType}</if>
            <if test="testArea != null  and testArea != ''"> and p.test_area = #{testArea}</if>
            <if test="langType != null  and langType != ''"> and p.lang_type = #{langType}</if>
            <if test="testEmail != null  and testEmail != ''"> and p.test_email = #{testEmail}</if>
            <if test="frameTextContentId != null "> and p.frame_text_content_id = #{frameTextContentId}</if>
            <if test="invalidTime != null "> and p.invalid_time = #{invalidTime}</if>
            <if test="status != null  and status != ''"> and p.status = #{status}</if>
            <if test="reportTemplateId != null  and reportTemplateId != ''"> and p.report_template_id = #{reportTemplateId}</if>
            <if test="userIds != null "> and p.user_id in
                <foreach item="userIds" collection="userIds" open="(" separator="," close=")">
                  #{userIds}
                </foreach>
            </if>
        </where>
        order by p.id desc,p.update_time desc
    </select>
 
 
    <select id="selectEntTestPackageMainList" parameterType="EntTestPackage" resultMap="EntTestPackageResult">
        select id,prod_id, p.user_id, p.test_name,p.prod_name, p.test_type, p.test_area, p.lang_type, p.test_email, p.frame_text_content_id, p.create_by, p.create_time, p.update_by, p.update_time, p.invalid_time,p.param_codes, p.status, p.template,p.remark,u.user_name,p.auto_send_report,p.report_template_id,p.hrTemplate,u.phonenumber from ent_test_package p
        left join sys_user u on u.user_id = p.user_id
        <where>
            <if test="userId != null "> and p.user_id = #{userId}</if>
            <if test="testName != null  and testName != ''"> and p.test_name like concat('%', #{testName}, '%')</if>
            <if test="userName != null  and userName != ''"> and u.user_name like concat('%', #{userName}, '%')</if>
            <if test="testType != null  and testType != ''"> and p.test_type = #{testType}</if>
            <if test="testArea != null  and testArea != ''"> and p.test_area = #{testArea}</if>
            <if test="langType != null  and langType != ''"> and p.lang_type = #{langType}</if>
            <if test="testEmail != null  and testEmail != ''"> and p.test_email = #{testEmail}</if>
            <if test="frameTextContentId != null "> and p.frame_text_content_id = #{frameTextContentId}</if>
            <if test="invalidTime != null "> and p.invalid_time = #{invalidTime}</if>
            <if test="status != null  and status != ''"> and p.status = #{status}</if>
            <if test="reportTemplateId != null  and reportTemplateId != ''"> and p.report_template_id = #{reportTemplateId}</if>
            <if test="userIds != null "> and p.user_id in
                <foreach item="userIds" collection="userIds" open="(" separator="," close=")">
                    #{userIds}
                </foreach>
            </if>
        </where>
    </select>
 
    <select id="selectEntTestPackageListByIdAndStatusIn" parameterType="java.util.Map" resultMap="EntTestPackageResult">
        <include refid="selectEntTestPackageVo"/>
        <where>
            <if test="status != null "> status in
                <foreach item="status" collection="status" open="(" separator="," close=")">
                    #{status}
                </foreach>
            </if>
            <if test="userId != null "> and p.user_id = #{userId}</if>
            <if test="invalid != null"> and now() > invalid_time </if>
        </where>
    </select>
    
    <select id="selectEntTestPackageById" parameterType="Long" resultMap="EntTestPackageResult">
        <include refid="selectEntTestPackageSuVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertEntTestPackage" parameterType="EntTestPackage" useGeneratedKeys="true" keyProperty="id">
        insert into ent_test_package
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="userId != null ">user_id,</if>
            <if test="prodId != null ">prod_id,</if>
            <if test="testName != null  and testName != ''">test_name,</if>
            <if test="prodName != null  and prodName != ''">prod_name,</if>
            <if test="testType != null  and testType != ''">test_type,</if>
            <if test="testArea != null  and testArea != ''">test_area,</if>
            <if test="langType != null  and langType != ''">lang_type,</if>
            <if test="testEmail != null  and testEmail != ''">test_email,</if>
            <if test="frameTextContentId != null ">frame_text_content_id,</if>
            <if test="createBy != null  and createBy != ''">create_by,</if>
            <if test="createTime != null ">create_time,</if>
            <if test="updateBy != null  and updateBy != ''">update_by,</if>
            <if test="hrTemplate != null  and hrTemplate != ''">hrTemplate,</if>
            <if test="updateTime != null ">update_time,</if>
            <if test="invalidTime != null ">invalid_time,</if>
            <if test="paramCodes != null ">param_codes,</if>
            <if test="status != null  and status != ''">status,</if>
            <if test="template != null  and template != ''">template,</if>
            <if test="remark != null  and remark != ''">remark,</if>
            <if test="autoSendReport != null  and autoSendReport != ''">auto_send_report,</if>
            <if test="reportTemplateId != null  and reportTemplateId != ''">report_template_id,</if>
            <if test="position != null  and position != ''">position,</if>
            <if test="professionalCategory != null  and professionalCategory != ''">professional_category,</if>
            <if test="superiorPosition != null  and superiorPosition != ''">superior_position,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="userId != null ">#{userId},</if>
            <if test="prodId != null ">#{prodId},</if>
            <if test="testName != null  and testName != ''">#{testName},</if>
            <if test="prodName != null  and prodName != ''">#{prodName},</if>
            <if test="testType != null  and testType != ''">#{testType},</if>
            <if test="testArea != null  and testArea != ''">#{testArea},</if>
            <if test="langType != null  and langType != ''">#{langType},</if>
            <if test="testEmail != null  and testEmail != ''">#{testEmail},</if>
            <if test="frameTextContentId != null ">#{frameTextContentId},</if>
            <if test="createBy != null  and createBy != ''">#{createBy},</if>
            <if test="createTime != null ">#{createTime},</if>
            <if test="updateBy != null  and updateBy != ''">#{updateBy},</if>
            <if test="hrTemplate != null  and hrTemplate != ''">#{hrTemplate},</if>
            <if test="updateTime != null ">#{updateTime},</if>
            <if test="invalidTime != null ">#{invalidTime},</if>
            <if test="paramCodes != null ">#{paramCodes},</if>
            <if test="status != null  and status != ''">#{status},</if>
            <if test="template != null  and template != ''">#{template},</if>
            <if test="remark != null  and remark != ''">#{remark},</if>
            <if test="autoSendReport != null  and autoSendReport != ''">#{autoSendReport},</if>
            <if test="reportTemplateId != null  and reportTemplateId != ''">#{reportTemplateId},</if>
            <if test="position != null  and position != ''">#{position},</if>
            <if test="professionalCategory != null  and professionalCategory != ''">#{professionalCategory},</if>
            <if test="superiorPosition != null  and superiorPosition != ''">#{superiorPosition},</if>
         </trim>
    </insert>
 
    <update id="updateEntTestPackage" parameterType="EntTestPackage">
        update ent_test_package
        <trim prefix="SET" suffixOverrides=",">
            <if test="userId != null ">user_id = #{userId},</if>
            <if test="prodId != null ">prod_id = #{prodId},</if>
            <if test="testName != null  and testName != ''">test_name = #{testName},</if>
            <if test="prodName != null  and prodName != ''">prod_name = #{prodName},</if>
            <if test="testType != null  and testType != ''">test_type = #{testType},</if>
            <if test="testArea != null  and testArea != ''">test_area = #{testArea},</if>
            <if test="langType != null  and langType != ''">lang_type = #{langType},</if>
            <if test="testEmail != null  and testEmail != ''">test_email = #{testEmail},</if>
            <if test="frameTextContentId != null ">frame_text_content_id = #{frameTextContentId},</if>
            <if test="createBy != null  and createBy != ''">create_by = #{createBy},</if>
            <if test="hrTemplate != null  and hrTemplate != ''">hrTemplate = #{hrTemplate},</if>
            <if test="createTime != null ">create_time = #{createTime},</if>
            <if test="updateBy != null  and updateBy != ''">update_by = #{updateBy},</if>
            <if test="updateTime != null ">update_time = #{updateTime},</if>
            <if test="invalidTime != null ">invalid_time = #{invalidTime},</if>
            <if test="paramCodes != null ">param_codes = #{paramCodes},</if>
            <if test="status != null  and status != ''">status = #{status},</if>
            <if test="template != null  and template != ''">template = #{template},</if>
            <if test="remark != null  and remark != ''">remark = #{remark},</if>
            <if test="position != null  and position != ''">position = #{position},</if>
            <if test="professionalCategory != null  and professionalCategory != ''">professional_category = #{professionalCategory},</if>
            <if test="superiorPosition != null  and superiorPosition != ''">superior_position = #{superiorPosition},</if>
            <choose>
                <when test="autoSendReport==true">
                    auto_send_report = 1,
                </when>
                <otherwise>
                    auto_send_report = 0,
                </otherwise>
            </choose>
            <if test="reportTemplateId != null  and reportTemplateId != ''">report_template_id = #{reportTemplateId},</if>
        </trim>
        where id = #{id}
    </update>
 
    <delete id="deleteEntTestPackageById" parameterType="Long">
        delete from ent_test_package where id = #{id}
    </delete>
 
    <delete id="deleteEntTestPackageByIds" parameterType="String">
        delete from ent_test_package where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
    
</mapper>