SysResourceMapper.xml
3.7 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
87
88
<?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.SysResourceDao">
<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>
<resultMap type="com.sibu.orderHelper.integral.sys.response.SysMenuResponse" id="sysMenu">
<id column="id" property="id"/>
<result column="name" property="name" />
<result column="resource_url" property="resourceUrl" />
<result column="parent_id" property="parentId" />
<result column="target" property="target"/>
<result column="icon_img" property="iconImg"/>
<result column="type" property="type" />
</resultMap>
<sql id="Base_Column_List" >
id,name,type,resource_url,parent_id,parent_ids,target,icon_img,sort,is_show
</sql>
<!-- 获取资源为菜单属性的资源 -->
<select id="getResourceByType" resultMap="sysMenu">
select id,name,resource_url,parent_id,target,icon_img from sys_resource where type = ${type} and is_show = 1 order by sort
</select>
<select id="getResourceByRole" parameterType="java.lang.String" resultMap="sysMenu">
select id,name,resource_url,parent_id,target,icon_img,type from sys_resource where id in (${ids}) and is_show = 1 order by sort
</select>
<!-- 添加菜单资源 -->
<insert id="addSysResource" parameterType="com.sibu.orderHelper.integral.sys.request.SysResourceAddRequest">
insert into sys_resource(name,type,resource_url,parent_id,parent_ids,target,icon_img,sort,is_show)
value(#{name},#{type},#{resourceUrl},#{parentId},#{parentIds},#{target},#{iconImg},#{sort},#{isShow})
</insert>
<!-- 编辑资源 -->
<update id="eidtSysResource" parameterType="com.sibu.orderHelper.integral.sys.request.SysResourceAddRequest">
update sys_resource set name=#{name},type=#{type},resource_url=#{resourceUrl},parent_id=#{parentId},target=#{target},icon_img=#{iconImg},sort=#{sort}
where id = #{id} limit 1
</update>
<!-- 删除资源 -->
<delete id="deleteSysResource" parameterType="java.lang.Integer">
delete from sys_resource where id = #{id} or parent_id = #{id}
</delete>
<!-- 获取菜单资源详情 -->
<select id="getSysResource" parameterType="java.lang.Integer" resultMap="sysResource">
select <include refid="Base_Column_List" /> from sys_resource where id=${id} limit 1
</select>
<!-- 获取菜单资源树结构 -->
<select id="getTreeSysResource" resultMap="sysResource" parameterType="map">
select
<include refid="Base_Column_List" />
from sys_resource
<where>
<if test="isShow != null" >
AND is_show = #{isShow,jdbcType=BIT}
</if>
</where>
order by sort
</select>
<select id="getParentSysResource" resultMap="sysResource" parameterType="map">
select
<include refid="Base_Column_List" />
from sys_resource
<where>
<if test="parentId != null" >
AND parent_id = #{parentId,jdbcType=BIT}
</if>
</where>
order by sort
</select>
</mapper>