Bladeren bron

fix 修改疫苗权限查询

Administrator 3 jaren geleden
bovenliggende
commit
c56217a8dc

+ 1 - 1
boman-common/boman-common-datascope/src/main/java/com/boman/common/datascope/aspect/DataScopeAspect.java

@@ -144,7 +144,7 @@ public class DataScopeAspect
             else if (DATA_SCOPE_DEPT_AND_CHILD.equals(dataScope))
             {
                 sqlString.append(StringUtils.format(
-                        " OR {}.id IN ( SELECT dept_id FROM sys_dept WHERE dept_id = {} or find_in_set( {} , ancestors ) )",
+                        " OR {}.id IN ( SELECT id FROM sys_dept WHERE id = {} or find_in_set( {} , ancestors ) )",
                         deptAlias, user.getDeptId(), user.getDeptId()));
             }
             else if (DATA_SCOPE_SELF.equals(dataScope))

+ 21 - 5
boman-modules/boman-system/src/main/java/com/boman/system/service/impl/SysDeptServiceImpl.java

@@ -3,9 +3,14 @@ package com.boman.system.service.impl;
 import java.util.*;
 import java.util.stream.Collectors;
 
+import com.boman.common.core.utils.SecurityUtils;
 import com.boman.common.core.utils.number.NumberUtils;
 import com.alibaba.fastjson.JSONObject;
 import com.boman.common.core.utils.obj.ObjectUtils;
+import com.boman.common.redis.service.RedisService;
+import com.boman.domain.SysUser;
+import com.boman.domain.constant.CacheConstants;
+import com.boman.system.api.model.LoginUser;
 import com.boman.system.mapper.SyncMapper;
 import com.google.common.collect.Lists;
 import com.sun.org.apache.regexp.internal.RE;
@@ -24,6 +29,8 @@ import com.boman.system.service.ISysDeptService;
 
 import javax.annotation.Resource;
 
+import static com.boman.common.datascope.aspect.DataScopeAspect.DATA_SCOPE_ALL;
+
 /**
  * 部门管理 服务实现
  *
@@ -37,6 +44,9 @@ public class SysDeptServiceImpl implements ISysDeptService {
     @Autowired
     private SysRoleMapper roleMapper;
 
+    @Resource
+    private RedisService redisService;
+
     /**
      * 查询部门管理数据
      *
@@ -46,15 +56,21 @@ public class SysDeptServiceImpl implements ISysDeptService {
     @Override
     @DataScope(deptAlias = "d")
     public List<SysDept> selectDeptList(SysDept dept) {
+        LoginUser loginUser = redisService.getCacheObject(CacheConstants.LOGIN_TOKEN_KEY + SecurityUtils.getToken());
+        SysUser sysUser = loginUser.getSysUser();
+        List<SysRole> roles = sysUser.getRoles();
+        dept.setListByParentId(Boolean.TRUE);
+        for (SysRole role : roles) {
+            String dataScope = role.getDataScope();
+            if (DATA_SCOPE_ALL.equals(dataScope)){
+                dept.setListByParentId(Boolean.FALSE);
+            }
+        }
         if (StringUtils.isNotEmpty(dept.getDeptName()) || StringUtils.isNotEmpty(dept.getStatus())) {
-            dept.setListByParentId(Boolean.TRUE);
             return deptMapper.selectDeptList(dept);
         }
         Long id = dept.getId();
-        if (id == null) {
-            dept.setListByParentId(Boolean.FALSE);
-        } else {
-            dept.setListByParentId(Boolean.TRUE);
+        if (id != null) {
             dept.setParentId(id);
         }
         List<SysDept> depts = deptMapper.selectDeptList(dept);

+ 2 - 0
boman-web-core/src/main/java/com/boman/web/core/service/vaccineInfo/impl/AdministrativeInfoServiceImpl.java

@@ -2,6 +2,7 @@ package com.boman.web.core.service.vaccineInfo.impl;
 
 import com.boman.common.core.utils.ServletUtils;
 import com.boman.common.core.utils.StringUtils;
+import com.boman.common.datascope.annotation.DataScope;
 import com.boman.common.security.service.TokenService;
 import com.boman.domain.SysDept;
 import com.boman.domain.SysUser;
@@ -36,6 +37,7 @@ public class AdministrativeInfoServiceImpl implements AdministrativeInfoService
      * @return
      */
     @Override
+    @DataScope(deptAlias = "d")
     public List<AdministrativeInfo> selectAdministrativeInfoList(AdministrativeInfo administrativeInfo) {
         List<AdministrativeInfo> administrativeInfos = administrativeInfoMapper.selectAdministrativeInfoList(administrativeInfo);
         return administrativeInfos;

+ 8 - 6
boman-web-core/src/main/resources/mapper/AdministrativeInfoMapper.xml

@@ -19,23 +19,25 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </resultMap>
 
     <sql id="selectAdministrativeInfoVo">
-        select id,parent_id, dept_name as  administrative_name, status, create_by, create_time, update_by, update_time from sys_dept
+        select d.id,d.parent_id, d.dept_name as  administrative_name, d.status, d.create_by, d.create_time, d.update_by, d.update_time from sys_dept d
     </sql>
 
     <select id="selectAdministrativeInfoList" parameterType="com.boman.web.core.domain.AdministrativeInfo" resultMap="AdministrativeInfoResult">
         <include refid="selectAdministrativeInfoVo"/>
         <where>
-            del_flag = '0'
+            d.del_flag = '0'
         <if test="parentId != null and parentId != 0">
-            AND parent_id = #{parentId}
+            AND d.parent_id = #{parentId}
         </if>
         <if test="administrativeName != null and administrativeName != ''">
-            AND dept_name like concat('%', #{administrativeName}, '%')
+            AND d.dept_name like concat('%', #{administrativeName}, '%')
         </if>
         <if test="status != null and status != ''">
-            AND status = #{status}
+            AND d.status = #{status}
         </if>
         </where>
-        order by parent_id, order_num
+        <!-- 数据范围过滤 -->
+        ${params.dataScope}
+        order by d.parent_id, d.order_num
     </select>
 </mapper>