<?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.bjsxt.mapper.UsersMapper">
	<select id="selectUserByName" resultMap="us">
		select * from users u ,roles r,roles_menus rm,menus m WHERE u.role_id=r.roleid and r.roleid=rm.roles_id and rm.menus_id=m.menuid and u.username=#{0}
	</select>
	
	<resultMap type="users" id="us">
		<!--接收Users类的数据  -->
			<!--接收主键  -->
			<id property="username" column="username"/>
			<!--接收非主键  -->
			<result property="userpwd" column="userpwd"/>
		<!--接收Users类中其他引用类型的属性的数据  -->
			<!--Roles对象-->
			<association property="roles" javaType="roles">
				<id property="roleid" column="roleid"/>
				<result property="rolename" column="rolename"/>
				
				<!--menus对象  -->
				<association property="menus" javaType="menus">
					<id property="menuid" column="menuid"/>
					<result property="menuname" column="menuname"/>
					<result property="menuurl" column="menuurl"/>
					<result property="fatherid" column="fatherid"/>
				</association>
			</association>
			
			
	</resultMap>
	
</mapper>