/**
* 第一次自己搞懂注解方式的一对多 记录下 这是让我搞懂的地址:https://b23.tv/BZoafo
* 这里演示是一对多关系 一个用户拥有多个权限
*
*/
// 我们先查询出用户的所有信息 因为我们需要用户的id 根据id再做二次查询
// 我们主要的sql 分为两个 1.select * from user
// 2.select distinct r.* from role r inner join user_role ur on
// ur.roleid= r.id where ur.userid =#{id}
// 我们将用1的sql查询出来的结果(也就是需要用户的id)作为2的查询条件
@Select("select * from user")
@Results({
@Result(id = true, property = "id", column = "id"),
@Result(property = "username", column = "username"),
@Result(property = "password", column = "password"),
@Result(property = "email", column = "email"),
@Result(property = "phoneNum", column = "phoneNum"),
@Result(property = "status", column = "status"),
@Result(property = "nickName", column = "nickName"),
@Result(property = "roles", column = "id", many = @Many(select = "com.educate.meeting.dao.IUserDao.findRoleByUid",
fetchType = FetchType.EAGER),javaType=List.class)
})
List<User> findUserInfo(@Param("id") int id);
@Select("select distinct r.* from role r inner join user_role ur on ur.roleid= r.id where ur.userid =#{id}")
List<Role> findRoleByUid(@Param("id") int id);