xiangpei
2024-11-22 c8bc73954b11b40cc62945099a4f7ca1a73154a1
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
<?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.ycl.mapper.LeaveapplyMapper">
 
    <resultMap type="Leaveapply" id="LeaveapplyResult">
        <result property="id"    column="id"    />
        <result property="userId"    column="user_id"    />
        <result property="startTime"    column="start_time"    />
        <result property="endTime"    column="end_time"    />
        <result property="leaveType"    column="leave_type"    />
        <result property="reason"    column="reason"    />
        <result property="applyTime"    column="apply_time"    />
        <result property="realityStartTime"    column="reality_start_time"    />
        <result property="realityEndTime"    column="reality_end_time"    />
    </resultMap>
 
    <sql id="selectLeaveapplyVo">
        select id, user_id, start_time, end_time, leave_type, reason, apply_time, reality_start_time, reality_end_time from leaveapply
    </sql>
 
    <select id="selectLeaveapplyList" parameterType="Leaveapply" resultMap="LeaveapplyResult">
        <include refid="selectLeaveapplyVo"/>
        <where>
            <if test="leaveType != null  and leaveType != ''"> and leave_type = #{leaveType}</if>
            <if test="params.beginApplyTime != null and params.beginApplyTime != '' and params.endApplyTime != null and params.endApplyTime != ''"> and apply_time between #{params.beginApplyTime} and #{params.endApplyTime}</if>
            <if test="userId != null  and userId != ''"> and user_id = #{userId}</if>
        </where>
    </select>
 
    <select id="selectLeaveapplyById" parameterType="Long" resultMap="LeaveapplyResult">
        <include refid="selectLeaveapplyVo"/>
        where id = #{id}
    </select>
 
    <insert id="insertLeaveapply" parameterType="Leaveapply" useGeneratedKeys="true" keyProperty="id">
        insert into leaveapply
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="userId != null">user_id,</if>
            <if test="startTime != null">start_time,</if>
            <if test="endTime != null">end_time,</if>
            <if test="leaveType != null">leave_type,</if>
            <if test="reason != null">reason,</if>
            <if test="applyTime != null">apply_time,</if>
            <if test="realityStartTime != null">reality_start_time,</if>
            <if test="realityEndTime != null">reality_end_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="userId != null">#{userId},</if>
            <if test="startTime != null">#{startTime},</if>
            <if test="endTime != null">#{endTime},</if>
            <if test="leaveType != null">#{leaveType},</if>
            <if test="reason != null">#{reason},</if>
            <if test="applyTime != null">#{applyTime},</if>
            <if test="realityStartTime != null">#{realityStartTime},</if>
            <if test="realityEndTime != null">#{realityEndTime},</if>
         </trim>
    </insert>
 
    <update id="updateLeaveapply" parameterType="Leaveapply">
        update leaveapply
        <trim prefix="SET" suffixOverrides=",">
            <if test="userId != null">user_id = #{userId},</if>
            <if test="startTime != null">start_time = #{startTime},</if>
            <if test="endTime != null">end_time = #{endTime},</if>
            <if test="leaveType != null">leave_type = #{leaveType},</if>
            <if test="reason != null">reason = #{reason},</if>
            <if test="applyTime != null">apply_time = #{applyTime},</if>
            <if test="realityStartTime != null">reality_start_time = #{realityStartTime},</if>
            <if test="realityEndTime != null">reality_end_time = #{realityEndTime},</if>
        </trim>
        where id = #{id}
    </update>
 
    <delete id="deleteLeaveapplyById" parameterType="Long">
        delete from leaveapply where id = #{id}
    </delete>
 
    <delete id="deleteLeaveapplyByIds" parameterType="String">
        delete from leaveapply where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
 
</mapper>