LeaveApplicationMapper.xml 5.39 KB
<?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>