<?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.hzya.frame.sysnew.person.dao.impl.SysPersonDaoImpl">

    <resultMap id="get-SysPersonEntity-result" type="com.hzya.frame.sysnew.person.entity.SysPersonEntity">
        <result property="id" column="id" jdbcType="VARCHAR"/>
        <result property="organId" column="organ_id" jdbcType="VARCHAR"/>
        <result property="organName" column="organ_name" jdbcType="VARCHAR"/>
        <result property="personCode" column="person_code" jdbcType="VARCHAR"/>
        <result property="personName" column="person_name" jdbcType="VARCHAR"/>
        <result property="sex" column="sex" jdbcType="VARCHAR"/>
        <result property="mobilePhone" column="mobile_phone" jdbcType="VARCHAR"/>
        <result property="entryTime" column="entry_time" jdbcType="TIMESTAMP"/>
        <result property="email" column="email" jdbcType="VARCHAR"/>
        <result property="degreeId" column="degree_id" jdbcType="VARCHAR"/>
        <result property="postId" column="post_id" jdbcType="VARCHAR"/>
        <result property="levelId" column="level_id" jdbcType="VARCHAR"/>
        <result property="birthDay" column="birth_day" jdbcType="TIMESTAMP"/>
        <result property="telPhone" column="tel_phone" jdbcType="VARCHAR"/>
        <result property="hometown" column="hometown" jdbcType="VARCHAR"/>
        <result property="idCard" column="id_card" jdbcType="VARCHAR"/>
        <result property="address" column="address" jdbcType="VARCHAR"/>
        <result property="leaveTime" column="leave_time" jdbcType="TIMESTAMP"/>
        <result property="state" column="state" jdbcType="VARCHAR"/>
        <result property="remark" column="remark" jdbcType="VARCHAR"/>
        <result property="ddUserId" column="dd_user_id" jdbcType="VARCHAR"/>
        <result property="wxUserId" column="wx_user_id" jdbcType="VARCHAR"/>
        <result property="headImageId" column="head_image_id" jdbcType="VARCHAR"/>
        <result property="sorts" column="sorts" jdbcType="INTEGER"/>
        <result property="create_user_id" column="create_user_id" jdbcType="VARCHAR"/>
        <result property="create_time" column="create_time" jdbcType="TIMESTAMP"/>
        <result property="modify_user_id" column="modify_user_id" jdbcType="VARCHAR"/>
        <result property="modify_time" column="modify_time" jdbcType="TIMESTAMP"/>
        <result property="sts" column="sts" jdbcType="VARCHAR"/>
        <result property="org_id" column="org_id" jdbcType="VARCHAR"/>
        <result property="companyId" column="company_id" jdbcType="VARCHAR"/>
    </resultMap>
    <!-- 查询的字段-->
    <sql id="SysPersonEntity_Base_Column_List">
        id
       ,organ_id
        ,person_code 
        ,person_name 
        ,sex 
        ,mobile_phone
        ,entry_time 
        ,email 
        ,degree_id 
        ,post_id 
        ,level_id 
        ,birth_day 
        ,tel_phone 
        ,hometown 
        ,id_card 
        ,address 
        ,leave_time 
        ,state 
        ,remark 
        ,dd_user_id 
        ,wx_user_id 
        ,head_image_id 
        ,sorts 
        ,create_user_id 
        ,create_time 
        ,modify_user_id 
        ,modify_time 
        ,sts 
        ,org_id 
        ,company_id 
     </sql>

    <!--通过ID获取数据 -->
    <select id="entity_get" resultMap="get-SysPersonEntity-result">
        select
