<?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="jnpf.personnels.mapper.FtbPersonnelsBlacklistMapper">

    <select id="blacklist" resultType="jnpf.model.personnels.vo.black.FtbPersonnelsBlackListVO">
        select
        a.F_Id as id,
        a.F_UserName as userName,
        a.F_Phone as phone,
        a.F_UserId as userId,
        a.F_OrgName as orgName,
        a.F_PostName as postName,
        a.F_BlackTypeId as blackTypeId,
        a.F_Type as type,
        a.F_UserSystemId as userSystemId,
        a.F_Reason as reason,
        a.F_CreatorTime as createTime,
        b.F_RegularName as blackTypeName
        from ftb_personnels_blacklist a join ftb_personnels_blacklist_type b on b.F_Id=a.F_BlackTypeId
         where a.F_EnableMark = 0
        <if test="params.blackTypeId != null and params.blackTypeId != ''">
            and a.F_BlackTypeId = #{params.blackTypeId}
        </if>
        <if test="params.keyWord != null and params.keyWord != ''">
            and (a.F_UserName like concat('%',#{params.keyWord},'%') or a.F_Phone like concat('%',#{params.keyWord},'%'))
        </if>
        <if test="params.createStartTime != null and params.createStartTime != ''">
            and DATE_FORMAT(a.F_CreatorTime, '%Y-%m-%d') &gt;= #{params.createStartTime}
            and DATE_FORMAT(a.F_CreatorTime, '%Y-%m-%d') &lt;= #{params.createEndTime}
        </if>
        <if test="params.type != null">
            and a.F_Type = #{params.type}
        </if>
    </select>
</mapper>
