<?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.tamguo.admin.dao.SysUserMapper">
	
	<select id="queryByUserName" resultType="SysUserEntity">
		SELECT
			u.uid,
			u.user_name,
			u.role_ids,
			u.password,
			u.status,
			u.nick_name,
			u.mobile,
			u.email,
			u.course_id
		FROM
			sys_user u
		WHERE
			u.user_name = #{username}
  	</select>
  	
  	<select id="queryPage" resultType="SysUserEntity">
  		SELECT
			u.uid,
			u.user_name,
			u.role_ids,
			r.name as role_name,
			u.password,
			u.status,
			u.nick_name,
			u.mobile,
			u.email,
			u.course_id
		FROM
			sys_user u
		LEFT JOIN sys_role r ON r.uid = u.role_ids 
		<where>
			<if test="userName != null and userName != ''">
				u.user_name like #{userName}
			</if>
		</where>
  	</select>

</mapper>