<?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="mapper.UserMapper" >
    <!--配置映射关系-->
    <resultMap id="userMapper" type="pojo.Users">
        <id property="userid" column="userid"/>
        <result property="username" column="username"/>
        <result property="userpassword" column="userpassword"/>

        <!-- 配置关联对象Roles(单个对象) -->
        <association property="roles" javaType="pojo.Roles">
            <id property="roleid" column="roleid"/>
            <result property="rolename" column="rolename"/>
        </association>

        <!-- 配置关联对象Menus(集合) -->
        <collection property="menusList" ofType="pojo.Menus">
            <id property="menuid" column="menuid"/>
            <result property="menuname" column="menuname"/>
            <result property="menuurl" column="menuurl"/>
            <result property="fatherid" column="fatherid"/>
        </collection>
    </resultMap>

    <!--查询操作-->
    <select id="selectUserById" parameterType="pojo.Users" resultMap="userMapper">
        select * from users u,roles r,menus m,roles_menus rm where u.roles_id = r.roleid and r.roleid = rm.roles_id and rm.menus_id = m.menuid and u.userid = #{userid};
    </select>
</mapper>