From 05683f2b2bdbdbe21cf17ad523c21ab338bd1c54 Mon Sep 17 00:00:00 2001
From: wuxw <928255095@qq.com>
Date: 星期二, 19 七月 2022 21:49:55 +0800
Subject: [PATCH] 优化添加设备 功能

---
 java110-db/src/main/resources/mapper/community/MenuServiceDaoImplMapper.xml |  125 ++++++++++++++++++++++++++++-------------
 1 files changed, 86 insertions(+), 39 deletions(-)

diff --git a/java110-db/src/main/resources/mapper/community/MenuServiceDaoImplMapper.xml b/java110-db/src/main/resources/mapper/community/MenuServiceDaoImplMapper.xml
old mode 100644
new mode 100755
index 4ce72af..7994579
--- a/java110-db/src/main/resources/mapper/community/MenuServiceDaoImplMapper.xml
+++ b/java110-db/src/main/resources/mapper/community/MenuServiceDaoImplMapper.xml
@@ -3,14 +3,14 @@
         PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="menuServiceDaoImpl">
-    
+
 
     <!-- 淇濆瓨璺敱淇℃伅鑷� instance琛ㄤ腑 add by wuxw 2018-07-03 -->
     <insert id="saveMenuGroupInfo" parameterType="Map">
         insert into m_menu_group(
-        g_id,name,icon,label,seq,description
+        g_id,name,icon,label,seq,description,group_type,store_type
         ) values (
-        #{gId},#{name},#{icon},#{label},#{seq},#{description}
+        #{gId},#{name},#{icon},#{label},#{seq},#{description},#{groupType},#{storeType}
         )
 
     </insert>
@@ -18,7 +18,7 @@
 
     <!-- 鏌ヨ璺敱淇℃伅 add by wuxw 2018-07-03 -->
     <select id="getMenuGroupInfo" parameterType="Map" resultType="Map">
-        select t.g_id,t.name,t.icon,t.label,t.seq,t.description,t.g_id gId
+        select t.g_id,t.name,t.icon,t.label,t.seq,t.description,t.g_id gId,t.group_type groupType,t.store_type storeType
         from m_menu_group t
         where t.status_cd= '0'
         <if test="gId !=null and gId != ''">
@@ -33,13 +33,20 @@
         <if test="label !=null and label != ''">
             and t.label= #{label}
         </if>
+        <if test="groupType !=null and groupType != ''">
+            and t.group_type= #{groupType}
+        </if>
+        <if test="storeType !=null and storeType != ''">
+            and t.store_type= #{storeType}
+        </if>
         <if test="seq !=null">
             and t.seq= #{seq}
         </if>
+
         <if test="description !=null and description != ''">
             and t.description= #{description}
         </if>
-        order by t.create_time desc
+        order by t.seq desc
         <if test="page != -1 and page != null ">
             limit #{page}, #{row}
         </if>
@@ -55,16 +62,22 @@
                 t.status_cd = #{statusCd},
             </if>
             <if test="name !=null and name != ''">
-                 t.name= #{name},
+                t.name= #{name},
             </if>
             <if test="icon !=null and icon != ''">
                 t.icon= #{icon},
+            </if>
+            <if test="groupType !=null and groupType != ''">
+                t.group_type= #{groupType},
             </if>
             <if test="label !=null ">
                 t.label= #{label},
             </if>
             <if test="seq !=null ">
                 t.seq= #{seq},
+            </if>
+            <if test="storeType !=null and storeType != ''">
+                t.store_type= #{storeType},
             </if>
             <if test="description !=null and description != ''">
                 t.description= #{description}
@@ -78,7 +91,7 @@
     <select id="queryMenuGroupsCount" parameterType="Map" resultType="Map">
         select count(1) count
         from m_menu_group t
-        where 1 =1
+        where t.status_cd= '0'
         <if test="gId !=null and gId != ''">
             and t.g_id= #{gId}
         </if>
@@ -87,6 +100,9 @@
         </if>
         <if test="icon !=null and icon != ''">
             and t.icon= #{icon}
+        </if>
+        <if test="groupType !=null and groupType != ''">
+            and t.group_type= #{groupType}
         </if>
         <if test="statusCd !=null and statusCd != ''">
             and t.status_cd= #{statusCd}
@@ -97,14 +113,13 @@
         <if test="seq !=null">
             and t.seq= #{seq}
         </if>
+        <if test="storeType !=null and storeType != ''">
+            and t.store_type= #{storeType}
+        </if>
         <if test="description !=null and description != ''">
             and t.description= #{description}
         </if>
     </select>
-
-
-
-
 
 
     <!-- 淇濆瓨璺敱淇℃伅鑷� instance琛ㄤ腑 add by wuxw 2018-07-03 -->
