RoleFunctionRelationMapper.xml
8.82 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
<?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="cn.com.glsx.merchants.mapper.RoleFunctionRelationMapper">
<resultMap id="BaseResultMap" type="cn.com.glsx.merchants.entity.RoleFunctionRelation">
<id column="id" jdbcType="INTEGER" property="id"/>
<result column="role_accounttype_id" jdbcType="INTEGER" property="roleAccounttypeId"/>
<result column="product_id" jdbcType="INTEGER" property="productId"/>
<result column="menu_id" jdbcType="INTEGER" property="menuId"/>
<result column="funciton_id" jdbcType="INTEGER" property="funcitonId"/>
<result column="created_by" jdbcType="INTEGER" property="createdBy"/>
<result column="created_time" jdbcType="TIMESTAMP" property="createdTime"/>
<result column="updated_by" jdbcType="INTEGER" property="updatedBy"/>
<result column="updated_time" jdbcType="TIMESTAMP" property="updatedTime"/>
<result column="del_flag" jdbcType="TINYINT" property="delFlag"/>
<result column="function_value" jdbcType="VARCHAR" property="functionValue"/>
</resultMap>
<resultMap id="ResultMap" type="cn.com.glsx.merchants.model.response.RoleFunctionRelationResponse"
extends="BaseResultMap">
<result column="product_name" jdbcType="VARCHAR" property="productName"/>
</resultMap>
<sql id="Base_Column_List">
id
, role_accounttype_id, product_id, menu_id, funciton_id, created_by, created_time,
updated_by, updated_time, del_flag, function_value
</sql>
<delete id="deleteByRelationIdList" parameterType="java.lang.Integer">
update platform_merchant_role_function_relation set del_flag = -1
where 1 = 1 and role_accounttype_id in
<foreach collection="idList" separator="," close=")" open="(" index="index" item="item">
#{item,jdbcType=INTEGER}
</foreach>
</delete>
<delete id="deleteByCondition" parameterType="java.lang.Integer">
update platform_merchant_role_function_relation set del_flag = -1
where 1 = 1 and role_accounttype_id in
<foreach collection="idList" separator="," close=")" open="(" index="index" item="item">
#{item.id,jdbcType=INTEGER}
</foreach>
<if test="productId != null">
and product_id = #{productId,jdbcType=INTEGER}
</if>
<if test="menuId != null">
and menu_id = #{menuId,jdbcType=INTEGER}
</if>
<if test="functionId != null">
and funciton_id = #{functionId,jdbcType=INTEGER}
</if>
</delete>
<insert id="batchInsert" keyColumn="id" keyProperty="id" parameterType="map" useGeneratedKeys="true">
insert into platform_merchant_role_function_relation
(role_accounttype_id, product_id, menu_id, funciton_id, created_by, created_time,
updated_by, updated_time, del_flag, function_value)
values
<foreach collection="list" item="item" separator=",">
(#{item.roleAccounttypeId,jdbcType=INTEGER}, #{item.productId,jdbcType=INTEGER},
#{item.menuId,jdbcType=INTEGER}, #{item.funcitonId,jdbcType=INTEGER}, #{item.createdBy,jdbcType=INTEGER},
#{item.createdTime,jdbcType=TIMESTAMP}, #{item.updatedBy,jdbcType=INTEGER},
#{item.updatedTime,jdbcType=TIMESTAMP},
#{item.delFlag,jdbcType=TINYINT}, #{item.functionValue,jdbcType=VARCHAR})
</foreach>
</insert>
<select id="selectByCondition" resultMap="ResultMap"
parameterType="cn.com.glsx.merchants.model.request.RoleFunctionRelationRequest">
select t.id, t.role_accounttype_id, t.product_id, t.menu_id, t.funciton_id, t.created_by, t.created_time,
t.updated_by,t.updated_time, t.function_value, p.product_name
from platform_merchant_role_function_relation t left join platform_merchant_product p
on t.product_id = p.id where t.del_flag = 0
<if test="obj.roleAccounttypeId != null">
and t.role_accounttype_id = #{obj.roleAccounttypeId,jdbcType=INTEGER}
</if>
</select>
<select id="findMenuFunTreeByRole" resultType="cn.com.glsx.merchants.model.MerchantCompareModel">
select p1.accounttype_id as accountTypeId,
p2.accounttype_name as accountTypeName,
p5.product_id as productId,
p4.product_name as productName,
p5.menu_id as menuId,
p6.menu_name as menuName,
p5.funciton_id as functionId,
p6.menu_url as menuUrl,
p5.function_value as functionvalue,
p7.function_name as functionName,
p7.function_attribute_name as functionUrl,
p6.parentId as parentId,
p6.menu_position as sort
from platform_merchant_role_accounttype_relation p1
left join platform_merchant_accounttype p2 on p1.accounttype_id = p2.id
left join platform_merchant_role_function_relation p5
on p1.id = p5.role_accounttype_id and p5.del_flag = 0
left JOIN platform_merchant_product p4 on p5.product_id = p4.id
left join platform_merchant_product_menu p6 on p6.id = p5.menu_id
left join platform_merchant_product_function p7 on p5.funciton_id = p7.id
where p1.role_id = #{roleId}
and p1.del_flag = 0
and p1.accounttype_id is not null
</select>
<select id="findMenuFunTreeByRoleAndMenuId" resultType="cn.com.glsx.merchants.model.MerchantCompareModel">
select p1.accounttype_id as accountTypeId,
p2.accounttype_name as accountTypeName,
p5.product_id as productId,
p4.product_name as productName,
p5.menu_id as menuId,
p6.menu_name as menuName,
p5.funciton_id as functionId,
p6.menu_url as menuUrl,
p5.function_value as functionvalue,
p7.function_name as functionName,
p7.function_attribute_name as functionUrl,
p6.parentId as parentId
,
p6.menu_position as sort
from platform_merchant_role_accounttype_relation p1
left join platform_merchant_accounttype p2 on p1.accounttype_id = p2.id
left join platform_merchant_role_function_relation p5
on p1.id = p5.role_accounttype_id and p5.del_flag = 0
left JOIN platform_merchant_product p4 on p5.product_id = p4.id
left join platform_merchant_product_menu p6 on p6.id = p5.menu_id
left join platform_merchant_product_function p7 on p5.funciton_id = p7.id
where p1.role_id = #{roleId}
and p1.del_flag = 0
and p6.id = #{menuId}
and p1.accounttype_id is not null
</select>
<select id="findByCondition" resultMap="BaseResultMap">
select * from platform_merchant_role_function_relation
where del_flag = 0
<if test="productId != null">
and product_id = #{productId}
</if>
and menu_id = #{menuId}
and role_accounttype_id in
<foreach collection="ids" separator="," close=")" open="(" index="index" item="item">
#{item}
</foreach>
</select>
<update id="deleteByMenuId">
update platform_merchant_role_function_relation
set del_flag = -1,
updated_by=#{roleFunctionRelation.createdBy},
updated_time=NOW()
where 1 = 1
and menu_id = #{roleFunctionRelation.menuId}
</update>
<update id="deleteByFunctionId">
update platform_merchant_role_function_relation
set del_flag = -1,
updated_by=#{roleFunctionRelation.createdBy},
updated_time=NOW()
where 1 = 1
and funciton_id = #{roleFunctionRelation.funcitonId}
</update>
<update id="batchUpdate">
<foreach collection="list" item="item" index="index" open="" close="" separator=";">
update platform_merchant_role_function_relation
set del_flag = -1,
updated_by=#{item.createdBy},
updated_time=NOW()
where
role_accounttype_id=#{item.roleAccounttypeId}
and product_id=#{item.productId}
and menu_id=#{item.menuId}
<if test="item.funcitonId != null">
and funciton_id = #{item.funcitonId}
and function_value = #{item.functionValue}
</if>
</foreach>
</update>
</mapper>