a.id
        ,a.organ_id
        ,(	SELECT organ_name from sys_organ WHERE sts = 'Y' and  id = a.organ_id )as organ_name

        ,a.person_code
        ,a.person_name
        ,a.sex
        ,a.mobile_phone
        ,a.entry_time
        ,a.email
        ,a.degree_id
        ,a.post_id
        ,a.level_id
        ,a.birth_day
        ,a.tel_phone
        ,a.hometown
        ,a.id_card
        ,a.address
        ,a.leave_time
        ,a.state
        ,a.remark
        ,a.dd_user_id
        ,a.wx_user_id
        ,a.head_image_id
        ,a.sorts
        ,a.create_user_id
        ,a.create_time
        ,a.modify_user_id
        ,a.modify_time
        ,a.sts
        ,a.org_id
        ,a.company_id
        from sys_person a where a.id = #{ id } and a.sts='Y'
    </select>
    <!-- 查询 采用==查询 -->
    <select id="entity_list_base" resultMap="get-SysPersonEntity-result"
            parameterType="com.hzya.frame.sysnew.person.entity.SysPersonEntity">
        select
        <include refid="SysPersonEntity_Base_Column_List"/>
        from sys_person
        <trim prefix="where" prefixOverrides="and">
            <if test="id != null and id != ''">and id = #{id}</if>
            <if test="organId != null and organId != ''">and organ_id = #{organId}</if>
            <if test="personCode != null and personCode != ''">and person_code = #{personCode}</if>
            <if test="personName != null and personName != ''">and person_name = #{personName}</if>
            <if test="sex != null and sex != ''">and sex = #{sex}</if>
            <if test="mobilePhone != null and mobilePhone != ''">and mobile_phone = #{mobilePhone}</if>
            <if test="entryTime != null">and entry_time = #{entryTime}</if>
            <if test="email != null and email != ''">and email = #{email}</if>
            <if test="degreeId != null and degreeId != ''">and degree_id = #{degreeId}</if>
            <if test="postId != null and postId != ''">and post_id = #{postId}</if>
            <if test="levelId != null and levelId != ''">and level_id = #{levelId}</if>
            <if test="birthDay != null">and birth_day = #{birthDay}</if>
            <if test="telPhone != null and telPhone != ''">and tel_phone = #{telPhone}</if>
            <if test="hometown != null and hometown != ''">and hometown = #{hometown}</if>
            <if test="idCard != null and idCard != ''">and id_card = #{idCard}</if>
            <if test="address != null and address != ''">and address = #{address}</if>
            <if test="leaveTime != null">and leave_time = #{leaveTime}</if>
            <if test="state != null and state != ''">and state = #{state}</if>
            <if test="remark != null and remark != ''">and remark = #{remark}</if>
            <if test="ddUserId != null and ddUserId != ''">and dd_user_id = #{ddUserId}</if>
            <if test="wxUserId != null and wxUserId != ''">and wx_user_id = #{wxUserId}</if>
            <if test="headImageId != null and headImageId != ''">and head_image_id = #{headImageId}</if>
            <if test="sorts != null">and sorts = #{sorts}</if>
            <if test="create_user_id != null and create_user_id != ''">and create_user_id = #{create_user_id}</if>
            <if test="create_time != null">and create_time = #{create_time}</if>
            <if test="modify_user_id != null and modify_user_id != ''">and modify_user_id = #{modify_user_id}</if>
            <if test="modify_time != null">and modify_time = #{modify_time}</if>
            <if test="sts != null and sts != ''">and sts = #{sts}</if>
            <if test="org_id != null and org_id != ''">and org_id = #{org_id}</if>
            <if test="companyId != null and companyId != ''">and company_id = #{companyId}</if>
            and sts='Y'
        </trim>
        <if test=" sort == null or sort == ''.toString() ">order by sorts asc</if>
        <if test=" sort !='' and sort!=null and order !='' and order!=null ">order by ${sort} ${order}</if>
    </select>

    <!-- 查询符合条件的数量 -->
    <select id="entity_count" resultType="Integer" parameterType="com.hzya.frame.sysnew.person.entity.SysPersonEntity">
        select count(1) from sys_person
        <trim prefix="where" prefixOverrides="and">
            <if test="id != null and id != ''">and id = #{id}</if>
            <if test="organId != null and organId != ''">and organ_id = #{organId}</if>
            <if test="personCode != null and personCode != ''">and person_code = #{personCode}</if>
            <if test="personName != null and personName != ''">and person_name = #{personName}</if>
            <if test="sex != null and sex != ''">and sex = #{sex}</if>
            <if test="mobilePhone != null and mobilePhone != ''">and mobile_phone = #{mobilePhone}</if>
            <if test="entryTime != null">and entry_time = #{entryTime}</if>
            <if test="email != null and email != ''">and email = #{email}</if>
            <if test="degreeId != null and degreeId != ''">and degree_id = #{degreeId}</if>
            <if test="postId != null and postId != ''">and post_id = #{postId}</if>
            <if test="levelId != null and levelId != ''">and level_id = #{levelId}</if>
            <if test="birthDay != null">and birth_day = #{birthDay}</if>
            <if test="telPhone != null and telPhone != ''">and tel_phone = #{telPhone}</if>
            <if test="hometown != null and hometown != ''">and hometown = #{hometown}</if>
            <if test="idCard != null and idCard != ''">and id_card = #{idCard}</if>
            <if test="address != null and address != ''">and address = #{address}</if>
            <if test="leaveTime != null">and leave_time = #{leaveTime}</if>
            <if test="state != null and state != ''">and state = #{state}</if>
            <if test="remark != null and remark != ''">and remark = #{remark}</if>
            <if test="ddUserId != null and ddUserId != ''">and dd_user_id = #{ddUserId}</if>
            <if test="wxUserId != null and wxUserId != ''">and wx_user_id = #{wxUserId}</if>
            <if test="headImageId != null and headImageId != ''">and head_image_id = #{headImageId}</if>
            <if test="sorts != null">and sorts = #{sorts}</if>
            <if test="create_user_id != null and create_user_id != ''">and create_user_id = #{create_user_id}</if>
            <if test="create_time != null">and create_time = #{create_time}</if>
            <if test="modify_user_id != null and modify_user_id != ''">and modify_user_id = #{modify_user_id}</if>
            <if test="modify_time != null">and modify_time = #{modify_time}</if>
            <if test="sts != null and sts != ''">and sts = #{sts}</if>
            <if test="org_id != null and org_id != ''">and org_id = #{org_id}</if>
            <if test="companyId != null and companyId != ''">and company_id = #{companyId}</if>
            and sts='Y'
        </trim>
    </select>

    <!-- 分页查询列表 采用like格式 -->
    <select id="entity_list_like" resultMap="get-SysPersonEntity-result"
            parameterType="com.hzya.frame.sysnew.person.entity.SysPersonEntity">
        select
        a.id
        ,a.organ_id
        ,(	SELECT organ_name from sys_organ WHERE sts = 'Y' and  id = a.organ_id )as organ_name

        ,a.person_code
        ,a.person_name
        ,a.sex
        ,a.mobile_phone
        ,a.entry_time
        ,a.email
        ,a.degree_id
        ,a.post_id
        ,a.level_id
        ,a.birth_day
        ,a.tel_phone
        ,a.hometown
        ,a.id_card
        ,a.address
        ,a.leave_time
        ,a.state
        ,a.remark
        ,a.dd_user_id
        ,a.wx_user_id
        ,a.head_image_id
        ,a.sorts
        ,a.create_user_id
        ,a.create_time
        ,a.modify_user_id
        ,a.modify_time
        ,a.sts
        ,a.org_id
        ,a.company_id


        from sys_person a
        <trim prefix="where" prefixOverrides="and">
            <if test="id != null and id != ''">and a.id like concat('%',#{id},'%')</if>
            <if test="organId != null and organId != ''">and a.organ_id  =  #{organId}</if>
            <if test="personCode != null and personCode != ''">and a.person_code like concat('%',#{personCode},'%')</if>
            <if test="personName != null and personName != ''">and a.person_name like concat('%',#{personName},'%')</if>
            <if test="sex != null and sex != ''">and a.sex like concat('%',#{sex},'%')</if>
            <if test="mobilePhone != null and mobilePhone != ''">and a.mobile_phone like concat('%',#{mobilePhone},'%')
            </if>
            <if test="entryTime != null">and a.entry_time like concat('%',#{entryTime},'%')</if>
            <if test="email != null and email != ''">and a.email like concat('%',#{email},'%')</if>
            <if test="degreeId != null and degreeId != ''">and a.degree_id like concat('%',#{degreeId},'%')</if>
            <if test="postId != null and postId != ''">and a.post_id like concat('%',#{postId},'%')</if>
            <if test="levelId != null and levelId != ''">and a.level_id like concat('%',#{levelId},'%')</if>
            <if test="birthDay != null">and a.birth_day like concat('%',#{birthDay},'%')</if>
            <if test="telPhone != null and telPhone != ''">and a.tel_phone like concat('%',#{telPhone},'%')</if>
            <if test="hometown != null and hometown != ''">and a.hometown like concat('%',#{hometown},'%')</if>
            <if test="idCard != null and idCard != ''">and a.id_card like concat('%',#{idCard},'%')</if>
            <if test="address != null and address != ''">and a.address like concat('%',#{address},'%')</if>
            <if test="leaveTime != null">and a.leave_time like concat('%',#{leaveTime},'%')</if>
            <if test="state != null and state != ''">and a.state like concat('%',#{state},'%')</if>
            <if test="remark != null and remark != ''">and a.remark like concat('%',#{remark},'%')</if>
            <if test="ddUserId != null and ddUserId != ''">and a.dd_user_id like concat('%',#{ddUserId},'%')</if>
            <if test="wxUserId != null and wxUserId != ''">and a.wx_user_id like concat('%',#{wxUserId},'%')</if>
            <if test="headImageId != null and headImageId != ''">and a.head_image_id like concat('%',#{headImageId},'%')
            </if>
            <if test="sorts != null">and a.sorts like concat('%',#{sorts},'%')</if>
            <if test="create_user_id != null and create_user_id != ''">and a.create_user_id like
                concat('%',#{create_user_id},'%')
            </if>
            <if test="create_time != null">and a.create_time like concat('%',#{create_time},'%')</if>
            <if test="modify_user_id != null and modify_user_id != ''">and a.modify_user_id like
                concat('%',#{modify_user_id},'%')
            </if>
            <if test="modify_time != null">and a.modify_time like concat('%',#{modify_time},'%')</if>
            <if test="sts != null and sts != ''">and a.sts like concat('%',#{sts},'%')</if>
            <if test="org_id != null and org_id != ''">and a.org_id like concat('%',#{org_id},'%')</if>
            <if test="companyId != null and companyId != ''">and a.company_id like concat('%',#{companyId},'%')</if>
            and a.sts='Y'
        </trim>
        <if test=" sort == null or sort == ''.toString() ">order by a.sorts asc</if>
        <if test=" sort !='' and sort!=null and order !='' and order!=null ">order by ${sort} ${order}</if>
    </select>

    <!-- 查询列表 字段采用or格式 -->
    <select id="SysPersonentity_list_or" resultMap="get-SysPersonEntity-result"
            parameterType="com.hzya.frame.sysnew.person.entity.SysPersonEntity">
        select
        <include refid="SysPersonEntity_Base_Column_List"/>
        from sys_person
        <trim prefix="where" prefixOverrides="and">
            <if test="id != null and id != ''">or id = #{id}</if>
            <if test="organId != null and organId != ''">or organ_id = #{organId}</if>
            <if test="personCode != null and personCode != ''">or person_code = #{personCode}</if>
            <if test="personName != null and personName != ''">or person_name = #{personName}</if>
            <if test="sex != null and sex != ''">or sex = #{sex}</if>
            <if test="mobilePhone != null and mobilePhone != ''">or mobile_phone = #{mobilePhone}</if>
            <if test="entryTime != null">or entry_time = #{entryTime}</if>
            <if test="email != null and email != ''">or email = #{email}</if>
            <if test="degreeId != null and degreeId != ''">or degree_id = #{degreeId}</if>
            <if test="postId != null and postId != ''">or post_id = #{postId}</if>
            <if test="levelId != null and levelId != ''">or level_id = #{levelId}</if>
            <if test="birthDay != null">or birth_day = #{birthDay}</if>
            <if test="telPhone != null and telPhone != ''">or tel_phone = #{telPhone}</if>
            <if test="hometown != null and hometown != ''">or hometown = #{hometown}</if>
            <if test="idCard != null and idCard != ''">or id_card = #{idCard}</if>
            <if test="address != null and address != ''">or address = #{address}</if>
            <if test="leaveTime != null">or leave_time = #{leaveTime}</if>
            <if test="state != null and state != ''">or state = #{state}</if>
            <if test="remark != null and remark != ''">or remark = #{remark}</if>
            <if test="ddUserId != null and ddUserId != ''">or dd_user_id = #{ddUserId}</if>
            <if test="wxUserId != null and wxUserId != ''">or wx_user_id = #{wxUserId}</if>
            <if test="headImageId != null and headImageId != ''">or head_image_id = #{headImageId}</if>
            <if test="sorts != null">or sorts = #{sorts}</if>
            <if test="create_user_id != null and create_user_id != ''">or create_user_id = #{create_user_id}</if>
            <if test="create_time != null">or create_time = #{create_time}</if>
            <if test="modify_user_id != null and modify_user_id != ''">or modify_user_id = #{modify_user_id}</if>
            <if test="modify_time != null">or modify_time = #{modify_time}</if>
            <if test="sts != null and sts != ''">or sts = #{sts}</if>
            <if test="org_id != null and org_id != ''">or org_id = #{org_id}</if>
            <if test="companyId != null and companyId != ''">or company_id = #{companyId}</if>
            and sts='Y'
        </trim>
        <if test=" sort == null or sort == ''.toString()  ">order by sorts asc</if>
        <if test=" sort !='' and sort!=null and order !='' and order!=null ">order by ${sort} ${order}</if>
    </select>

    <!--新增所有列-->
    <insert id="entity_insert" parameterType="com.hzya.frame.sysnew.person.entity.SysPersonEntity"
            >
        insert into sys_person(
        <trim suffix="" suffixOverrides=",">
            <if test="id != null and id != ''">id ,</if>
            <if test="organId != null and organId != ''">organ_id ,</if>
            <if test="personCode != null and personCode != ''">person_code ,</if>
            <if test="personName != null and personName != ''">person_name ,</if>
            <if test="sex != null and sex != ''">sex ,</if>
            <if test="mobilePhone != null and mobilePhone != ''">mobile_phone ,</if>
            <if test="entryTime != null">entry_time ,</if>
            <if test="email != null and email != ''">email ,</if>
            <if test="degreeId != null and degreeId != ''">degree_id ,</if>
            <if test="postId != null and postId != ''">post_id ,</if>
            <if test="levelId != null and levelId != ''">level_id ,</if>
            <if test="birthDay != null">birth_day ,</if>
            <if test="telPhone != null and telPhone != ''">tel_phone ,</if>
            <if test="hometown != null and hometown != ''">hometown ,</if>
            <if test="idCard != null and idCard != ''">id_card ,</if>
            <if test="address != null and address != ''">address ,</if>
            <if test="leaveTime != null">leave_time ,</if>
            <if test="state != null and state != ''">state ,</if>
            <if test="remark != null and remark != ''">remark ,</if>
            <if test="ddUserId != null and ddUserId != ''">dd_user_id ,</if>
            <if test="wxUserId != null and wxUserId != ''">wx_user_id ,</if>
            <if test="headImageId != null and headImageId != ''">head_image_id ,</if>
            <if test="sorts != null">sorts ,</if>
            <if test="create_user_id != null and create_user_id != ''">create_user_id ,</if>
            <if test="create_time != null">create_time ,</if>
            <if test="modify_user_id != null and modify_user_id != ''">modify_user_id ,</if>
            <if test="modify_time != null">modify_time ,</if>
            <if test="sts != null and sts != ''">sts ,</if>
            <if test="org_id != null and org_id != ''">org_id ,</if>
            <if test="companyId != null and companyId != ''">company_id ,</if>
            <if test="sts == null ">sts,</if>
        </trim>
        )values(
        <trim suffix="" suffixOverrides=",">
            <if test="id != null and id != ''">#{id} ,</if>
            <if test="organId != null and organId != ''">#{organId} ,</if>
            <if test="personCode != null and personCode != ''">#{personCode} ,</if>
            <if test="personName != null and personName != ''">#{personName} ,</if>
            <if test="sex != null and sex != ''">#{sex} ,</if>
            <if test="mobilePhone != null and mobilePhone != ''">#{mobilePhone} ,</if>
            <if test="entryTime != null">#{entryTime} ,</if>
            <if test="email != null and email != ''">#{email} ,</if>
            <if test="degreeId != null and degreeId != ''">#{degreeId} ,</if>
            <if test="postId != null and postId != ''">#{postId} ,</if>
            <if test="levelId != null and levelId != ''">#{levelId} ,</if>
            <if test="birthDay != null">#{birthDay} ,</if>
            <if test="telPhone != null and telPhone != ''">#{telPhone} ,</if>
            <if test="hometown != null and hometown != ''">#{hometown} ,</if>
            <if test="idCard != null and idCard != ''">#{idCard} ,</if>
            <if test="address != null and address != ''">#{address} ,</if>
            <if test="leaveTime != null">#{leaveTime} ,</if>
            <if test="state != null and state != ''">#{state} ,</if>
            <if test="remark != null and remark != ''">#{remark} ,</if>
            <if test="ddUserId != null and ddUserId != ''">#{ddUserId} ,</if>
            <if test="wxUserId != null and wxUserId != ''">#{wxUserId} ,</if>
            <if test="headImageId != null and headImageId != ''">#{headImageId} ,</if>
            <if test="sorts != null">#{sorts} ,</if>
            <if test="create_user_id != null and create_user_id != ''">#{create_user_id} ,</if>
            <if test="create_time != null">#{create_time} ,</if>
            <if test="modify_user_id != null and modify_user_id != ''">#{modify_user_id} ,</if>
            <if test="modify_time != null">#{modify_time} ,</if>
            <if test="sts != null and sts != ''">#{sts} ,</if>
            <if test="org_id != null and org_id != ''">#{org_id} ,</if>
            <if test="companyId != null and companyId != ''">#{companyId} ,</if>
            <if test="sts == null ">'Y',</if>
        </trim>
        )
    </insert>
    <!-- 批量新增 -->
    <insert id="entityInsertBatch"  >
        insert into sys_person(organ_id, person_code, person_name, sex, mobile_phone, entry_time, email, degree_id,
        post_id, level_id, birth_day, tel_phone, hometown, id_card, address, leave_time, state, remark, dd_user_id,
        wx_user_id, head_image_id, sorts, create_user_id, create_time, modify_user_id, modify_time, sts, org_id,
        company_id, sts)
        values
        <foreach collection="entities" item="entity" separator=",">
            (#{entity.organId},#{entity.personCode},#{entity.personName},#{entity.sex},#{entity.mobilePhone},#{entity.entryTime},#{entity.email},#{entity.degreeId},#{entity.postId},#{entity.levelId},#{entity.birthDay},#{entity.telPhone},#{entity.hometown},#{entity.idCard},#{entity.address},#{entity.leaveTime},#{entity.state},#{entity.remark},#{entity.ddUserId},#{entity.wxUserId},#{entity.headImageId},#{entity.sorts},#{entity.create_user_id},#{entity.create_time},#{entity.modify_user_id},#{entity.modify_time},#{entity.sts},#{entity.org_id},#{entity.companyId},
            'Y')
        </foreach>
    </insert>
    <!-- 批量新增或者修改-->
    <insert id="entityInsertOrUpdateBatch"  >
        insert into sys_person(organ_id, person_code, person_name, sex, mobile_phone, entry_time, email, degree_id,
        post_id, level_id, birth_day, tel_phone, hometown, id_card, address, leave_time, state, remark, dd_user_id,
        wx_user_id, head_image_id, sorts, create_user_id, create_time, modify_user_id, modify_time, sts, org_id,
        company_id)
        values
        <foreach collection="entities" item="entity" separator=",">
            (#{entity.organId},#{entity.personCode},#{entity.personName},#{entity.sex},#{entity.mobilePhone},#{entity.entryTime},#{entity.email},#{entity.degreeId},#{entity.postId},#{entity.levelId},#{entity.birthDay},#{entity.telPhone},#{entity.hometown},#{entity.idCard},#{entity.address},#{entity.leaveTime},#{entity.state},#{entity.remark},#{entity.ddUserId},#{entity.wxUserId},#{entity.headImageId},#{entity.sorts},#{entity.create_user_id},#{entity.create_time},#{entity.modify_user_id},#{entity.modify_time},#{entity.sts},#{entity.org_id},#{entity.companyId})
        </foreach>
        on duplicate key update
        organ_id = values(organ_id),
        person_code = values(person_code),
        person_name = values(person_name),
        sex = values(sex),
        mobile_phone = values(mobile_phone),
        entry_time = values(entry_time),
        email = values(email),
        degree_id = values(degree_id),
        post_id = values(post_id),
        level_id = values(level_id),
        birth_day = values(birth_day),
        tel_phone = values(tel_phone),
        hometown = values(hometown),
        id_card = values(id_card),
        address = values(address),
        leave_time = values(leave_time),
        state = values(state),
        remark = values(remark),
        dd_user_id = values(dd_user_id),
        wx_user_id = values(wx_user_id),
        head_image_id = values(head_image_id),
        sorts = values(sorts),
        create_user_id = values(create_user_id),
        create_time = values(create_time),
        modify_user_id = values(modify_user_id),
        modify_time = values(modify_time),
        sts = values(sts),
        org_id = values(org_id),
        company_id = values(company_id)
    </insert>
    <!--通过主键修改方法-->
    <update id="entity_update" parameterType="com.hzya.frame.sysnew.person.entity.SysPersonEntity">
        update sys_person set
        <trim suffix="" suffixOverrides=",">
            <if test="organId != null and organId != ''">organ_id = #{organId},</if>
            <if test="personCode != null and personCode != ''">person_code = #{personCode},</if>
            <if test="personName != null and personName != ''">person_name = #{personName},</if>
            <if test="sex != null and sex != ''">sex = #{sex},</if>
            <if test="mobilePhone != null and mobilePhone != ''">mobile_phone = #{mobilePhone},</if>
            <if test="entryTime != null">entry_time = #{entryTime},</if>
            <if test="email != null and email != ''">email = #{email},</if>
            <if test="degreeId != null and degreeId != ''">degree_id = #{degreeId},</if>
            <if test="postId != null and postId != ''">post_id = #{postId},</if>
            <if test="levelId != null and levelId != ''">level_id = #{levelId},</if>
            <if test="birthDay != null">birth_day = #{birthDay},</if>
            <if test="telPhone != null and telPhone != ''">tel_phone = #{telPhone},</if>
            <if test="hometown != null and hometown != ''">hometown = #{hometown},</if>
            <if test="idCard != null and idCard != ''">id_card = #{idCard},</if>
            <if test="address != null and address != ''">address = #{address},</if>
            <if test="leaveTime != null">leave_time = #{leaveTime},</if>
            <if test="state != null and state != ''">state = #{state},</if>
            <if test="remark != null and remark != ''">remark = #{remark},</if>
            <if test="ddUserId != null and ddUserId != ''">dd_user_id = #{ddUserId},</if>
            <if test="wxUserId != null and wxUserId != ''">wx_user_id = #{wxUserId},</if>
            <if test="headImageId != null and headImageId != ''">head_image_id = #{headImageId},</if>
            <if test="sorts != null">sorts = #{sorts},</if>
            <if test="create_user_id != null and create_user_id != ''">create_user_id = #{create_user_id},</if>
            <if test="create_time != null">create_time = #{create_time},</if>
            <if test="modify_user_id != null and modify_user_id != ''">modify_user_id = #{modify_user_id},</if>
            <if test="modify_time != null">modify_time = #{modify_time},</if>
            <if test="sts != null and sts != ''">sts = #{sts},</if>
            <if test="org_id != null and org_id != ''">org_id = #{org_id},</if>
            <if test="companyId != null and companyId != ''">company_id = #{companyId},</if>
        </trim>
        where id = #{id}
    </update>
    <!-- 逻辑删除 -->
    <update id="entity_logicDelete" parameterType="com.hzya.frame.sysnew.person.entity.SysPersonEntity">
update sys_person  set sts= 'N' ,modify_time = #{modify_time},modify_user_id = #{modify_user_id}
where id = #{id}
</update>
    <!-- 多条件逻辑删除 -->
    <update id="entity_logicDelete_Multi_Condition" parameterType="com.hzya.frame.sysnew.person.entity.SysPersonEntity">
        update sys_person set sts= 'N' ,modify_time = #{modify_time},modify_user_id = #{modify_user_id}
        <trim prefix="where" prefixOverrides="and">
            <if test="id != null and id != ''">and id = #{id}</if>
            <if test="organId != null and organId != ''">and organ_id = #{organId}</if>
            <if test="personCode != null and personCode != ''">and person_code = #{personCode}</if>
            <if test="personName != null and personName != ''">and person_name = #{personName}</if>
            <if test="sex != null and sex != ''">and sex = #{sex}</if>
            <if test="mobilePhone != null and mobilePhone != ''">and mobile_phone = #{mobilePhone}</if>
            <if test="entryTime != null">and entry_time = #{entryTime}</if>
            <if test="email != null and email != ''">and email = #{email}</if>
            <if test="degreeId != null and degreeId != ''">and degree_id = #{degreeId}</if>
            <if test="postId != null and postId != ''">and post_id = #{postId}</if>
            <if test="levelId != null and levelId != ''">and level_id = #{levelId}</if>
            <if test="birthDay != null">and birth_day = #{birthDay}</if>
            <if test="telPhone != null and telPhone != ''">and tel_phone = #{telPhone}</if>
            <if test="hometown != null and hometown != ''">and hometown = #{hometown}</if>
            <if test="idCard != null and idCard != ''">and id_card = #{idCard}</if>
            <if test="address != null and address != ''">and address = #{address}</if>
            <if test="leaveTime != null">and leave_time = #{leaveTime}</if>
            <if test="state != null and state != ''">and state = #{state}</if>
            <if test="remark != null and remark != ''">and remark = #{remark}</if>
            <if test="ddUserId != null and ddUserId != ''">and dd_user_id = #{ddUserId}</if>
            <if test="wxUserId != null and wxUserId != ''">and wx_user_id = #{wxUserId}</if>
            <if test="headImageId != null and headImageId != ''">and head_image_id = #{headImageId}</if>
            <if test="sorts != null">and sorts = #{sorts}</if>
            <if test="sts != null and sts != ''">and sts = #{sts}</if>
            <if test="companyId != null and companyId != ''">and company_id = #{companyId}</if>
            and sts='Y'
        </trim>
    </update>
    <!--通过主键删除-->
    <delete id="entity_delete">
    delete from sys_person where id = #{id}
</delete>

</mapper>

