<?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.ktg.iscs.mapper.IsBlacklistMapper">

    <select id="getIsBlacklistPage" resultType="com.ktg.iscs.domain.IsBlacklist">
        select b.*, u.user_name, u.nick_name from is_blacklist b
        left join sys_user u on u.user_id = b.user_id
        <where>
            <if test="isBlacklist.userName != null and isBlacklist.userName.trim != ''">
                and u.user_name like concat('%',#{isBlacklist.userName},'%')
            </if>
            <if test="isBlacklist.nickName != null and isBlacklist.nickName.trim != ''">
                and u.nick_name like concat('%',#{isBlacklist.nickName},'%')
            </if>
            <if test="isBlacklist.userId != null">
                and b.user_id = #{isBlacklist.userId}
            </if>
        </where>
        order by b.record_id desc
    </select>
    <select id="getWhiteUserPage" resultType="com.ktg.iscs.domain.vo.user.WhiteUserVO">
        SELECT
            u.user_id,
            u.user_name,
            u.nick_name
        FROM
            sys_user u
        <where>
            u.user_id NOT IN (SELECT b.user_id FROM is_blacklist b)
            and u.del_flag = '0'
            <if test="dto.nickName != null and dto.nickName.trim != ''">
                and (u.user_name like concat('%',#{dto.nickName},'%') or u.nick_name like concat('%',#{dto.nickName},'%'))
            </if>
        </where>
        order by u.user_id asc
    </select>
</mapper>
