<?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">
<!-- 不使用namespace的话sql搜索定位会比较方便 -->
<mapper namespace="com.blueland.dao.TucStaffDao">
    <resultMap id="RM_TucStaffEntity"
               type="com.blueland.bo.TucStaffEntity">
        <result property="staffId" column="staff_id"/>
        <result property="staffName" column="staff_name"/>
        <result property="staffEnName" column="staff_en_name"/>
        <result property="orgId" column="org_id"/>
        <result property="orgName" column="org_name"/>
        <result property="staffSpells" column="staff_spells"/>
        <result property="staffShortSpells" column="staff_short_spells"/>
        <result property="staffNum" column="staff_num"/>
        <result property="staffShortNum" column="staff_short_num"/>
        <result property="positionId" column="position_id"/>
        <result property="positionName" column="position_name"/>
        <result property="staffSex" column="staff_sex"/>
        <result property="staffAge" column="staff_age"/>
        <result property="staffPaperworkType"
                column="staff_paperwork_type"/>
        <result property="staffPaperworkNum"
                column="staff_paperwork_num"/>
        <result property="staffMail" column="staff_mail"/>
        <result property="staffMobile" column="staff_mobile"/>
        <result property="staffMobileBak" column="staff_mobile_bak"/>
        <result property="staffFax" column="staff_fax"/>
        <result property="staffShortFax" column="staff_short_fax"/>
        <result property="staffWechart" column="staff_wechart"/>
        <result property="staffHomeAddress" column="staff_home_address"/>
        <result property="staffHomePhone" column="staff_home_phone"/>
        <result property="staffWorkAddress" column="staff_work_address"/>
        <result property="staffWorkPhone" column="staff_work_phone"/>
        <result property="staffPassport" column="staff_passport"/>
        <result property="staffNation" column="staff_nation"/>
        <result property="staffPoliticalStatus"
                column="staff_political_status"/>
        <result property="staffNativePlace" column="staff_native_place"/>
        <result property="staffSort" column="staff_sort"/>
        <result property="staffStatus" column="staff_status"/>
        <result property="staffType" column="staff_type"/>
        <result property="staffSubType" column="staff_sub_type"/>
        <result property="staffCreator" column="staff_creator"/>
        <result property="staffCreateTime" column="staff_create_time"/>
        <result property="staffUpdator" column="staff_updator"/>
        <result property="staffLastupdateTime"
                column="staff_lastupdate_time"/>
        <result property="staffWorkType" column="staff_work_type"/>
        <result property="companyId" column="company_id"/>
        <result property="companyName" column="company_name"/>
        <result property="deptId" column="dept_id"/>
        <result property="deptName" column="dept_name"/>
        <result property="staffHrId" column="staff_hr_id"/>
        <result property="staffCode" column="staff_code"/>
        <result property="staffBirthday" column="staff_birthday"/>
        <result property="staffEducation" column="staff_education"/>
        <result property="staffRetiredTime" column="staff_retired_time"/>
        <result property="staffJobStatus" column="staff_job_status"/>
        <result property="staffAccountType" column="staff_account_type"/>
        <result property="staffPhoneBak" column="staff_phone_bak"/>
        <result property="staffPostCode" column="staff_post_code"/>
        <result property="staffPostType" column="staff_post_type"/>
        <result property="appId" column="app_id"/>
    </resultMap>

    <sql id="TucStaffEntityColumns">
        staff_id,
        staff_name,
        staff_en_name,
        org_id,
        org_name,
        staff_spells,
        staff_short_spells,
        staff_num,
        staff_short_num,
        position_id,
        position_name,
        staff_sex,
        staff_age,
        staff_paperwork_type,
        staff_paperwork_num,
        staff_mail,
        staff_mobile,
        staff_mobile_bak,
        staff_fax,
        staff_short_fax,
        staff_wechart,
        staff_home_address,
        staff_home_phone,
        staff_work_address,
        staff_work_phone,
        staff_passport,
        staff_nation,
        staff_political_status,
        staff_native_place,
        staff_sort,
        staff_status,
        staff_type,
        staff_sub_type,
        staff_creator,
        staff_create_time,
        staff_updator,
        staff_lastupdate_time,
        staff_work_type,
        company_id,
        company_name,
        dept_id,
        dept_name,
        staff_hr_id,
        staff_code,
        staff_birthday,
        staff_education,
        staff_retired_time,
        staff_job_status,
        staff_account_type,
        staff_phone_bak,
        staff_post_code,
        staff_post_type,
        app_id
    </sql>

    <sql id="TucStaffEntityQueryColumns">
        staff_id,
        staff_name,
        staff_en_name,
        org_id,
        org_name,
        staff_spells,
        staff_short_spells,
        staff_num,
        staff_short_num,
        position_id,
        position_name,
        staff_sex,
        staff_age,
        staff_paperwork_type,
        staff_paperwork_num,
        staff_mail,
        staff_mobile,
        staff_mobile_bak,
        staff_fax,
        staff_short_fax,
        staff_wechart,
        staff_home_address,
        staff_home_phone,
        staff_work_address,
        staff_work_phone,
        staff_passport,
        staff_nation,
        staff_political_status,
        staff_native_place,
        staff_sort,
        staff_status,
        staff_type,
        staff_sub_type,
        staff_creator,
        staff_create_time,
        staff_updator,
        staff_lastupdate_time,
        staff_work_type,
        company_id,
        company_name,
        dept_id,
        dept_name,
        staff_hr_id,
        staff_code,
        staff_birthday,
        staff_education,
        staff_retired_time,
        staff_job_status,
        staff_account_type,
        staff_phone_bak,
        staff_post_code,
        staff_post_type,
        app_id
    </sql>
    <!-- useGeneratedKeys="true" keyProperty="xxx" for sqlserver and mysql -->
    <insert id="insert" useGeneratedKeys="false"
            keyProperty="staffId">
        INSERT INTO t_uc_staff (
        <include refid="TucStaffEntityColumns"/>
        )
                VALUES (#{staffId,jdbcType=VARCHAR},
                        #{staffName,jdbcType=VARCHAR},
                        #{staffEnName,jdbcType=VARCHAR},
                        #{orgId,jdbcType=VARCHAR},
                        #{orgName,jdbcType=VARCHAR},
                        #{staffSpells,jdbcType=VARCHAR},
                        #{staffShortSpells,jdbcType=VARCHAR},
                        #{staffNum,jdbcType=VARCHAR},
                        #{staffShortNum,jdbcType=VARCHAR},
                        #{positionId,jdbcType=VARCHAR},
                        #{positionName,jdbcType=VARCHAR},
                        #{staffSex,jdbcType=VARCHAR},
                        #{staffAge,jdbcType=INTEGER},
                        #{staffPaperworkType,jdbcType=VARCHAR},
                        #{staffPaperworkNum,jdbcType=VARCHAR},
                        #{staffMail,jdbcType=VARCHAR},
                        #{staffMobile,jdbcType=VARCHAR},
                        #{staffMobileBak,jdbcType=VARCHAR},
                        #{staffFax,jdbcType=VARCHAR},
                        #{staffShortFax,jdbcType=VARCHAR},
                        #{staffWechart,jdbcType=VARCHAR},
                        #{staffHomeAddress,jdbcType=VARCHAR},
                        #{staffHomePhone,jdbcType=VARCHAR},
                        #{staffWorkAddress,jdbcType=VARCHAR},
                        #{staffWorkPhone,jdbcType=VARCHAR},
                        #{staffPassport,jdbcType=VARCHAR},
                        #{staffNation,jdbcType=VARCHAR},
                        #{staffPoliticalStatus,jdbcType=VARCHAR},
                        #{staffNativePlace,jdbcType=VARCHAR},
                        #{staffSort,jdbcType=INTEGER},
                        #{staffStatus,jdbcType=VARCHAR},
                        #{staffType,jdbcType=VARCHAR},
                        #{staffSubType,jdbcType=VARCHAR},
                        #{staffCreator,jdbcType=VARCHAR},
                        #{staffCreateTime,jdbcType=TIMESTAMP},
                        #{staffUpdator,jdbcType=VARCHAR},
                        #{staffLastupdateTime,jdbcType=TIMESTAMP},
                        #{staffWorkType,jdbcType=VARCHAR},
                        #{companyId,jdbcType=VARCHAR},
                        #{companyName,jdbcType=VARCHAR},
                        #{deptId,jdbcType=VARCHAR},
                        #{deptName,jdbcType=VARCHAR},
                        #{staffHrId,jdbcType=VARCHAR},
                        #{staffCode,jdbcType=VARCHAR},
                        #{staffBirthday,jdbcType=TIMESTAMP},
                        #{staffEducation,jdbcType=VARCHAR},
                        #{staffRetiredTime,jdbcType=TIMESTAMP},
                        #{staffJobStatus,jdbcType=VARCHAR},
                        #{staffAccountType,jdbcType=VARCHAR},
                        #{staffPhoneBak,jdbcType=VARCHAR},
                        #{staffPostCode,jdbcType=VARCHAR},
                        #{staffPostType,jdbcType=VARCHAR},
                        #{appId,jdbcType=VARCHAR})
    </insert>

    <update id="updateByCode">
        UPDATE t_uc_staff
        <set>
            <if test="@Ognl@isNotEmpty(staffName)">
                staff_name = #{staffName,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(staffEnName)">
                staff_en_name = #{staffEnName,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(orgId)">
                org_id = #{orgId,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(orgName)">
                org_name = #{orgName,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(staffSpells)">
                staff_spells = #{staffSpells,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(staffShortSpells)">
                staff_short_spells =
                        #{staffShortSpells,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(staffNum)">
                staff_num = #{staffNum,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(staffShortNum)">
                staff_short_num = #{staffShortNum,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(positionId)">
                position_id = #{positionId,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(positionName)">
                position_name = #{positionName,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(staffSex)">
                staff_sex = #{staffSex,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(staffAge)">
                staff_age = #{staffAge,jdbcType=INTEGER},
            </if>
            <if test="@Ognl@isNotEmpty(staffPaperworkType)">
                staff_paperwork_type =
                        #{staffPaperworkType,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(staffPaperworkNum)">
                staff_paperwork_num =
                        #{staffPaperworkNum,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(staffMail)">
                staff_mail = #{staffMail,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(staffMobile)">
                staff_mobile = #{staffMobile,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(staffMobileBak)">
                staff_mobile_bak = #{staffMobileBak,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(staffFax)">
                staff_fax = #{staffFax,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(staffShortFax)">
                staff_short_fax = #{staffShortFax,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(staffWechart)">
                staff_wechart = #{staffWechart,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(staffHomeAddress)">
                staff_home_address =
                        #{staffHomeAddress,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(staffHomePhone)">
                staff_home_phone = #{staffHomePhone,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(staffWorkAddress)">
                staff_work_address =
                        #{staffWorkAddress,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(staffWorkPhone)">
                staff_work_phone = #{staffWorkPhone,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(staffPassport)">
                staff_passport = #{staffPassport,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(staffNation)">
                staff_nation = #{staffNation,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(staffPoliticalStatus)">
                staff_political_status =
                        #{staffPoliticalStatus,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(staffNativePlace)">
                staff_native_place =
                        #{staffNativePlace,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(staffSort)">
                staff_sort = #{staffSort,jdbcType=INTEGER},
            </if>
            <if test="@Ognl@isNotEmpty(staffStatus)">
                staff_status = #{staffStatus,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(staffType)">
                staff_type = #{staffType,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(staffSubType)">
                staff_sub_type = #{staffSubType,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(staffCreator)">
                staff_creator = #{staffCreator,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(staffCreateTime)">
                staff_create_time =
                        #{staffCreateTime,jdbcType=TIMESTAMP},
            </if>
            <if test="@Ognl@isNotEmpty(staffUpdator)">
                staff_updator = #{staffUpdator,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(staffLastupdateTime)">
                staff_lastupdate_time =
                        #{staffLastupdateTime,jdbcType=TIMESTAMP},
            </if>
            <if test="@Ognl@isNotEmpty(staffWorkType)">
                staff_work_type = #{staffWorkType,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(companyId)">
                company_id = #{companyId,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(companyName)">
                company_name = #{companyName,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(deptId)">
                dept_id = #{deptId,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(deptName)">
                dept_name = #{deptName,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(staffHrId)">
                staff_hr_id = #{staffHrId,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(staffCode)">
                staff_code = #{staffCode,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(staffBirthday)">
                staff_birthday = #{staffBirthday,jdbcType=TIMESTAMP},
            </if>
            <if test="@Ognl@isNotEmpty(staffEducation)">
                staff_education = #{staffEducation,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(staffRetiredTime)">
                staff_retired_time =
                        #{staffRetiredTime,jdbcType=TIMESTAMP},
            </if>
            <if test="@Ognl@isNotEmpty(staffJobStatus)">
                staff_job_status = #{staffJobStatus,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(staffAccountType)">
                staff_account_type = #{staffAccountType,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(staffPhoneBak)">
                staff_phone_bak = #{staffPhoneBak,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(staffPostCode)">
                staff_post_code = #{staffPostCode,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(staffPostType)">
                staff_post_type = #{staffPostType,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(appId)">
                app_id = #{appId,jdbcType=VARCHAR}
            </if>
        </set>
        WHERE staff_code = #{staffCode,jdbcType=VARCHAR}
    </update>

    <update id="updateByNum">
        UPDATE t_uc_staff
        <set>
            <if test="@Ognl@isNotEmpty(staffName)">
                staff_name = #{staffName,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(staffEnName)">
                staff_en_name = #{staffEnName,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(orgId)">
                org_id = #{orgId,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(orgName)">
                org_name = #{orgName,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(staffSpells)">
                staff_spells = #{staffSpells,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(staffShortSpells)">
                staff_short_spells =
                        #{staffShortSpells,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(staffNum)">
                staff_num = #{staffNum,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(staffShortNum)">
                staff_short_num = #{staffShortNum,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(positionId)">
                position_id = #{positionId,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(positionName)">
                position_name = #{positionName,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(staffSex)">
                staff_sex = #{staffSex,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(staffAge)">
                staff_age = #{staffAge,jdbcType=INTEGER},
            </if>
            <if test="@Ognl@isNotEmpty(staffPaperworkType)">
                staff_paperwork_type =
                        #{staffPaperworkType,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(staffPaperworkNum)">
                staff_paperwork_num =
                        #{staffPaperworkNum,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(staffMail)">
                staff_mail = #{staffMail,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(staffMobile)">
                staff_mobile = #{staffMobile,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(staffMobileBak)">
                staff_mobile_bak = #{staffMobileBak,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(staffFax)">
                staff_fax = #{staffFax,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(staffShortFax)">
                staff_short_fax = #{staffShortFax,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(staffWechart)">
                staff_wechart = #{staffWechart,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(staffHomeAddress)">
                staff_home_address =
                        #{staffHomeAddress,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(staffHomePhone)">
                staff_home_phone = #{staffHomePhone,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(staffWorkAddress)">
                staff_work_address =
                        #{staffWorkAddress,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(staffWorkPhone)">
                staff_work_phone = #{staffWorkPhone,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(staffPassport)">
                staff_passport = #{staffPassport,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(staffNation)">
                staff_nation = #{staffNation,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(staffPoliticalStatus)">
                staff_political_status =
                        #{staffPoliticalStatus,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(staffNativePlace)">
                staff_native_place =
                        #{staffNativePlace,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(staffSort)">
                staff_sort = #{staffSort,jdbcType=INTEGER},
            </if>
            <if test="@Ognl@isNotEmpty(staffStatus)">
                staff_status = #{staffStatus,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(staffType)">
                staff_type = #{staffType,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(staffSubType)">
                staff_sub_type = #{staffSubType,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(staffCreator)">
                staff_creator = #{staffCreator,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(staffCreateTime)">
                staff_create_time =
                        #{staffCreateTime,jdbcType=TIMESTAMP},
            </if>
            <if test="@Ognl@isNotEmpty(staffUpdator)">
                staff_updator = #{staffUpdator,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(staffLastupdateTime)">
                staff_lastupdate_time =
                        #{staffLastupdateTime,jdbcType=TIMESTAMP},
            </if>
            <if test="@Ognl@isNotEmpty(staffWorkType)">
                staff_work_type = #{staffWorkType,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(companyId)">
                company_id = #{companyId,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(companyName)">
                company_name = #{companyName,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(deptId)">
                dept_id = #{deptId,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(deptName)">
                dept_name = #{deptName,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(staffHrId)">
                staff_hr_id = #{staffHrId,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(staffCode)">
                staff_code = #{staffCode,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(staffBirthday)">
                staff_birthday = #{staffBirthday,jdbcType=TIMESTAMP},
            </if>
            <if test="@Ognl@isNotEmpty(staffEducation)">
                staff_education = #{staffEducation,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(staffRetiredTime)">
                staff_retired_time =
                        #{staffRetiredTime,jdbcType=TIMESTAMP},
            </if>
            <if test="@Ognl@isNotEmpty(staffJobStatus)">
                staff_job_status = #{staffJobStatus,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(staffAccountType)">
                staff_account_type = #{staffAccountType,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(staffPhoneBak)">
                staff_phone_bak = #{staffPhoneBak,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(staffPostCode)">
                staff_post_code = #{staffPostCode,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(staffPostType)">
                staff_post_type = #{staffPostType,jdbcType=VARCHAR},
            </if>
            <if test="@Ognl@isNotEmpty(appId)">
                app_id = #{appId,jdbcType=VARCHAR}
            </if>
        </set>
        WHERE staff_num = #{staffNum,jdbcType=VARCHAR}
    </update>

    <delete id="deleteByCode">
        DELETE
        FROM t_uc_staff
        WHERE staff_code =
              #{staffId,jdbcType=VARCHAR}
    </delete>

    <select id="get" resultMap="RM_TucStaffEntity">
        SELECT
        <include refid="TucStaffEntityQueryColumns"/>
        FROM t_uc_staff
        WHERE staff_id = #{staffId,jdbcType=VARCHAR}
    </select>

    <select id="findListByRoleAndStaffCode" resultMap="RM_TucStaffEntity">
        SELECT
            t1.*
        FROM
            t_uc_staff t1
                INNER JOIN t_pf_role2user t2 ON t1.staff_post_code = t2.staff_post_code
        <where>
            t1.staff_status = 'QY'
            <if test="@Ognl@isNotEmpty(codes)">
                and t1.staff_code in
                <foreach collection="codes" item="code" index="index" open="(" separator="," close=")">
                    #{code}
                </foreach>
            </if>
        </where>
        GROUP BY
            t1.staff_post_code,
            t1.app_id
    </select>

    <!-- 分页查询已经使用Dialect进行分页,也可以不使用Dialect直接编写分页 因为分页查询将传 offset,pageSize,lastRows
        三个参数,不同的数据库可以根于此三个参数属性应用不同的分页实现 -->
    <select id="findList" resultMap="RM_TucStaffEntity">
        SELECT
        <include refid="TucStaffEntityQueryColumns"/>
        FROM t_uc_staff
        <include refid="findList_where"/>

        <if test="@Ognl@isNotEmpty(bo.sortColumns)">
            ORDER BY ${bo.sortColumns}
        </if>
    </select>

    <select id="findPage" resultMap="RM_TucStaffEntity">
        SELECT
        <include refid="TucStaffEntityQueryColumns"/>
        FROM t_uc_staff
        <include refid="findList_where"/>

        <if test="@Ognl@isNotEmpty(bo.sortColumns)">
            ORDER BY ${bo.sortColumns}
        </if>
    </select>

    <sql id="findList_where">
        <!-- ognl访问静态方法的表达式 为@class@method(args),以下为调用rapid中的Ognl.isNotEmpty()方法,还有其它方法如isNotBlank()可以使用，具体请查看Ognl类 -->
        <where>
            <if test="@Ognl@isNotEmpty(bo.staffId)">
                AND staff_id = #{bo.staffId,jdbcType=VARCHAR}
            </if>
            <if test="@Ognl@isNotEmpty(bo.staffName)">
                AND staff_name = #{bo.staffName,jdbcType=VARCHAR}
            </if>
            <if test="@Ognl@isNotEmpty(bo.staffEnName)">
                AND staff_en_name = #{bo.staffEnName,jdbcType=VARCHAR}
            </if>
            <if test="@Ognl@isNotEmpty(bo.orgId)">
                AND org_id = #{bo.orgId,jdbcType=VARCHAR}
            </if>
            <if test="@Ognl@isNotEmpty(bo.orgName)">
                AND org_name = #{bo.orgName,jdbcType=VARCHAR}
            </if>
            <if test="@Ognl@isNotEmpty(bo.staffSpells)">
                AND staff_spells = #{bo.staffSpells,jdbcType=VARCHAR}
            </if>
            <if test="@Ognl@isNotEmpty(bo.staffShortSpells)">
                AND staff_short_spells =
                #{bo.staffShortSpells,jdbcType=VARCHAR}
            </if>
            <if test="@Ognl@isNotEmpty(bo.staffNum)">
                AND staff_num = #{bo.staffNum,jdbcType=VARCHAR}
            </if>
            <if test="@Ognl@isNotEmpty(bo.staffShortNum)">
                AND staff_short_num = #{bo.staffShortNum,jdbcType=VARCHAR}
            </if>
            <if test="@Ognl@isNotEmpty(bo.positionId)">
                AND position_id = #{bo.positionId,jdbcType=VARCHAR}
            </if>
            <if test="@Ognl@isNotEmpty(bo.positionName)">
                AND position_name = #{bo.positionName,jdbcType=VARCHAR}
            </if>
            <if test="@Ognl@isNotEmpty(bo.staffSex)">
                AND staff_sex = #{bo.staffSex,jdbcType=VARCHAR}
            </if>
            <if test="@Ognl@isNotEmpty(bo.staffAge)">
                AND staff_age = #{bo.staffAge,jdbcType=INTEGER}
            </if>
            <if test="@Ognl@isNotEmpty(bo.staffPaperworkType)">
                AND staff_paperwork_type =
                #{bo.staffPaperworkType,jdbcType=VARCHAR}
            </if>
            <if test="@Ognl@isNotEmpty(bo.staffPaperworkNum)">
                AND staff_paperwork_num =
                #{bo.staffPaperworkNum,jdbcType=VARCHAR}
            </if>
            <if test="@Ognl@isNotEmpty(bo.staffMail)">
                AND staff_mail = #{bo.staffMail,jdbcType=VARCHAR}
            </if>
            <if test="@Ognl@isNotEmpty(bo.staffMobile)">
                AND staff_mobile = #{bo.staffMobile,jdbcType=VARCHAR}
            </if>
            <if test="@Ognl@isNotEmpty(bo.staffMobileBak)">
                AND staff_mobile_bak = #{bo.staffMobileBak,jdbcType=VARCHAR}
            </if>
            <if test="@Ognl@isNotEmpty(bo.staffFax)">
                AND staff_fax = #{bo.staffFax,jdbcType=VARCHAR}
            </if>
            <if test="@Ognl@isNotEmpty(bo.staffShortFax)">
                AND staff_short_fax = #{bo.staffShortFax,jdbcType=VARCHAR}
            </if>
            <if test="@Ognl@isNotEmpty(bo.staffWechart)">
                AND staff_wechart = #{bo.staffWechart,jdbcType=VARCHAR}
            </if>
            <if test="@Ognl@isNotEmpty(bo.staffHomeAddress)">
                AND staff_home_address =
                #{bo.staffHomeAddress,jdbcType=VARCHAR}
            </if>
            <if test="@Ognl@isNotEmpty(bo.staffHomePhone)">
                AND staff_home_phone = #{bo.staffHomePhone,jdbcType=VARCHAR}
            </if>
            <if test="@Ognl@isNotEmpty(bo.staffWorkAddress)">
                AND staff_work_address =
                #{bo.staffWorkAddress,jdbcType=VARCHAR}
            </if>
            <if test="@Ognl@isNotEmpty(bo.staffWorkPhone)">
                AND staff_work_phone = #{bo.staffWorkPhone,jdbcType=VARCHAR}
            </if>
            <if test="@Ognl@isNotEmpty(bo.staffPassport)">
                AND staff_passport = #{bo.staffPassport,jdbcType=VARCHAR}
            </if>
            <if test="@Ognl@isNotEmpty(bo.staffNation)">
                AND staff_nation = #{bo.staffNation,jdbcType=VARCHAR}
            </if>
            <if test="@Ognl@isNotEmpty(bo.staffPoliticalStatus)">
                AND staff_political_status =
                #{bo.staffPoliticalStatus,jdbcType=VARCHAR}
            </if>
            <if test="@Ognl@isNotEmpty(bo.staffNativePlace)">
                AND staff_native_place =
                #{bo.staffNativePlace,jdbcType=VARCHAR}
            </if>
            <if test="@Ognl@isNotEmpty(bo.staffSort)">
                AND staff_sort = #{bo.staffSort,jdbcType=INTEGER}
            </if>
            <if test="@Ognl@isNotEmpty(bo.staffStatus)">
                AND staff_status = #{bo.staffStatus,jdbcType=VARCHAR}
            </if>
            <if test="@Ognl@isNotEmpty(bo.staffType)">
                AND staff_type = #{bo.staffType,jdbcType=VARCHAR}
            </if>
            <if test="@Ognl@isNotEmpty(bo.staffSubType)">
                AND staff_sub_type = #{bo.staffSubType,jdbcType=VARCHAR}
            </if>
            <if test="@Ognl@isNotEmpty(bo.staffCreator)">
                AND staff_creator = #{bo.staffCreator,jdbcType=VARCHAR}
            </if>

            <if test="@Ognl@isNotEmpty(bo.staffUpdator)">
                AND staff_updator = #{bo.staffUpdator,jdbcType=VARCHAR}
            </if>

            <if test="@Ognl@isNotEmpty(bo.staffWorkType)">
                AND staff_work_type = #{bo.staffWorkType,jdbcType=VARCHAR}
            </if>
            <if test="@Ognl@isNotEmpty(bo.companyId)">
                AND company_id = #{bo.companyId,jdbcType=VARCHAR}
            </if>
            <if test="@Ognl@isNotEmpty(bo.companyName)">
                AND company_name = #{bo.companyName,jdbcType=VARCHAR}
            </if>
            <if test="@Ognl@isNotEmpty(bo.deptId)">
                AND dept_id = #{bo.deptId,jdbcType=VARCHAR}
            </if>
            <if test="@Ognl@isNotEmpty(bo.likeDeptId)">
                AND dept_id like concat('%', #{bo.likeDeptId}, '%')
            </if>
            <if test="@Ognl@isNotEmpty(bo.deptName)">
                AND dept_name = #{bo.deptName,jdbcType=VARCHAR}
            </if>
            <if test="@Ognl@isNotEmpty(bo.staffHrId)">
                AND staff_hr_id = #{bo.staffHrId,jdbcType=VARCHAR}
            </if>
            <if test="@Ognl@isNotEmpty(bo.staffCode)">
                AND staff_code = #{bo.staffCode,jdbcType=VARCHAR}
            </if>

            <if test="@Ognl@isNotEmpty(bo.staffEducation)">
                AND staff_education = #{bo.staffEducation,jdbcType=VARCHAR}
            </if>

            <if test="@Ognl@isNotEmpty(bo.staffJobStatus)">
                AND staff_job_status = #{bo.staffJobStatus,jdbcType=VARCHAR}
            </if>
            <if test="@Ognl@isNotEmpty(bo.staffAccountType)">
                AND staff_account_type =
                #{bo.staffAccountType,jdbcType=VARCHAR}
            </if>
            <if test="@Ognl@isNotEmpty(bo.staffPhoneBak)">
                AND staff_phone_bak = #{bo.staffPhoneBak,jdbcType=VARCHAR}
            </if>
            <if test="@Ognl@isNotEmpty(bo.queryOrgId) and @Ognl@isNotEmpty(bo.staffType)">
                AND FIND_IN_SET(org_id, getOrgChildLst(#{bo.queryOrgId},#{bo.staffType}))
            </if>
            <if test="@Ognl@isNotEmpty(bo.queryStaff)">
                AND (staff_name like CONCAT('%',#{bo.queryStaff},'%' ) OR staff_code = #{bo.queryStaff} OR staff_num =
                #{bo.queryStaff} OR staff_mobile = #{bo.queryStaff})
            </if>
            <if test="@Ognl@isNotEmpty(bo.queryDeptId) and @Ognl@isNotEmpty(bo.staffType)">
                AND dept_id like CONCAT(#{bo.queryDeptId},'%')
            </if>
            <if test="@Ognl@isNotEmpty(bo.staffPostCode)">
                and staff_post_code = #{bo.staffPostCode}
            </if>
            <if test="@Ognl@isNotEmpty(bo.staffPostType)">
                and staff_post_type = #{bo.staffPostType}
            </if>
            <if test="@Ognl@isNotEmpty(bo.appId)">
                and app_id = #{bo.appId,jdbcType=VARCHAR}
            </if>
            <if test="@Ognl@isNotEmpty(bo.postCodes)">
                and staff_post_code in
                <foreach collection="bo.postCodes" item="code" index="index" open="(" separator="," close=")">
                    #{code}
                </foreach>
            </if>
            <if test="@Ognl@isNotEmpty(bo.staffCodes)">
                and staff_code in
                <foreach collection="bo.staffCodes" item="code" index="index" open="(" separator="," close=")">
                    #{code}
                </foreach>
            </if>
        </where>
    </sql>

    <select id="getStaffInfoByOrgTop" resultMap="RM_TucStaffEntity">
        select t1.*
        from t_uc_org t
                     join t_uc_staff t1 on t.org_id = t1.org_id
                where t.org_type = #{bo.staffType}
                  and t.org_sub_type = #{bo.staffType}
                  and staff_status = 'QY'
                  and t1.staff_type = #{bo.staffType}
        <if test="@Ognl@isNotEmpty(bo.staffWorkType)">
            AND staff_work_type = #{bo.staffWorkType}
        </if>
        order by staff_sort
    </select>

    <select id="getStaffInfoByOrgTopPage" resultMap="RM_TucStaffEntity">
        select t1.*
        from t_uc_org t
        join t_uc_staff t1 on t.org_id = t1.org_id
        where t.org_type = #{bo.staffType}
        and t.org_sub_type = #{bo.staffType}
        and staff_status = 'QY'
        and t1.staff_type = #{bo.staffType}
        <if test="@Ognl@isNotEmpty(bo.staffWorkType)">
            AND staff_work_type = #{bo.staffWorkType}
        </if>
        order by staff_sort
    </select>

    <select id="getSubStaffs" resultMap="RM_TucStaffEntity">
        select *
        from t_uc_staff where staff_type = #{bo.staffType}
                          and org_id in
                              (
                                      SELECT org_id
                                      FROM t_uc_org
                                      where org_type = #{bo.staffType}
                                        AND FIND_IN_SET(org_id,
                                                        getOrgChildLst(#{bo.orgId}, #{bo.staffType}))
                                        and org_status = 'QY')
        <if test="@Ognl@isNotEmpty(bo.staffStatus)">
            AND staff_status = #{bo.staffStatus}
        </if>
        <if test="@Ognl@isNotEmpty(bo.staffWorkType)">
            AND staff_work_type = #{bo.staffWorkType}
        </if>
        <if test="@Ognl@isNotEmpty(bo.queryStaff)">
            AND (staff_name like CONCAT('%', #{bo.queryStaff}, '%') OR
                 staff_code = #{bo.queryStaff} OR staff_num = #{bo.queryStaff} OR
                 staff_mobile = #{bo.queryStaff})
        </if>
        ORDER BY t_uc_staff.staff_sort
    </select>

    <select id="getSubStaffsPage" resultMap="RM_TucStaffEntity">
        select *
        from t_uc_staff where staff_type = #{bo.staffType}
        and org_id in
        (
        SELECT org_id
        FROM t_uc_org
        where org_type = #{bo.staffType}
        AND FIND_IN_SET(org_id,
        getOrgChildLst(#{bo.orgId}, #{bo.staffType}))
        and org_status = 'QY')
        <if test="@Ognl@isNotEmpty(bo.staffStatus)">
            AND staff_status = #{bo.staffStatus}
        </if>
        <if test="@Ognl@isNotEmpty(bo.staffWorkType)">
            AND staff_work_type = #{bo.staffWorkType}
        </if>
        <if test="@Ognl@isNotEmpty(bo.queryStaff)">
            AND (staff_name like CONCAT('%', #{bo.queryStaff}, '%') OR
            staff_code = #{bo.queryStaff} OR staff_num = #{bo.queryStaff} OR
            staff_mobile = #{bo.queryStaff})
        </if>
        ORDER BY t_uc_staff.staff_sort
    </select>

    <select id="getStaffByOrgs" resultMap="RM_TucStaffEntity">
        select *
        from t_uc_staff where staff_type = #{bo.staffType}
                          and org_id in
        <foreach collection="bo.orgIds" index="index" item="item" open="(" separator="," close=")">
            #{item}
        </foreach>
        <if test="@Ognl@isNotEmpty(bo.staffStatus)">
            AND staff_status = #{bo.staffStatus}
        </if>
        <if test="@Ognl@isNotEmpty(bo.staffWorkType)">
            AND staff_work_type = #{bo.staffWorkType}
        </if>
        <if test="@Ognl@isNotEmpty(bo.orgName)">
            AND org_name like concat('%', #{bo.orgName}, '%')
        </if>
        <if test="@Ognl@isNotEmpty(bo.queryStaff)">
            AND (staff_name like CONCAT('%', #{bo.queryStaff}, '%') OR
                 staff_code = #{bo.queryStaff} OR staff_num = #{bo.queryStaff} OR
                 staff_mobile = #{bo.queryStaff})
        </if>
        ORDER BY t_uc_staff.staff_sort
    </select>

    <select id="getStaffByOrgsPage" resultMap="RM_TucStaffEntity">
        select *
        from t_uc_staff where staff_type = #{bo.staffType}
        and org_id in
        <foreach collection="bo.orgIds" index="index" item="item" open="(" separator="," close=")">
            #{item}
        </foreach>
        <if test="@Ognl@isNotEmpty(bo.staffStatus)">
            AND staff_status = #{bo.staffStatus}
        </if>
        <if test="@Ognl@isNotEmpty(bo.staffWorkType)">
            AND staff_work_type = #{bo.staffWorkType}
        </if>
        <if test="@Ognl@isNotEmpty(bo.orgName)">
            AND org_name like concat('%', #{bo.orgName}, '%')
        </if>
        <if test="@Ognl@isNotEmpty(bo.queryStaff)">
            AND (staff_name like CONCAT('%', #{bo.queryStaff}, '%') OR
            staff_code = #{bo.queryStaff} OR staff_num = #{bo.queryStaff} OR
            staff_mobile = #{bo.queryStaff})
        </if>
        ORDER BY t_uc_staff.staff_sort
    </select>

    <select id="getAppRoleUser" resultType="java.util.Map">
        SELECT t1.staff_code,
               t1.staff_name,
               t1.org_id,
               t1.org_name,
               t1.staff_post_code,
               t1.staff_post_type,
               t3.app_id,
               t3.role_id,
               t1.company_id,
               t1.company_name,
               t1.dept_id,
               t1.dept_name
        FROM t_uc_staff t1
                     left join t_pf_role2user t2
                on t1.staff_code = t2.user_id and t2.STATUS = 'y' and t2.APP_ID = #{bo.appId,jdbcType=VARCHAR}
                     left join t_pf_role t3
                on t3.role_id = t2.role_id and t3.STATUS = 'y' and t3.APP_ID = #{bo.appId,jdbcType=VARCHAR}
                WHERE t3.app_id = #{bo.appId,jdbcType=VARCHAR}
                  and t2.role_id = #{bo.roleId,jdbcType=VARCHAR}
        <if test="@Ognl@isNotBlank(bo.companyId)">
            and t1.company_id = #{bo.companyId,jdbcType=VARCHAR}
        </if>
        <if test="@Ognl@isNotBlank(bo.deptId)">
            and t1.dept_id = #{bo.deptId,jdbcType=VARCHAR}
        </if>
        <if test="@Ognl@isNotBlank(bo.orgId)">
            and t1.org_id = #{bo.orgId,jdbcType=VARCHAR}
        </if>
    </select>

    <select id="getAppRoleUserPage" resultType="java.util.Map">
        SELECT t1.staff_code,
        t1.staff_name,
        t1.staff_post_code,
        t1.staff_post_type,
        t1.org_id,
        t1.org_name,
        t3.app_id,
        t3.role_id,
        t1.company_id,
        t1.company_name,
        t1.dept_id,
        t1.dept_name
        FROM t_uc_staff t1
        left join t_pf_role2user t2
        on t1.staff_code = t2.user_id and t2.STATUS = 'y' and t2.APP_ID = #{bo.appId,jdbcType=VARCHAR}
        left join t_pf_role t3
        on t3.role_id = t2.role_id and t3.STATUS = 'y' and t3.APP_ID = #{bo.appId,jdbcType=VARCHAR}
        WHERE t3.app_id = #{bo.appId,jdbcType=VARCHAR}
        and t2.role_id = #{bo.roleId,jdbcType=VARCHAR}
        <if test="@Ognl@isNotBlank(bo.companyId)">
            and t1.company_id = #{bo.companyId,jdbcType=VARCHAR}
        </if>
        <if test="@Ognl@isNotBlank(bo.deptId)">
            and t1.dept_id = #{bo.deptId,jdbcType=VARCHAR}
        </if>
        <if test="@Ognl@isNotBlank(bo.orgId)">
            and t1.org_id = #{bo.orgId,jdbcType=VARCHAR}
        </if>
    </select>

    <select id="getAppRoleUserPage2" resultType="java.util.Map">
        SELECT t1.staff_code,
        t1.staff_name,
        t1.staff_post_code,
        t1.staff_post_type,
        t1.org_id,
        t1.org_name,
        t3.app_id,
        t3.role_id,
        t1.company_id,
        t1.company_name,
        t1.dept_id,
        t1.dept_name
        FROM t_uc_staff t1
        left join t_pf_role2user t2
        on t1.staff_post_code = t2.staff_post_code and t2.STATUS = 'y' and t2.APP_ID = #{bo.appId,jdbcType=VARCHAR}
        left join t_pf_role t3
        on t3.role_id = t2.role_id and t3.STATUS = 'y' and t3.APP_ID = #{bo.appId,jdbcType=VARCHAR}
        WHERE t3.app_id = #{bo.appId,jdbcType=VARCHAR}
        and t2.role_id = #{bo.roleId,jdbcType=VARCHAR}
        <if test="@Ognl@isNotBlank(bo.companyId)">
            and t1.company_id = #{bo.companyId,jdbcType=VARCHAR}
        </if>
        <if test="@Ognl@isNotBlank(bo.deptId)">
            and t1.dept_id = #{bo.deptId,jdbcType=VARCHAR}
        </if>
        <if test="@Ognl@isNotBlank(bo.orgId)">
            and t1.org_id = #{bo.orgId,jdbcType=VARCHAR}
        </if>
    </select>

    <!-- 20200728 add 条件获取某租户某角色（或某部门下的用户） -->
    <select id="getAppRoleUserList" resultMap="RM_TucStaffEntity">
        SELECT t1.*
        FROM t_uc_staff t1
                     left join t_pf_role2user t2
                on t1.staff_code = t2.user_id and t2.STATUS = 'y' and t2.APP_ID = #{bo.appId,jdbcType=VARCHAR}
                     left join t_pf_role t3
                on t3.role_id = t2.role_id and t3.STATUS = 'y' and t3.APP_ID = #{bo.appId,jdbcType=VARCHAR}
                WHERE t3.app_id = #{bo.appId,jdbcType=VARCHAR}
                  and t2.role_id = #{bo.roleId,jdbcType=VARCHAR}
        <if test="@Ognl@isNotBlank(bo.companyId)">
            and t1.company_id = #{bo.companyId,jdbcType=VARCHAR}
        </if>
        <if test="@Ognl@isNotBlank(bo.deptId)">
            and t1.dept_id like CONCAT(#{bo.deptId}, '%')
        </if>
        <if test="@Ognl@isNotBlank(bo.orgId)">
            and t1.org_id = #{bo.orgId,jdbcType=VARCHAR}
        </if>
    </select>

    <select id="searchUser" resultType="com.blueland.bo.TreeEntity">
        SELECT staff_id     as id,
               staff_name   as NAME,
               dept_id      as deptId,
               dept_name    as deptName,
               org_id       as orgId,
               org_name     as orgName,
               company_id   as companyId,
               company_name as companyName,
               org_id       as parentId,
               'staff'      as type,
               'true'       as leaf,
               staff_num    as staffNum,
               staff_code   as staffCode,
               staff_mobile as staffMobile,
               staff_post_code as staffPostCode,
               staff_post_type as staffPostType
        FROM t_uc_staff
        <include refid="findList_where"/>
        <if test="@Ognl@isNotEmpty(bo.sortColumns)">
            ORDER BY ${bo.sortColumns}
        </if>
    </select>

    <!-- 20200423 add 用部门模糊查询 -->
    <select id="searchUser4deptId" resultType="com.blueland.bo.TreeEntity">
        SELECT staff_id     as id,
               staff_name   as NAME,
               dept_id      as deptId,
               dept_name    as deptName,
               org_id       as orgId,
               org_name     as orgName,
               company_id   as companyId,
               company_name as companyName,
               org_id       as parentId,
               'staff'      as type,
               'true'       as leaf,
               staff_num    as staffNum,
               staff_code   as staffCode,
               staff_mobile as staffMobile,
               staff_post_code as staffPostCode,
               staff_post_type as staffPostType
        FROM t_uc_staff
        <include refid="findList_where"/>
        <if test="@Ognl@isNotEmpty(bo.sortColumns)">
            ORDER BY ${bo.sortColumns}
        </if>
    </select>

    <select id="findListByName" resultMap="RM_TucStaffEntity">
        SELECT t1.*
        FROM t_uc_staff t1
         JOIN t_uc_org t2 ON t1.org_id = t2.org_id
        WHERE 1 = 1
        <if test="@Ognl@isNotEmpty(bo.appId)">
            AND t1.app_id = #{bo.appId}
            AND t2.app_id = #{bo.appId}
        </if>
        <if test="@Ognl@isNotEmpty(bo.staffName)">
            and t1.staff_name LIKE concat('%', #{bo.staffName}, '%')
        </if>
        <if test="@Ognl@isNotEmpty(bo.staffStatus)">
            AND t1.staff_status = #{bo.staffStatus}
        </if>
        <if test="@Ognl@isNotEmpty(bo.sortColumns)">
            ORDER BY ${bo.sortColumns}
        </if>
    </select>

    <!-- 20200907 add -->
    <select id="getByStaffCode" resultMap="RM_TucStaffEntity">
        SELECT
        <include refid="TucStaffEntityQueryColumns"/>
        FROM t_uc_staff
        WHERE staff_code = #{staffCode,jdbcType=VARCHAR}
        limit 1
    </select>

    <!-- 20201027 add -->
    <select id="getByStaffcodes" resultMap="RM_TucStaffEntity">
        SELECT
        <include refid="TucStaffEntityQueryColumns"/>
        FROM t_uc_staff
                WHERE staff_status = 'QY'
                  and staff_code in
        <foreach collection="staffcodes" item="item" index="index" open="(" separator="," close=")">
            #{item,jdbcType=VARCHAR}
        </foreach>
    </select>
    <update id="updateByStaffPhoneBak">
        UPDATE t_uc_staff
        <set>
            staff_phone_bak = ''
        </set>
        where staff_phone_bak = #{staffPhoneBak,jdbcType=VARCHAR}
    </update>

    <update id="updateDeptnameByDeptid">
        UPDATE t_uc_staff
        SET dept_name = #{deptname},
            org_name  = #{deptname}
        WHERE dept_id = #{deptcode}
    </update>

    <select id="getByStaffFax" resultMap="RM_TucStaffEntity">
        select *
        FROM t_uc_staff
        WHERE staff_num = #{staffFax,jdbcType=VARCHAR}
    </select>

    <select id="getStaffList" resultMap="RM_TucStaffEntity">
        select staff_code, staff_num, staff_name
        FROM t_uc_staff
        WHERE staff_name LIKE concat('%', #{name}, '%')
    </select>

    <select id="getListByCodes" resultMap="RM_TucStaffEntity">
        select staff_code,
               org_id,
               dept_id,
               dept_name,
               staff_name
        FROM t_uc_staff
                WHERE staff_code in
        <foreach collection="codes" item="item" index="index" open="(" separator="," close=")">
            #{item}
        </foreach>
    </select>

    <resultMap id="RM_StaffCodeStaffNum" type="com.blueland.bo.TucStaffEntity" >
        <result property="staffCode" column="staff_code"></result>
        <result property="staffNum" column="staff_num"></result>
    </resultMap>

    <select id="findListStaffCodeStaffNum" resultMap="RM_StaffCodeStaffNum">
        select staff_code,staff_num
        from t_uc_staff
        where staff_status != 'JY'
        AND staff_num is not null AND staff_num != ''
        AND staff_code is not null AND staff_code != ''
    </select>

    <select id="findListQY" resultMap="RM_TucStaffEntity">
        SELECT
        <include refid="TucStaffEntityQueryColumns"/>
        FROM t_uc_staff
        where staff_status != 'JY'
        AND staff_num is not null AND staff_num != ''
        AND staff_code is not null AND staff_code != ''
        and app_id is not null and app_id != ''
        <if test="appId != null and appId != ''">
            and app_id = #{appId}
        </if>
    </select>

    <select id="findStaffPostList" resultType="com.blueland.vo.StaffPostVO">
        SELECT
            r.USER_ID AS staffCode,
            r.staff_post_code as staffPostCode,
            a.app_id AS tenantId,
            a.app_name AS tenantName,
            a.index_url AS appUrl
        FROM
            t_pf_role2user r
        LEFT JOIN t_pf_application a ON r.APP_ID = a.app_id
        WHERE
            r.STATUS = 'Y'
        and a.app_id is not null and a.app_id != ''
        <if test="staffCode != null and staffCode != ''">
            and r.USER_ID = #{staffCode}
        </if>
        GROUP BY
            r.USER_ID,
            r.APP_ID
    </select>

    <select id="findStaffPostList2" resultType="com.blueland.vo.StaffPostVO">
        SELECT
        r.USER_ID AS staffCode,
        r.staff_post_code as staffPostCode,
        a.app_id AS tenantId,
        a.app_name AS tenantName,
        a.index_url AS appUrl
        FROM
        t_pf_role2user r
        LEFT JOIN t_pf_application a ON r.APP_ID = a.app_id
        WHERE
        r.STATUS = 'Y'
        and a.app_id is not null and a.app_id != ''
        <if test="staffCode != null and staffCode != ''">
            and r.USER_ID = #{staffCode}
        </if>
        GROUP BY
        r.APP_ID
    </select>

    <delete id="deleteByPostCode">
        DELETE
        FROM t_uc_staff
        WHERE staff_post_code = #{postCode}
    </delete>

    <select id="getByPostCode" resultMap="RM_TucStaffEntity">
        SELECT
        <include refid="TucStaffEntityQueryColumns"/>
        FROM t_uc_staff
        WHERE staff_post_code = #{postCode}
        AND app_id = #{appId}
        limit 1
    </select>

    <select id="selectStaffByNumAndDept" resultMap="RM_TucStaffEntity">
        SELECT
        <include refid="TucStaffEntityQueryColumns"/>
        FROM
            t_uc_staff
        WHERE
            staff_status = 'QY'
            and staff_num = #{staffNum}
            and dept_id like concat('%',#{deptId},'%')
            limit 1
    </select>

    <select id="selectStaffByNum" resultMap="RM_TucStaffEntity">
        SELECT
        <include refid="TucStaffEntityQueryColumns"/>
        FROM
        t_uc_staff
        WHERE
        staff_status = 'QY'
        and staff_num = #{staffNum}
        limit 1
    </select>

    <select id="countStaff" resultType="integer">
        select count(*) from t_uc_staff
        where id = #{id} and app_id = #{appId}
    </select>

    <select id="countStaffByNum" resultType="integer">
        select count(*) from t_uc_staff
        where staff_num = #{num} and app_id = #{appId}
    </select>

    <delete id="deleteStaffByAppId">
        delete from t_uc_staff where app_id = #{appId}
    </delete>
</mapper>

