<?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.hccake.ballcat.admin.modules.sys.mapper.SysUserMapper">


	<!-- 通过用户ID查询其关联的角色ID-->
	<select id="selectUsersByRoleCode" resultType="com.hccake.ballcat.admin.modules.sys.model.entity.SysUser">
        SELECT
            	u.user_id,
				u.username,
				u.nickname,
				u.password,
				u.salt,
				u.avatar,
				u.sex,
				u.email,
				u.phone,
				u.status,
				u.create_time,
				u.update_time
        FROM
       		sys_user u
		left join
			sys_user_role ur
			on u.user_id = ur.user_id
        left join
            sys_role r
		     on r.id = ur.role_id
        WHERE r.`code` = #{0}
        and u.deleted = 0
    </select>

    <select id="getSelectData" resultType="com.hccake.ballcat.common.core.vo.SelectData">
		select
		username as name , user_id as value
		from
		sys_user
		where
		deleted = 0
		<if test="type != null and type != ''">
			and type = #{type}
		</if>
	</select>


</mapper>
