<?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.dgtly.system.mapper.SysUserQuitMapper">
    
    <resultMap type="SysUserQuit" id="SysUserQuitResult">
        <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="isDelete"    column="is_delete"    />
        <result property="name"    column="Name"    />
        <result property="loginname"    column="LoginName"    />
        <result property="email"    column="Email"    />
        <result property="mobile"    column="Mobile"    />
        <result property="sapemployeeid"    column="SapEmployeeId"    />
        <result property="sapcostcentercode"    column="SapCostCenterCode"    />
        <result property="sapcostcenter"    column="SapCostCenter"    />
        <result property="sapcompanycode"    column="SapCompanyCode"    />
        <result property="sapcompanyname"    column="SapCompanyName"    />
        <result property="status"    column="Status"    />
        <result property="leavedate"    column="LeaveDate"    />
    </resultMap>

    <sql id="selectSysUserQuitVo">
        select create_by, create_time, update_by, update_time, is_delete, Name, LoginName, Email, Mobile, SapEmployeeId, SapCostCenterCode, SapCostCenter, SapCompanyCode, SapCompanyName, Status, LeaveDate from sys_user_quit
    </sql>

    <select id="selectSysUserQuitList" parameterType="SysUserQuit" resultMap="SysUserQuitResult">
        <include refid="selectSysUserQuitVo"/>
        <where>  
            <if test="isDelete != null "> and is_delete = #{isDelete}</if>
            <if test="name != null  and name != ''"> and Name like concat('%', #{name}, '%')</if>
            <if test="loginname != null  and loginname != ''"> and LoginName like concat('%', #{loginname}, '%')</if>
            <if test="email != null  and email != ''"> and Email = #{email}</if>
            <if test="mobile != null  and mobile != ''"> and Mobile = #{mobile}</if>
            <if test="sapemployeeid != null  and sapemployeeid != ''"> and SapEmployeeId = #{sapemployeeid}</if>
            <if test="sapcostcentercode != null  and sapcostcentercode != ''"> and SapCostCenterCode = #{sapcostcentercode}</if>
            <if test="sapcostcenter != null  and sapcostcenter != ''"> and SapCostCenter = #{sapcostcenter}</if>
            <if test="sapcompanycode != null  and sapcompanycode != ''"> and SapCompanyCode = #{sapcompanycode}</if>
            <if test="sapcompanyname != null  and sapcompanyname != ''"> and SapCompanyName like concat('%', #{sapcompanyname}, '%')</if>
            <if test="status != null  and status != ''"> and Status = #{status}</if>
            <if test="leavedate != null  and leavedate != ''"> and LeaveDate = #{leavedate}</if>
        </where>
    </select>
    
    <select id="selectSysUserQuitById" parameterType="String" resultMap="SysUserQuitResult">
        <include refid="selectSysUserQuitVo"/>
        where create_by = #{createBy}
    </select>
        
    <insert id="insertSysUserQuit" parameterType="SysUserQuit">
        insert into sys_user_quit
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <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="updateTime != null ">update_time,</if>
            <if test="isDelete != null ">is_delete,</if>
            <if test="name != null  and name != ''">Name,</if>
            <if test="loginname != null  and loginname != ''">LoginName,</if>
            <if test="email != null  and email != ''">Email,</if>
            <if test="mobile != null  and mobile != ''">Mobile,</if>
            <if test="sapemployeeid != null  and sapemployeeid != ''">SapEmployeeId,</if>
            <if test="sapcostcentercode != null  and sapcostcentercode != ''">SapCostCenterCode,</if>
            <if test="sapcostcenter != null  and sapcostcenter != ''">SapCostCenter,</if>
            <if test="sapcompanycode != null  and sapcompanycode != ''">SapCompanyCode,</if>
            <if test="sapcompanyname != null  and sapcompanyname != ''">SapCompanyName,</if>
            <if test="status != null  and status != ''">Status,</if>
            <if test="leavedate != null  and leavedate != ''">LeaveDate,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="createBy != null  and createBy != ''">#{createBy},</if>
            <if test="createTime != null ">#{createTime},</if>
            <if test="updateBy != null  and updateBy != ''">#{updateBy},</if>
            <if test="updateTime != null ">#{updateTime},</if>
            <if test="isDelete != null ">#{isDelete},</if>
            <if test="name != null  and name != ''">#{name},</if>
            <if test="loginname != null  and loginname != ''">#{loginname},</if>
            <if test="email != null  and email != ''">#{email},</if>
            <if test="mobile != null  and mobile != ''">#{mobile},</if>
            <if test="sapemployeeid != null  and sapemployeeid != ''">#{sapemployeeid},</if>
            <if test="sapcostcentercode != null  and sapcostcentercode != ''">#{sapcostcentercode},</if>
            <if test="sapcostcenter != null  and sapcostcenter != ''">#{sapcostcenter},</if>
            <if test="sapcompanycode != null  and sapcompanycode != ''">#{sapcompanycode},</if>
            <if test="sapcompanyname != null  and sapcompanyname != ''">#{sapcompanyname},</if>
            <if test="status != null  and status != ''">#{status},</if>
            <if test="leavedate != null  and leavedate != ''">#{leavedate},</if>
         </trim>
    </insert>

    <update id="updateSysUserQuit" parameterType="SysUserQuit">
        update sys_user_quit
        <trim prefix="SET" suffixOverrides=",">
            <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="isDelete != null ">is_delete = #{isDelete},</if>
            <if test="name != null  and name != ''">Name = #{name},</if>
            <if test="loginname != null  and loginname != ''">LoginName = #{loginname},</if>
            <if test="email != null  and email != ''">Email = #{email},</if>
            <if test="mobile != null  and mobile != ''">Mobile = #{mobile},</if>
            <if test="sapemployeeid != null  and sapemployeeid != ''">SapEmployeeId = #{sapemployeeid},</if>
            <if test="sapcostcentercode != null  and sapcostcentercode != ''">SapCostCenterCode = #{sapcostcentercode},</if>
            <if test="sapcostcenter != null  and sapcostcenter != ''">SapCostCenter = #{sapcostcenter},</if>
            <if test="sapcompanycode != null  and sapcompanycode != ''">SapCompanyCode = #{sapcompanycode},</if>
            <if test="sapcompanyname != null  and sapcompanyname != ''">SapCompanyName = #{sapcompanyname},</if>
            <if test="status != null  and status != ''">Status = #{status},</if>
            <if test="leavedate != null  and leavedate != ''">LeaveDate = #{leavedate},</if>
        </trim>
        where create_by = #{createBy}
    </update>

    <delete id="deleteSysUserQuitById" parameterType="String">
        delete from sys_user_quit where create_by = #{createBy}
    </delete>

    <delete id="deleteSysUserQuitByIds" parameterType="String">
        delete from sys_user_quit where create_by in 
        <foreach item="createBy" collection="array" open="(" separator="," close=")">
            #{createBy}
        </foreach>
    </delete>

    <select id="selectAllUserSapEmployeeId"  resultType="java.lang.String">
        select u.SapEmployeeId
        from sys_user_quit u
    </select>

</mapper>