LeaveApplicationMapper.xml
5.39 KB
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
<?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.trash.office.mapper.LeaveApplicationMapper">
<resultMap type="LeaveApplication" id="LeaveApplicationResult">
<result property="id" column="id" />
<result property="applicant" column="applicant" />
<result property="deptId" column="dept_Id" />
<result property="deptName" column="dept_name" />
<result property="positionId" column="position_id" />
<result property="phone" column="phone" />
<result property="type" column="type" />
<result property="beginDate" column="begin_date" />
<result property="endDate" column="end_date" />
<result property="numberDays" column="number_days" />
<result property="content" column="content" />
<result property="status" column="status" />
<result property="createTime" column="create_time" />
<result property="createBy" column="create_by" />
<result property="updateTime" column="update_time" />
<result property="updateBy" column="update_by" />
</resultMap>
<sql id="selectLeaveApplicationVo">
select id, applicant, dept_Id,dept_name, position_id, phone, type, begin_date, end_date, number_days, content, status, create_time, create_by, update_time, update_by from office_leave_application
</sql>
<select id="selectLeaveApplicationList" parameterType="LeaveApplication" resultMap="LeaveApplicationResult">
<include refid="selectLeaveApplicationVo"/>
<where>
<if test="applicant != null and applicant != ''"> and applicant like concat('%', #{applicant}, '%')</if>
<if test="deptName != null "> and dept_name = #{deptName}</if>
<if test="positionId != null "> and position_id = #{positionId}</if>
<if test="type != null and type != ''"> and type = #{type}</if>
</where>
</select>
<select id="selectLeaveApplicationById" parameterType="Long" resultMap="LeaveApplicationResult">
<include refid="selectLeaveApplicationVo"/>
where id = #{id}
</select>
<insert id="insertLeaveApplication" parameterType="LeaveApplication" useGeneratedKeys="true" keyProperty="id">
insert into office_leave_application
<trim prefix="(" suffix=")" suffixOverrides=",">
create_time,
<if test="applicant != null">applicant,</if>
<if test="deptId != null">dept_Id,</if>
<if test="deptName != null">dept_name,</if>
<if test="positionId != null">position_id,</if>
<if test="phone != null">phone,</if>
<if test="type != null">type,</if>
<if test="beginDate != null">begin_date,</if>
<if test="endDate != null">end_date,</if>
<if test="numberDays != null">number_days,</if>
<if test="content != null">content,</if>
<if test="status != null">status,</if>
<if test="createBy != null">create_by,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
now(),
<if test="applicant != null">#{applicant},</if>
<if test="deptId != null">#{deptId},</if>
<if test="deptName != null">#{deptName},</if>
<if test="positionId != null">#{positionId},</if>
<if test="phone != null">#{phone},</if>
<if test="type != null">#{type},</if>
<if test="beginDate != null">#{beginDate},</if>
<if test="endDate != null">#{endDate},</if>
<if test="numberDays != null">#{numberDays},</if>
<if test="content != null">#{content},</if>
<if test="status != null">#{status},</if>
<if test="createBy != null">#{createBy},</if>
</trim>
</insert>
<update id="updateLeaveApplication" parameterType="LeaveApplication">
update office_leave_application
<trim prefix="SET" suffixOverrides=",">
update_time = now(),
<if test="applicant != null">applicant = #{applicant},</if>
<if test="deptId != null">dept_Id = #{deptId},</if>
<if test="deptName != null">dept_name = #{deptName},</if>
<if test="positionId != null">position_id = #{positionId},</if>
<if test="phone != null">phone = #{phone},</if>
<if test="type != null">type = #{type},</if>
<if test="beginDate != null">begin_date = #{beginDate},</if>
<if test="endDate != null">end_date = #{endDate},</if>
<if test="numberDays != null">number_days = #{numberDays},</if>
<if test="content != null">content = #{content},</if>
<if test="status != null">status = #{status},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteLeaveApplicationById" parameterType="Long">
delete from office_leave_application where id = #{id}
</delete>
<delete id="deleteLeaveApplicationByIds" parameterType="String">
delete from office_leave_application where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>