From 5af411aab1f942b77796967874703fd1c7b9ed01 Mon Sep 17 00:00:00 2001 From: yangwei <867012372@qq.com> Date: Mon, 28 Apr 2025 17:16:41 +0800 Subject: [PATCH] =?UTF-8?q?[feat]=201=E3=80=81=E4=BF=AE=E6=94=B9=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=9D=83=E9=99=90=E2=91=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BusinessAlertStatisticsServiceImpl.java | 41 ++++++++++++------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/dk-modules/business/src/main/java/org/dromara/business/service/impl/BusinessAlertStatisticsServiceImpl.java b/dk-modules/business/src/main/java/org/dromara/business/service/impl/BusinessAlertStatisticsServiceImpl.java index d4276b3..37b4cf6 100644 --- a/dk-modules/business/src/main/java/org/dromara/business/service/impl/BusinessAlertStatisticsServiceImpl.java +++ b/dk-modules/business/src/main/java/org/dromara/business/service/impl/BusinessAlertStatisticsServiceImpl.java @@ -12,6 +12,7 @@ import org.dromara.business.mapper.BusinessAlertMapper; import org.dromara.business.service.IBusinessAlertService; import org.dromara.business.service.IBusinessAlertStatisticsService; import org.dromara.common.core.exception.ServiceException; +import org.dromara.common.mybatis.enums.DataScopeType; import org.dromara.common.redis.utils.RedisUtils; import org.dromara.common.satoken.utils.LoginHelper; import org.dromara.system.api.RemoteDataScopeService; @@ -775,20 +776,32 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist } private void createPermissions(BusinessAlertBo businessAlertBo) { - Long roleId = Optional.ofNullable(LoginHelper.getLoginUser()) - .map(LoginUser::getRoles) - .filter(roles -> !roles.isEmpty()) - .map(List::getFirst) - .map(RoleDTO::getRoleId) - .orElse(null); - - String roleCustom = remoteDataScopeService.getRoleCustom(roleId); - if (roleCustom.equalsIgnoreCase("-1")){ - businessAlertBo.setDeptIdList(ListUtil.empty()); - }else { - businessAlertBo.setDeptIdList(Arrays.stream(roleCustom.split(",")) - .map(Long::parseLong) - .collect(Collectors.toList())); + RoleDTO roleDTO = LoginHelper.getLoginUser().getRoles().getFirst(); + + //自定义权限 + if (roleDTO.getDataScope().equalsIgnoreCase(DataScopeType.CUSTOM.getCode())){ + String roleCustom = remoteDataScopeService.getRoleCustom(roleDTO.getRoleId()); + if (roleCustom.equalsIgnoreCase("-1")){ + businessAlertBo.setDeptIdList(ListUtil.empty()); + }else { + businessAlertBo.setDeptIdList(Arrays.stream(roleCustom.split(",")) + .map(Long::parseLong) + .collect(Collectors.toList())); + } + } else if (roleDTO.getDataScope().equalsIgnoreCase(DataScopeType.DEPT_AND_CHILD.getCode())) { + //部门及其以下 + String deptAndChild = remoteDataScopeService.getDeptAndChild(LoginHelper.getDeptId()); + if (deptAndChild.equalsIgnoreCase("-1")){ + businessAlertBo.setDeptIdList(ListUtil.empty()); + }else { + businessAlertBo.setDeptIdList(Arrays.stream(deptAndChild.split(",")) + .map(Long::parseLong) + .collect(Collectors.toList())); + } + + } else if (roleDTO.getDataScope().equalsIgnoreCase(DataScopeType.DEPT.getCode())) { + //本部门 + businessAlertBo.setDeptIdList(List.of(LoginHelper.getDeptId())); } } }