<?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.sync.mapper.MetaUserinfoAllMapper">
    
    <resultMap type="MetaUserinfoAll" id="MetaUserinfoAllResult">
        <result property="id"    column="Id"    />
        <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="status"    column="Status"    />
        <result property="leavedate"    column="LeaveDate"    />
        <result property="objid1"    column="OBJID_1"    />
        <result property="stext1"    column="STEXT_1"    />
        <result property="objid2"    column="OBJID_2"    />
        <result property="stext2"    column="STEXT_2"    />
        <result property="objid3"    column="OBJID_3"    />
        <result property="stext3"    column="STEXT_3"    />
        <result property="objid4"    column="OBJID_4"    />
        <result property="stext4"    column="STEXT_4"    />
        <result property="objid5"    column="OBJID_5"    />
        <result property="stext5"    column="STEXT_5"    />
        <result property="objid6"    column="OBJID_6"    />
        <result property="poste"    column="POSTE"    />
        <result property="packageId"    column="package_id"    />
        <result property="lineId"    column="line_id"    />
    </resultMap>

    <sql id="selectMetaUserinfoAllVo">
        select Id, Name, LoginName, Email, Mobile, SapEmployeeId, Status, LeaveDate, OBJID_1, STEXT_1, OBJID_2, STEXT_2, OBJID_3, STEXT_3, OBJID_4, STEXT_4, OBJID_5, STEXT_5, OBJID_6, POSTE, package_id, line_id from meta_userinfo_all
    </sql>

    <select id="selectMetaUserinfoAllList" parameterType="MetaUserinfoAll" resultMap="MetaUserinfoAllResult">
        <include refid="selectMetaUserinfoAllVo"/>
        <where>  
            <if test="id != null "> and Id = #{id}</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="status != null "> and Status = #{status}</if>
            <if test="leavedate != null "> and LeaveDate = #{leavedate}</if>
            <if test="objid1 != null  and objid1 != ''"> and OBJID_1 = #{objid1}</if>
            <if test="stext1 != null  and stext1 != ''"> and STEXT_1 = #{stext1}</if>
            <if test="objid2 != null  and objid2 != ''"> and OBJID_2 = #{objid2}</if>
            <if test="stext2 != null  and stext2 != ''"> and STEXT_2 = #{stext2}</if>
            <if test="objid3 != null  and objid3 != ''"> and OBJID_3 = #{objid3}</if>
            <if test="stext3 != null  and stext3 != ''"> and STEXT_3 = #{stext3}</if>
            <if test="objid4 != null  and objid4 != ''"> and OBJID_4 = #{objid4}</if>
            <if test="stext4 != null  and stext4 != ''"> and STEXT_4 = #{stext4}</if>
            <if test="objid5 != null  and objid5 != ''"> and OBJID_5 = #{objid5}</if>
            <if test="stext5 != null  and stext5 != ''"> and STEXT_5 = #{stext5}</if>
            <if test="objid6 != null  and objid6 != ''"> and OBJID_6 = #{objid6}</if>
            <if test="poste != null  and poste != ''"> and POSTE = #{poste}</if>
            <if test="packageId != null  and packageId != ''"> and package_id = #{packageId}</if>
            <if test="lineId != null  and lineId != ''"> and line_id = #{lineId}</if>
        </where>
    </select>
    
    <select id="selectMetaUserinfoAllById" parameterType="Long" resultMap="MetaUserinfoAllResult">
        <include refid="selectMetaUserinfoAllVo"/>
        where Id = #{id}
    </select>
        
    <insert id="insertMetaUserinfoAll" parameterType="MetaUserinfoAll">
        insert into meta_userinfo_all
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null ">Id,</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="status != null ">Status,</if>
            <if test="leavedate != null ">LeaveDate,</if>
            <if test="objid1 != null  and objid1 != ''">OBJID_1,</if>
            <if test="stext1 != null  and stext1 != ''">STEXT_1,</if>
            <if test="objid2 != null  and objid2 != ''">OBJID_2,</if>
            <if test="stext2 != null  and stext2 != ''">STEXT_2,</if>
            <if test="objid3 != null  and objid3 != ''">OBJID_3,</if>
            <if test="stext3 != null  and stext3 != ''">STEXT_3,</if>
            <if test="objid4 != null  and objid4 != ''">OBJID_4,</if>
            <if test="stext4 != null  and stext4 != ''">STEXT_4,</if>
            <if test="objid5 != null  and objid5 != ''">OBJID_5,</if>
            <if test="stext5 != null  and stext5 != ''">STEXT_5,</if>
            <if test="objid6 != null  and objid6 != ''">OBJID_6,</if>
            <if test="poste != null  and poste != ''">POSTE,</if>
            <if test="packageId != null  and packageId != ''">package_id,</if>
            <if test="lineId != null  and lineId != ''">line_id,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null ">#{id},</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="status != null ">#{status},</if>
            <if test="leavedate != null ">#{leavedate},</if>
            <if test="objid1 != null  and objid1 != ''">#{objid1},</if>
            <if test="stext1 != null  and stext1 != ''">#{stext1},</if>
            <if test="objid2 != null  and objid2 != ''">#{objid2},</if>
            <if test="stext2 != null  and stext2 != ''">#{stext2},</if>
            <if test="objid3 != null  and objid3 != ''">#{objid3},</if>
            <if test="stext3 != null  and stext3 != ''">#{stext3},</if>
            <if test="objid4 != null  and objid4 != ''">#{objid4},</if>
            <if test="stext4 != null  and stext4 != ''">#{stext4},</if>
            <if test="objid5 != null  and objid5 != ''">#{objid5},</if>
            <if test="stext5 != null  and stext5 != ''">#{stext5},</if>
            <if test="objid6 != null  and objid6 != ''">#{objid6},</if>
            <if test="poste != null  and poste != ''">#{poste},</if>
            <if test="packageId != null  and packageId != ''">#{packageId},</if>
            <if test="lineId != null  and lineId != ''">#{lineId},</if>
         </trim>
    </insert>

    <update id="updateMetaUserinfoAll" parameterType="MetaUserinfoAll">
        update meta_userinfo_all
        <trim prefix="SET" suffixOverrides=",">
            <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="status != null ">Status = #{status},</if>
            <if test="leavedate != null ">LeaveDate = #{leavedate},</if>
            <if test="objid1 != null  and objid1 != ''">OBJID_1 = #{objid1},</if>
            <if test="stext1 != null  and stext1 != ''">STEXT_1 = #{stext1},</if>
            <if test="objid2 != null  and objid2 != ''">OBJID_2 = #{objid2},</if>
            <if test="stext2 != null  and stext2 != ''">STEXT_2 = #{stext2},</if>
            <if test="objid3 != null  and objid3 != ''">OBJID_3 = #{objid3},</if>
            <if test="stext3 != null  and stext3 != ''">STEXT_3 = #{stext3},</if>
            <if test="objid4 != null  and objid4 != ''">OBJID_4 = #{objid4},</if>
            <if test="stext4 != null  and stext4 != ''">STEXT_4 = #{stext4},</if>
            <if test="objid5 != null  and objid5 != ''">OBJID_5 = #{objid5},</if>
            <if test="stext5 != null  and stext5 != ''">STEXT_5 = #{stext5},</if>
            <if test="objid6 != null  and objid6 != ''">OBJID_6 = #{objid6},</if>
            <if test="poste != null  and poste != ''">POSTE = #{poste},</if>
            <if test="packageId != null  and packageId != ''">package_id = #{packageId},</if>
            <if test="lineId != null  and lineId != ''">line_id = #{lineId},</if>
        </trim>
        where Id = #{id}
    </update>

    <delete id="deleteMetaUserinfoAllById" parameterType="Long">
        delete from meta_userinfo_all where Id = #{id}
    </delete>

    <delete id="deleteMetaUserinfoAllByIds" parameterType="String">
        delete from meta_userinfo_all where Id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
    
</mapper>