<?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.qmth.exam.reserve.dao.UserDao">

    <select id="pageUser" resultType="com.qmth.exam.reserve.bean.user.UserVO">
        SELECT
        u.id,
        u.enable,
        u.role roleCode,
        u.name,
        u.login_name loginName,
        u.mobile,
        u.category_id categoryId,
        u.create_time createTime,
        u.update_time updateTime,
        g.name categoryName
        FROM t_user u
        LEFT JOIN t_category g ON g.id = u.category_id
        <where>
            <if test="req.categoryId != null">
                and u.category_id=#{req.categoryId}
            </if>
            <if test="req.name != null and req.name !=''">
                and u.name like concat('%', #{req.name}, '%')
            </if>
            <if test="req.loginName != null and req.loginName !=''">
                and u.login_name like concat('%', #{req.loginName}, '%')
            </if>
            <if test="req.roleCode != null and req.roleCode !=''">
                and u.role = #{req.roleCode}
            </if>
            <if test="req.enable != null">
                and u.enable=#{req.enable}
            </if>
        </where>
        order by u.update_time desc
    </select>

</mapper>
