SysRoleMapper.xml
3.2 KB
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?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.sibu.orderHelper.integral.web.dao.SysRoleDao">
<resultMap type="com.sibu.orderHelper.integral.sys.response.SysRoleResponse" id="sysRole">
<id column="id" property="id"/>
<result column="name" property="name" />
<result column="cnname" property="cnname" />
<result column="resource_ids" property="resourceIds" />
<result column="create_dt" property="createDt" jdbcType="TIMESTAMP"/>
</resultMap>
<resultMap type="com.sibu.orderHelper.integral.sys.response.SysResourceResponse" id="sysResource">
<id column="id" property="id"/>
<result column="name" property="name" />
<result column="type" property="type" />
<result column="resource_url" property="resourceUrl" />
<result column="parent_id" property="parentId" />
<result column="parent_ids" property="parentIds" />
<result column="target" property="target"/>
<result column="icon_img" property="iconImg"/>
<result column="sort" property="sort"/>
<result column="is_show" property="isShow"/>
</resultMap>
<sql id="Base_Column_List" >
id,name,cnname,resource_ids,create_dt
</sql>
<sql id="Resource_Base_Column_List" >
id,name,type,resource_url,parent_id,parent_ids,target,icon_img,sort,is_show
</sql>
<!-- 添加角色 -->
<insert id="addSysRole" parameterType="com.sibu.orderHelper.integral.sys.request.SysRoleAddRequest">
insert into sys_role(name,cnname)
value(#{name},#{cnname})
</insert>
<!-- 编辑角色 -->
<update id="editSysRole" parameterType="com.sibu.orderHelper.integral.sys.request.SysRoleAddRequest">
update sys_role set name=#{name},cnname=#{cnname}
where id = #{id} limit 1
</update>
<!-- 删除角色 -->
<update id="deleteSysRole">
update sys_role set available = 1 where id = #{id}
</update>
<!-- 验证角色绑定的用户 -->
<select id="getBindUserCount" resultType="integer">
select count(*) from sys_user where type_id=${id} limit 1
</select>
<!-- 获取菜单角色详情 -->
<select id="getSysRole" parameterType="java.lang.Integer" resultMap="sysRole">
select <include refid="Base_Column_List" /> from sys_role where id=${id} limit 1
</select>
<!-- 获取角色列表 -->
<select id="listSysRole" resultMap="sysRole">
select <include refid="Base_Column_List" /> from sys_role where available=0
</select>
<!-- 分配角色资源 -->
<update id="allocationRoleResource" parameterType="com.sibu.orderHelper.integral.sys.request.SysRoleAddRequest">
update sys_role set resource_ids = #{resourceIds} where id = #{id} limit 1
</update>
<!-- 获取角色树结构 -->
<select id="getRoleResource" resultMap="sysResource" parameterType="map">
select
<include refid="Resource_Base_Column_List" />
from sys_resource
<where>
<if test="resourceIds != null" >
AND id in #{resourceIds}
</if>
</where>
order by sort
</select>
</mapper>