<?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.platform.dao.TestSysUserDao">
    <select id="queryObject" resultType="com.platform.entity.SysUserEntity">
		select * from sys_user where user_id = #{value}
	</select>

    <select id="queryList" resultType="com.platform.entity.SysUserEntity">
        select u.*, (select d.name from sys_dept d where d.dept_id = u.dept_id) deptName from sys_user u
        <where>
            <if test="createUserId != null">
                and `create_user_id` = #{createUserId}
            </if>
            <if test="username != null and username.trim() != ''">
                and u.`username` like concat('%',#{username},'%')
            </if>
        </where>
        <choose>
            <when test="sidx != null and sidx.trim() != ''">
                order by u.${sidx} ${order}
            </when>
            <otherwise>
                order by u.user_id desc
            </otherwise>
        </choose>
        <if test="offset != null and limit != null">
            limit #{offset}, #{limit}
        </if>
    </select>
</mapper>