Kaynağa Gözat

电子信息牌数据权限修改

xuxiaofei 2 yıl önce
ebeveyn
işleme
fd56c361e0

+ 3 - 0
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/impl/XxpCardInfoServiceImpl.java

@@ -1,5 +1,6 @@
 package com.zd.laboratory.service.impl;
 
+import com.zd.common.core.annotation.DataScope;
 import com.zd.common.core.exception.ServiceException;
 import com.zd.common.core.security.TokenService;
 import com.zd.common.core.utils.StringUtils;
@@ -9,6 +10,7 @@ import com.zd.laboratory.domain.XxpUserAuth;
 import com.zd.laboratory.mapper.XxpCardInfoMapper;
 import com.zd.laboratory.mapper.XxpUserAuthMapper;
 import com.zd.laboratory.service.IXxpCardInfoService;
+import com.zd.model.domain.per.PerPrefix;
 import com.zd.model.entity.SysUser;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -53,6 +55,7 @@ public class XxpCardInfoServiceImpl implements IXxpCardInfoService
      * @return 电子信息牌集合
      */
     @Override
+    @DataScope(deptAlias = "d" , permi = PerPrefix.LABORATORY_CARDINFO)
     public List<XxpCardInfo> selectXxpCardInfoList(XxpCardInfo xxpCardInfo) {
         return xxpCardInfoMapper.selectXxpCardInfoList(xxpCardInfo);
     }

+ 22 - 19
zd-modules/zd-modules-laboratory/src/main/resources/mapper/laboratory/XxpCardInfoMapper.xml

@@ -27,26 +27,27 @@
     </resultMap>
 
     <sql id="selectXxpCardInfo">
-        select id,
-               card_name,
-               card_num,
-               college,
-               college_id,
-               location,
-               operate,
-               auth_type,
-               auth_pwd,
-               subject_id,
-               subject_name,
-               dept_id,
-               dept_name,
-               is_start,
-               user_id,
-               create_by,
-               create_time,
-               update_by,
-               update_time
+        select t.id,
+               t.card_name,
+               t.card_num,
+               t.college,
+               t.college_id,
+               t.location,
+               t.operate,
+               t.auth_type,
+               t.auth_pwd,
+               t.subject_id,
+               t.subject_name,
+               t.dept_id,
+               t.dept_name,
+               t.is_start,
+               t.user_id,
+               t.create_by,
+               t.create_time,
+               t.update_by,
+               t.update_time
         from xxp_card_info t
+        left join sys_dept d on t.dept_id = d.dept_id
     </sql>
 
     <select id="selectXxpCardInfoList" parameterType="com.zd.laboratory.domain.XxpCardInfo"
@@ -80,6 +81,8 @@
                 or t.subject_name like concat('%', #{searchValue}, '%')
                 )
             </if>
+            <!-- 数据范围过滤 -->
+            ${params.dataScope}
         </where>
     </select>
 

+ 1 - 1
zd-modules/zd-modules-system/src/main/java/com/zd/system/service/impl/SysUserServiceImpl.java

