<?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.yx.face.dao.UserInfoDao">


    <select id="getUsersByFacePass" resultType="com.yx.face.model.vo.UserInfoVO">
        SELECT info.id AS userId,
        info.avatar AS avatar,
        info.nickname AS nickname,
        info.username AS username,
        info.phone AS phone,
        info.id_number AS idNumber,
        info.gender AS gender,
        info.update_time AS createTime
        FROM user_info AS info INNER JOIN face_pass pass on info.id = pass.user_id
        <where>
            <if test="query != null">
                <if test="query.adminId != null">
                    AND pass.admin_id = #{query.adminId}
                </if>
                <if test="query.username != null and query.username !=''">
                    AND info.username = #{query.username}
                </if>
                <if test="query.phone != null and query.phone !=''">
                    AND info.phone = #{query.phone}
                </if>
                <if test="query.idNumber != null and query.idNumber !=''">
                    AND info.id_number = #{query.idNumber}
                </if>
            </if>
        </where>
        GROUP BY info.id ORDER BY  info.id DESC
    </select>


</mapper>

