1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?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.reyun.saas.mob.user.dao.RoleMapper">
<resultMap id="BaseResultMap" type="com.reyun.saas.mob.user.domain.Role">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="name" jdbcType="VARCHAR" property="name" />
<result column="description" jdbcType="VARCHAR" property="description" />
<result column="seq" jdbcType="INTEGER" property="seq" />
<result column="status" jdbcType="INTEGER" property="status" />
<result column="modify_time" jdbcType="TIMESTAMP" property="modifyTime" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
</resultMap>
<resultMap id="RoleDTOMap" type="com.reyun.saas.mob.user.dto.role.RoleDTO">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="name" jdbcType="VARCHAR" property="name" />
<result column="description" jdbcType="VARCHAR" property="description" />
<result column="seq" jdbcType="INTEGER" property="seq" />
<result column="status" jdbcType="INTEGER" property="status" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="modify_time" jdbcType="TIMESTAMP" property="modifyTime" />
<!--权限列表-->
<collection property="menus" ofType="com.reyun.saas.mob.user.domain.MenuRight" javaType="java.util.ArrayList">
<id column="mid" jdbcType="BIGINT" property="id" />
<result column="mparent_id" jdbcType="BIGINT" property="parentId" />
<result column="mname" jdbcType="VARCHAR" property="name" />
<result column="method" jdbcType="VARCHAR" property="method" />
<result column="url" jdbcType="VARCHAR" property="url" />
<result column="icon" jdbcType="VARCHAR" property="icon" />
<result column="grades" jdbcType="INTEGER" property="grades" />
<result column="mseq" jdbcType="INTEGER" property="seq" />
<result column="mstatus" jdbcType="INTEGER" property="status" />
<result column="mcreate_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="mmodify_time" jdbcType="TIMESTAMP" property="modifyTime" />
</collection>
</resultMap>
<!-- 获取角色和权限信息 -->
<select id="getMenusByRoleId" resultMap="RoleDTOMap">
select
r.*,
m.id as mid,
m.parent_id as mparent_id,
m.name mname,
m.method,
m.url,
m.icon,
m.status mstatus,
m.grades,
m.seq as mseq,
m.create_time as mcreate_time,
m.modify_time as mmodify_time
from role r
left join role_right rr
on rr.role_id = r.id
left join menu_right m
on rr.menu_id = m.id
where r.id = #{id}
and r.status = 1
order by m.id ASC
</select>
</mapper>