@@ -116,7 +131,6 @@
         )
 
     </insert>
-
 
 
     <!-- 淇濆瓨璺敱淇℃伅鑷� instance琛ㄤ腑 add by wuxw 2018-07-03 -->
@@ -132,8 +146,9 @@
 
     <!-- 鏌ヨ璺敱淇℃伅 add by wuxw 2018-07-03 -->
     <select id="getBasePrivilegeInfo" parameterType="Map" resultType="Map">
-        select t.p_id,t.name,t.domain,t.resource,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,st.name stName
         from p_privilege t
+        left join store_type st on t.domain=st.store_type_cd
         where t.status_cd= '0'
         <if test="pId !=null and pId != ''">
             and t.p_id= #{pId}
@@ -199,7 +214,6 @@
     </update>
 
 
-
     <!-- 鏌ヨ璺敱鏁伴噺 add by wuxw 2018-07-03 -->
     <select id="queryBasePrivilegesCount" parameterType="Map" resultType="Map">
         select count(1) count
@@ -226,26 +240,27 @@
     </select>
 
 
-
     <!-- 淇濆瓨璺敱淇℃伅鑷� instance琛ㄤ腑 add by wuxw 2018-07-03 -->
     <insert id="saveMenuInfo" parameterType="Map">
         insert into m_menu(
-           m_id,name,g_id,url,seq,p_id,description,is_show
+        m_id,name,g_id,url,seq,p_id,description,is_show
         ) values (
-            #{mId},#{name},#{gId},#{url},#{seq},'-1',#{description},#{isShow}
+        #{mId},#{name},#{gId},#{url},#{seq},'-1',#{description},#{isShow}
         )
     </insert>
 
 
     <!-- 鏌ヨ璺敱淇℃伅 add by wuxw 2018-07-03 -->
     <select id="getMenuInfo" parameterType="Map" resultType="Map">
-        select t.m_id mId,t.name,t.g_id gId,t.url,t.seq,t.p_id pId,t.description,t.is_show isShow,
+        select DISTINCT t.m_id mId,t.name,t.g_id gId,t.url,t.seq,t.p_id pId,t.description,t.is_show isShow,
         if(t.is_show='Y','鏄剧ず','涓嶆樉绀�') isShowName,
-        p.p_id pId,p.name pName
-        from m_menu t,p_privilege p
+        t.m_id pId,t.name pName,mg.name menuGroupName,mg.store_type,st.name storeTypeName
+        from m_menu t,p_privilege p,m_menu_group mg,store_type st
         where t.status_cd= '0'
         and p.status_cd= '0'
         and t.m_id = p.m_id
+        and t.g_id = mg.g_id
+        and mg.store_type = st.store_type_cd
         <if test="gId !=null and gId != ''">
             and t.g_id= #{gId}
         </if>
@@ -304,7 +319,7 @@
             AND ppr.status_cd = '0'
             )
         </if>
-        order by t.seq desc
+        order by t.seq
         <if test="page != -1 and page != null ">
             limit #{page}, #{row}
         </if>
@@ -346,11 +361,13 @@
 
     <!-- 鏌ヨ璺敱鏁伴噺 add by wuxw 2018-07-03 -->
     <select id="queryMenusCount" parameterType="Map" resultType="Map">
-        select count(1) count
-        from m_menu t,p_privilege p
+        select count(DISTINCT(t.m_id)) count
+        from m_menu t,p_privilege p,m_menu_group mg,store_type st
         where t.status_cd= '0'
         and p.status_cd= '0'
         and t.m_id = p.m_id
+        and t.g_id = mg.g_id
+        and mg.store_type = st.store_type_cd
         <if test="gId !=null and gId != ''">
             and t.g_id= #{gId}
         </if>
@@ -415,25 +432,55 @@
 
     <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'
+        WHERE ppu.`p_id` = pp.`p_id`
+        <if test="resource != null and resource != ''">
+            AND pp.`resource` = #{resource}
+        </if>
+        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`
+        <if test="resource != null and resource != ''">
+            AND pp.`resource` = #{resource}
+        </if>
+        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>
+
+    <select id="hasPrivilege" parameterType="Map" resultType="Map">
+        SELECT  DISTINCT  tt.p_id `pId`,tt.name,tt.pg_id pgId,tt.pg_name pgName,tt.description,tt.create_time createTime FROM (
+        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.p_id = #{pId}
+        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'
+        WHERE ppu.`p_id` = ppr.pg_id
+        AND ppr.pg_id = ppg.pg_id
+        AND ppr.p_id = pp.`p_id`
+        AND pp.p_id = #{pId}
+        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'
+        ) tt
     </select>
 
 
+
 </mapper>

--
Gitblit v1.8.0