@@ -1193,8 +1193,8 @@ public class SysUserServiceImpl implements ISysUserService {
      * @return
      */
     @Override
-    @DataScope(deptAlias = "d", userAlias = "u")
     public List<SysUser> selectUserDutyList(SysUser sysUser) {
+        sysUser.setDeptId(tokenService.getLoginUser().getSysUser().getDeptId());
         return userMapper.selectUserDutyList(sysUser);
     }
 

+ 103 - 43
zd-modules/zd-modules-system/src/main/resources/mapper/system/SysDeptMapper.xml

@@ -94,32 +94,32 @@
         order by d.parent_id, d.order_num
     </select>
 
-    <select id="selectDeptById"  resultMap="SysDeptResult">
+    <select id="selectDeptById" resultMap="SysDeptResult">
         <include refid="selectDeptVo"/>
         where dept_id = #{deptId}
     </select>
 
-    <select id="checkDeptExistUser"  resultType="int">
+    <select id="checkDeptExistUser" resultType="int">
         select count(1)
         from sys_user
         where dept_id = #{deptId}
           and del_flag = '0'
     </select>
 
-    <select id="hasChildByDeptId"  resultType="int">
+    <select id="hasChildByDeptId" resultType="int">
         select count(1)
         from sys_dept
         where del_flag = '0'
           and parent_id = #{deptId}
     </select>
 
-    <select id="selectChildrenDeptById"  resultMap="SysDeptResult">
+    <select id="selectChildrenDeptById" resultMap="SysDeptResult">
         select *
         from sys_dept
         where find_in_set(#{deptId}, ancestors)
     </select>
 
-    <select id="selectNormalChildrenDeptById"  resultType="java.lang.Integer">
+    <select id="selectNormalChildrenDeptById" resultType="java.lang.Integer">
         select count(*)
         from sys_dept
         where status = 0
@@ -127,20 +127,31 @@
           and find_in_set(#{deptId}, ancestors)
     </select>
 
-    <select id="selectDownDeptListById"  resultMap="SysDeptResult">
-		SELECT *
-		FROM sys_dept WHERE STATUS = 0 AND del_flag = '0' AND parent_id = #{parentId} order by order_num asc
-	</select>
+    <select id="selectDownDeptListById" resultMap="SysDeptResult">
+        SELECT *
+        FROM sys_dept
+        WHERE STATUS = 0
+          AND del_flag = '0'
+          AND parent_id = #{parentId}
+        order by order_num asc
+    </select>
 
-    <select id="selectMaxNumChildrenDeptById"  resultType="java.lang.Integer">
-		SELECT CASE WHEN MAX(order_num) IS NOT NULL THEN MAX(order_num)+1 ELSE 0 END
-		FROM sys_dept WHERE STATUS = 0 AND del_flag = '0' AND parent_id = #{parentId}
-	</select>
+    <select id="selectMaxNumChildrenDeptById" resultType="java.lang.Integer">
+        SELECT CASE WHEN MAX(order_num) IS NOT NULL THEN MAX(order_num) + 1 ELSE 0 END
+        FROM sys_dept
+        WHERE STATUS = 0
+          AND del_flag = '0'
+          AND parent_id = #{parentId}
+    </select>
 
-    <select id="selectChildrenDeptListById"  resultMap="SysDeptResult">
-		SELECT dt.* FROM sys_dept dt WHERE dt.STATUS = 0 AND dt.del_flag = '0'
-        AND FIND_IN_SET(#{deptId}, dt.ancestors) ORDER BY dt.order_num ASC
-	</select>
+    <select id="selectChildrenDeptListById" resultMap="SysDeptResult">
+        SELECT dt.*
+        FROM sys_dept dt
+        WHERE dt.STATUS = 0
+          AND dt.del_flag = '0'
+          AND FIND_IN_SET(#{deptId}, dt.ancestors)
+        ORDER BY dt.order_num ASC
+    </select>
 
     <select id="checkDeptNameUnique" resultMap="SysDeptResult">
         <include refid="selectDeptVo"/>
@@ -149,7 +160,7 @@
         <if test="delFlag != null and delFlag != ''">
             AND del_flag = #{delFlag}
         </if>
-         limit 1
+        limit 1
     </select>
 
     <select id="getDeptNameUnique" resultMap="SysDeptResult">
@@ -184,21 +195,27 @@
     </select>
 
     <select id="selectLevelByUserId" resultType="java.lang.Integer">
-        select count(1) from sys_dept where dept_id = (select dept_id from sys_user where user_id = #{userId} and user_type = '11' limit 1) and parent_id = 0
+        select count(1)
+        from sys_dept
+        where dept_id = (select dept_id from sys_user where user_id = #{userId} and user_type = '11' limit 1)
+          and parent_id = 0
     </select>
 
     <select id="queryDeptSignByUserId" resultType="java.lang.String">
-        select
-               case when a.dept_sign is not null then a.dept_sign
-                when (select dept_sign from sys_dept where dept_id = a.parent_id and is_lower = 1) is not null
-                    then (select dept_sign from sys_dept where dept_id = a.parent_id and is_lower = 1)
-                else (select dept_sign from sys_dept where dept_id = replace(replace(a.ancestors, concat(',', a.parent_id), ''), '0,', '') and is_lower = 1)
-                end
+        select case
+                   when a.dept_sign is not null then a.dept_sign
+                   when (select dept_sign from sys_dept where dept_id = a.parent_id and is_lower = 1) is not null
+                       then (select dept_sign from sys_dept where dept_id = a.parent_id and is_lower = 1)
+                   else (select dept_sign
+                         from sys_dept
+                         where dept_id = replace(replace(a.ancestors, concat(',', a.parent_id), ''), '0,', '')
+                           and is_lower = 1)
+                   end
         from (
                  select dept_sign, dept_id, parent_id, ancestors
                  from sys_dept
                  where dept_id = (select dept_id from sys_user where user_id = #{userId})
-             )a
+             ) a
     </select>
     <select id="selectDeptListByCollege" resultType="com.zd.model.entity.SysDept">
         <include refid="selectDeptVo"/>
@@ -214,21 +231,64 @@
         order by d.parent_id, d.order_num
     </select>
     <select id="treeDeptSubSel" resultType="com.zd.model.entity.SysDept">
-        select d.* from (
-            select d.dept_id,d.parent_id,
-                  ( select sd.dept_name from sys_dept sd where sd.dept_id=d.parent_id) parent_name,
-                   d.ancestors,d.dept_name,d.del_flag,1 subOrDept,d.dept_id subOrDeptId
-            from sys_dept d
-
-            union all
-
-            select concat(10000,s.id) dept_id,s.build_id parent_id,
-                   (select dept_name from sys_dept sd where sd.dept_id=s.build_id) parent_name,
-                   (select dt.ancestors
-            from sys_dept dt where dt.dept_id = s.build_id) ancestors,s.name dept_name,s.is_del del_flag,2 subOrDept,s.id subOrDeptId
-            from lab_subject s
-        )d
-        where d.del_flag = '0'
+        select
+        case when d.subOrDept=1 then d.dept_id else concat(10000,d.dept_id) END dept_id,
+        d.parent_id,
+        d.parent_name,
+        d.ancestors,
+        d.dept_name,
+        d.del_flag,
+        d.subOrDept,
+        d.dept_id
+        FROM
+        (
+        SELECT
+        d.dept_id,
+        d.parent_id,
+        (
+        SELECT
+        sd.dept_name
+        FROM
+        sys_dept sd
+        WHERE
+        sd.dept_id = d.parent_id
+        ) parent_name,
+        d.ancestors,
+        d.dept_name,
+        d.del_flag,
+        1 subOrDept,
+        d.dept_id subOrDeptId
+        FROM
+        sys_dept d
+        UNION ALL
+        SELECT
+        s.dept_id dept_id,
+        s.build_id parent_id,
+        (
+        SELECT
+        dept_name
+        FROM
+        sys_dept sd
+        WHERE
+        sd.dept_id = s.build_id
+        ) parent_name,
+        (
+        SELECT
+        dt.ancestors
+        FROM
+        sys_dept dt
+        WHERE
+        dt.dept_id = s.build_id
+        ) ancestors,
+        s. NAME dept_name,
+        s.is_del del_flag,
+        2 subOrDept,
+        s.id subOrDeptId
+        FROM
+        lab_subject s
+        ) d
+        WHERE
+        d.del_flag = '0'
         <if test="parentId != null and parentId != 0">
             AND d.parent_id = #{parentId}
         </if>
@@ -304,14 +364,14 @@
         </foreach>
     </update>
 
-    <update id="updateDeptStatusNormal" >
+    <update id="updateDeptStatusNormal">
         update sys_dept set status = '0' where dept_id in
         <foreach collection="array" item="deptId" open="(" separator="," close=")">
             #{deptId}
         </foreach>
     </update>
 
-    <delete id="deleteDeptById" >
+    <delete id="deleteDeptById">
         update sys_dept
         set del_flag = '2'
         where dept_id = #{deptId}