From f42983b35c738a28ed4b9d1732d1045c5f2a19bb Mon Sep 17 00:00:00 2001
From: java110 <928255095@qq.com>
Date: 星期日, 09 五月 2021 16:57:12 +0800
Subject: [PATCH] 优化代码
---
java110-db/src/main/resources/mapper/center/PrivilegeDAOImplMapper.xml | 83 ++++++++++++++++++++++++++++++-----------
1 files changed, 60 insertions(+), 23 deletions(-)
diff --git a/java110-db/src/main/resources/mapper/center/PrivilegeDAOImplMapper.xml b/java110-db/src/main/resources/mapper/center/PrivilegeDAOImplMapper.xml
old mode 100644
new mode 100755
index 6fc0cae..2012122
--- a/java110-db/src/main/resources/mapper/center/PrivilegeDAOImplMapper.xml
+++ b/java110-db/src/main/resources/mapper/center/PrivilegeDAOImplMapper.xml
@@ -4,7 +4,8 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="privilegeDAOImpl">
<select id="queryUserDefaultPrivilege" parameterType="map" resultType="map">
- SELECT a.`p_id` pId,a.`privilege_flag` privilegeFlag,a.`user_id` userId FROM p_privilege_user a WHERE a.`p_id` = #{pId}
+ SELECT a.`p_id` pId,a.`privilege_flag` privilegeFlag,a.`user_id` userId FROM p_privilege_user a WHERE a.`p_id` =
+ #{pId}
AND a.`user_id` = #{userId}
AND a.`privilege_flag` = '1'
AND a.`status_cd` = '0'
@@ -13,7 +14,11 @@
<!-- 淇濆瓨灞炴�т俊鎭� c_business_attrs -->
<insert id="saveUserDefaultPrivilege" parameterType="Map">
<![CDATA[
- INSERT INTO p_privilege_user(p_id,privilege_flag,user_id) VALUES(#{pId},'1',#{userId})
+
+
+ INSERT INTO p_privilege_user(p_id,privilege_flag,user_id,store_id) VALUES(#{pId},'1',#{userId},#{storeId})
+
+
]]>
</insert>
@@ -31,10 +36,10 @@
<update id="updatePrivilegeGroup" parameterType="Map">
UPDATE p_privilege_group a SET
<if test="name != null and name != ''">
- a.name = #{name},
+ a.name = #{name},
</if>
<if test="description != null and description != ''">
- a.description = #{description}
+ a.description = #{description}
</if>
WHERE 1= 1
<if test="storeId != null and storeId != ''">
@@ -74,18 +79,18 @@
<select id="queryPrivilegeRel" parameterType="Map" resultType="Map">
SELECT
- pp.`name`,
- pp.`domain`,
- pp.`p_id` pId,
- pp.`description`,
- pp.`create_time` createTime
+ pp.`name`,
+ pp.`domain`,
+ pp.`p_id` pId,
+ pp.`description`,
+ pp.`create_time` createTime
FROM
- p_privilege pp,
- p_privilege_rel ppr
+ p_privilege pp,
+ p_privilege_rel ppr
WHERE ppr.`p_id` = pp.`p_id`
- AND ppr.`status_cd` = '0'
- AND pp.`status_cd` = '0'
- AND ppr.`pg_id` = #{pgId}
+ AND ppr.`status_cd` = '0'
+ AND pp.`status_cd` = '0'
+ AND ppr.`pg_id` = #{pgId}
</select>
@@ -113,7 +118,7 @@
<!-- 鏌ヨ鏉冮檺 -->
<select id="queryPrivilege" parameterType="Map" resultType="Map">
SELECT
- pp.`p_id` pId,pp.`name`,pp.`description`,pp.`create_time` createTime,pp.`domain`
+ pp.`p_id` pId,pp.`name`,pp.`description`,pp.`create_time` createTime,pp.`domain`
FROM p_privilege pp
WHERE 1= 1
<if test="pId != null and pId != ''">
@@ -122,17 +127,17 @@
<if test="pId != null and pId != ''">
AND pp.domain = '800900000003'
</if>
- AND pp.`status_cd` = '0'
+ AND pp.`status_cd` = '0'
</select>
<!-- 鏌ヨ鐢ㄦ埛鏉冮檺 -->
<select id="queryUserPrivilege" parameterType="Map" resultType="Map">
SELECT
- ppu.`pu_id` puId,
- ppu.`p_id` pId,
- ppu.`privilege_flag` privilegeFlag,
- ppu.`user_id` userId
+ ppu.`pu_id` puId,
+ ppu.`p_id` pId,
+ ppu.`privilege_flag` privilegeFlag,
+ ppu.`user_id` userId
FROM
- p_privilege_user ppu
+ p_privilege_user ppu
WHERE 1 = 1
<if test="privilegeFlag != null and privilegeFlag != ''">
AND ppu.`privilege_flag` = #{privilegeFlag}
@@ -143,12 +148,16 @@
<if test="userId != null and userId != ''">
AND ppu.`user_id` = #{userId}
</if>
- AND ppu.`status_cd` = '0'
+ AND ppu.`status_cd` = '0'
</select>
<!-- 淇濆瓨灞炴�т俊鎭� c_business_attrs -->
<insert id="addUserPrivilege" parameterType="Map">
<![CDATA[
- INSERT INTO p_privilege_user(p_id,privilege_flag,user_id) VALUES(#{pId},#{privilegeFlag},#{userId})
+
+
+ INSERT INTO p_privilege_user(p_id,privilege_flag,user_id,store_id) VALUES(#{pId},#{privilegeFlag},#{userId},#{storeId})
+
+
]]>
</insert>
@@ -168,4 +177,32 @@
and ppu.status_cd = '0'
</update>
+ <select id="queryPrivilegeUsers" parameterType="map" resultType="map">
+ select t.user_id userId
+ from p_privilege_user t
+ INNER JOIN p_privilege p on t.p_id = p.p_id and p.status_cd = '0'
+ where t.privilege_flag = '0'
+ and t.status_cd = '0'
+ <if test="resource != null and resource != ''">
+ and p.resource = #{resource}
+ </if>
+ <if test="storeId != null and storeId != ''">
+ and t.store_id = #{storeId}
+ </if>
+ union ALL
+ select t.user_id userId
+ from p_privilege_user t
+ inner join p_privilege_group pg on t.p_id = pg.pg_id and pg.status_cd = '0' and pg.pg_id != '600201904002'
+ inner join p_privilege_rel pr on pg.pg_id = pr.pg_id and pr.status_cd ='0'
+ INNER JOIN p_privilege p on pr.p_id = p.p_id and p.status_cd = '0'
+ where t.status_cd = '0'
+ and t.privilege_flag = '1'
+ <if test="resource != null and resource != ''">
+ and p.resource = #{resource}
+ </if>
+ <if test="storeId != null and storeId != ''">
+ and t.store_id = #{storeId}
+ </if>
+ </select>
+
</mapper>
--
Gitblit v1.8.0