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
65
66
67
68
69
70
<?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.MenuRightMapper">
<resultMap id="BaseResultMap" type="com.reyun.saas.mob.user.domain.MenuRight">
<!--
WARNING - @mbg.generated
-->
<id column="id" jdbcType="BIGINT" property="id" />
<result column="parent_id" jdbcType="BIGINT" property="parentId" />
<result column="name" 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="seq" jdbcType="INTEGER" property="seq" />
<result column="grades" jdbcType="INTEGER" property="grades" />
<result column="status" jdbcType="INTEGER" property="status" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="modify_time" jdbcType="TIMESTAMP" property="modifyTime" />
</resultMap>
<resultMap id="MenuDTOMap" type="com.reyun.saas.mob.user.dto.MenuDTO">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="parent_id" jdbcType="BIGINT" property="parentId" />
<result column="name" 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="seq" jdbcType="INTEGER" property="seq" />
<result column="grades" jdbcType="INTEGER" property="grades" />
<result column="status" jdbcType="INTEGER" property="status" />
<collection javaType="java.util.ArrayList" ofType="com.reyun.saas.mob.user.domain.Role" property="roles">
<id column="rid" jdbcType="BIGINT" property="id" />
<result column="rname" jdbcType="VARCHAR" property="name" />
<result column="description" jdbcType="VARCHAR" property="description" />
<result column="rstatus" jdbcType="INTEGER" property="status" />
</collection>
</resultMap>
<select id="getAllMenus" resultMap="MenuDTOMap">
select
m.*,
r.id rid,
r.name rname,
r.status rstatus
from menu_right m
left join role_right rr
on rr.menu_id = m.id
left join role r
on r.id = rr.role_id
where m.status = 1 and m.grades = 3
order by m.id desc
</select>
<!-- 获取用户可访问的所有菜单 -->
<select id="getUserMenus" resultMap="BaseResultMap">
select
m.*
from menu_right m
left join role_right rr on rr.menu_id = m.id
left join role r on r.id = rr.role_id
left join user_role ur2 on ur2.role_id = r.id
left join user u on u.id = ur2.user_id
where
u.id = #{userId}
and m.status = 1
and m.grades <![CDATA[<=]]> 2
order by m.id asc
</select>
</mapper>