<?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.willalp.files.mapper.HsOrgPersonnelFilesMapper">

    <resultMap type="com.willalp.files.domain.HsOrgPersonnelFiles" id="HsOrgPersonnelFilesResult">
        <result property="id" column="id"/>
        <result property="userCode" column="user_code"/>
        <result property="jobNo" column="job_no"/>
        <result property="userName" column="user_name"/>
        <result property="userType" column="user_type"/>
        <result property="sex" column="sex"/>
        <result property="age" column="age"/>
        <result property="nation" column="nation"/>
        <result property="origo" column="origo"/>
        <result property="politicsStatus" column="politics_status"/>
        <result property="educationalLevel" column="educational_level"/>
        <result property="idCard" column="id_card"/>
        <result property="birthday" column="birthday"/>
        <result property="residence" column="residence"/>
        <result property="phone" column="phone"/>
        <result property="email" column="email"/>
        <result property="seatNo" column="seat_no"/>
        <result property="jobTitle" column="job_title"/>
        <result property="department" column="department"/>
        <result property="hiredate" column="hiredate"/>
        <result property="resignationTime" column="resignation_time"/>
        <result property="isDelete" column="is_delete"/>
        <result property="createBy" column="create_by"/>
        <result property="createTime" column="create_time"/>
        <result property="updateBy" column="update_by"/>
        <result property="updateTime" column="update_time"/>
        <result property="remark" column="remark"/>
    </resultMap>

    <sql id="selectHsOrgPersonnelFilesVo">
        select hpf.id,
               user_code,
               job_no,
               user_name,
               sex,
               suo.user_type,
               age,
               nation,
               origo,
               politics_status,
               educational_level,
               id_card,
               birthday,
               residence,
               hpf.phone,
               hpf.email,
               seat_no,
               job_title,
               sd.dept_name as department,
               hiredate,
               resignation_time
        from hs_org_personnel_files hpf
                 left join sys_user_organization suo on suo.login_name = hpf.user_code
                 left join sys_dept sd on sd.dept_id = hpf.department
    </sql>

    <select id="selectHsOrgPersonnelFilesList" parameterType="HsOrgPersonnelFiles"
            resultMap="HsOrgPersonnelFilesResult">
        <include refid="selectHsOrgPersonnelFilesVo"/>
        <where>
            is_delete = 0
            And suo.organization_code = 'G00000007'
            <if test="userType != null  and userType != ''">
                and suo.user_type = #{userType}
            </if>
            <if test="userCode != null  and userCode != ''">
                and user_code = #{userCode}
            </if>
            <if test="jobNo != null  and jobNo != ''">
                and job_no = #{jobNo}
            </if>
            <if test="userName != null  and userName != ''">
                and user_name like concat('%', #{userName}, '%')
            </if>
            <if test="sex != null  and sex != ''">
                and sex = #{sex}
            </if>
            <if test="age != null ">
                and age = #{age}
            </if>
            <if test="nation != null  and nation != ''">
                and nation = #{nation}
            </if>
            <if test="origo != null  and origo != ''">
                and origo = #{origo}
            </if>
            <if test="politicsStatus != null  and politicsStatus != ''">
                and politics_status = #{politicsStatus}
            </if>
            <if test="educationalLevel != null  and educationalLevel != ''">
                and educational_level = #{educationalLevel}
            </if>
            <if test="idCard != null  and idCard != ''">
                and id_card = #{idCard}
            </if>
            <if test="birthday != null  and birthday != ''">
                and birthday = #{birthday}
            </if>
            <if test="residence != null  and residence != ''">
                and residence = #{residence}
            </if>
            <if test="phone != null  and phone != ''">
                and phone = #{phone}
            </if>
            <if test="email != null  and email != ''">
                and email = #{email}
            </if>
            <if test="seatNo != null  and seatNo != ''">
                and seat_no = #{seatNo}
            </if>
            <if test="jobTitle != null  and jobTitle != ''">
                and job_title = #{jobTitle}
            </if>
            <if test="department != null  and department != ''">
                and sd.dept_id = #{department}
            </if>
            <if test="hiredate != null ">
                and hiredate = #{hiredate}
            </if>
            <if test="resignationTime != null ">
                and resignation_time = #{resignationTime}
            </if>
        </where>
    </select>
</mapper>
