From 57cbb7df3dcd52707c8d284ecc035bafb190312d Mon Sep 17 00:00:00 2001
From: java110 <928255095@qq.com>
Date: 星期六, 01 八月 2020 00:14:32 +0800
Subject: [PATCH] Merge branch 'master' of https://github.com/java110/MicroCommunity

---
 java110-db/src/main/resources/mapper/community/MenuServiceDaoImplMapper.xml |   62 +++++++++++++++++++++++++------
 1 files changed, 50 insertions(+), 12 deletions(-)

diff --git a/java110-db/src/main/resources/mapper/community/MenuServiceDaoImplMapper.xml b/java110-db/src/main/resources/mapper/community/MenuServiceDaoImplMapper.xml
index 326c309..597f589 100644
--- a/java110-db/src/main/resources/mapper/community/MenuServiceDaoImplMapper.xml
+++ b/java110-db/src/main/resources/mapper/community/MenuServiceDaoImplMapper.xml
@@ -60,7 +60,7 @@
             <if test="icon !=null and icon != ''">
                 t.icon= #{icon},
             </if>
-            <if test="label !=null and label != ''">
+            <if test="label !=null ">
                 t.label= #{label},
             </if>
             <if test="seq !=null ">
@@ -122,9 +122,9 @@
     <!-- 淇濆瓨璺敱淇℃伅鑷� instance琛ㄤ腑 add by wuxw 2018-07-03 -->
     <insert id="saveBasePrivilegeInfo" parameterType="Map">
         insert into p_privilege(
-        p_id,name,domain,description
+        p_id,name,resource,domain,description,m_id
         ) values (
-        #{pId},#{name},#{domain},#{description}
+        #{pId},#{name},#{resource},#{domain},#{description},#{mId}
         )
 
     </insert>
@@ -132,7 +132,7 @@
 
     <!-- 鏌ヨ璺敱淇℃伅 add by wuxw 2018-07-03 -->
     <select id="getBasePrivilegeInfo" parameterType="Map" resultType="Map">
-        select t.p_id,t.name,t.domain,t.description,t.p_id pId,t.create_time createTime
+        select t.p_id,t.name,t.domain,t.resource,t.description,t.p_id pId,t.create_time createTime
         from p_privilege t
         where t.status_cd= '0'
         <if test="pId !=null and pId != ''">
@@ -141,8 +141,14 @@
         <if test="name !=null and name != ''">
             and t.name like concat('%',#{name},'%')
         </if>
+        <if test="resource !=null and resource != ''">
+            and t.resource = #{resource}
+        </if>
         <if test="domain !=null and domain != ''">
             and t.domain= #{domain}
+        </if>
+        <if test="mId !=null and mId != ''">
+            and t.m_id= #{mId}
         </if>
         order by t.create_time desc
         <if test="page != -1 and page != null ">
@@ -161,6 +167,9 @@
             </if>
             <if test="name !=null and name != ''">
                 t.name= #{name},
+            </if>
+            <if test="resource !=null and resource != ''">
+                t.resource= #{resource},
             </if>
             <if test="domain !=null and domain != ''">
                 t.domain= #{domain},
@@ -202,8 +211,17 @@
         <if test="name !=null and name != ''">
             and t.name like concat('%',#{name},'%')
         </if>
+        <if test="resource !=null and resource != ''">
+            and t.resource = #{resource}
+        </if>
         <if test="domain !=null and domain != ''">
             and t.domain= #{domain}
+        </if>
+        <if test="mId !=null and mId != ''">
+            and t.m_id= #{mId}
+        </if>
+        <if test="statusCd !=null and statusCd != ''">
+            and t.status_cd= #{statusCd}
         </if>
     </select>
 
@@ -214,7 +232,7 @@
         insert into m_menu(
            m_id,name,g_id,url,seq,p_id,description,is_show
         ) values (
-            #{mId},#{name},#{gId},#{url},#{seq},#{pId},#{description},#{isShow}
+            #{mId},#{name},#{gId},#{url},#{seq},'-1',#{description},#{isShow}
         )
     </insert>
 
@@ -227,7 +245,7 @@
         from m_menu t,p_privilege p
         where t.status_cd= '0'
         and p.status_cd= '0'
-        and t.p_id = p.p_id
+        and t.m_id = p.m_id
         <if test="gId !=null and gId != ''">
             and t.g_id= #{gId}
         </if>
@@ -237,9 +255,7 @@
         <if test="mName !=null and mName != ''">
             and t.name like concat('%',#{mName},'%')
         </if>
-        <if test="pId !=null and pId != ''">
-            and t.p_id= #{pId}
-        </if>
+
         <if test="domain !=null and domain != ''">
             and p.domain= #{domain}
         </if>
@@ -250,7 +266,7 @@
             and t.m_id= #{mId}
         </if>
         <if test="pId !=null and pId != ''">
-            and t.p_id= #{pId}
+            and p.p_id= #{pId}
         </if>
         <if test="isShow !=null and isShow != ''">
             and t.is_show= #{isShow}
@@ -334,7 +350,7 @@
         from m_menu t,p_privilege p
         where t.status_cd= '0'
         and p.status_cd= '0'
-        and t.p_id = p.p_id
+        and t.m_id = p.m_id
         <if test="gId !=null and gId != ''">
             and t.g_id= #{gId}
         </if>
@@ -354,7 +370,7 @@
             and p.name like concat('%',#{pName},'%')
         </if>
         <if test="mId !=null and mId != ''">
-            and t.m_id= #{mId}
+            and p.m_id= #{mId}
         </if>
         <if test="pId !=null and pId != ''">
             and t.p_id= #{pId}
@@ -397,5 +413,27 @@
         </if>
     </select>
 
+    <select id="checkUserHasResource" parameterType="Map" resultType="Map">
+        SELECT pp.*,'-1' AS pg_id,'' AS pg_name FROM p_privilege_user ppu,p_privilege pp
+            WHERE ppu.`p_id` = pp.`p_id`
+                AND pp.`resource` = #{resource}
+                AND ppu.`privilege_flag` = '0'
+                AND ppu.`user_id` = #{userId}
+                AND ppu.`status_cd` = '0'
+                AND pp.`status_cd` = '0'
+        UNION
+        SELECT pp.*,ppg.pg_id,ppg.name pg_name FROM p_privilege_user ppu,p_privilege_group ppg,p_privilege pp,p_privilege_rel ppr
+            WHERE ppu.`p_id` = ppr.pg_id
+                AND ppr.pg_id = ppg.pg_id
+                AND ppr.p_id = pp.`p_id`
+                AND pp.`resource` = #{resource}
+                AND ppu.`privilege_flag` = '1'
+                AND ppu.`user_id` = #{userId}
+                AND ppu.`status_cd` = '0'
+                AND pp.`status_cd` = '0'
+                AND ppg.status_cd = '0'
+                AND ppr.status_cd = '0'
+    </select>
+
 
 </mapper>

--
Gitblit v1.8.0