Browse Source

[feat]

1、修改数据权限①
pull/4/head
杨威 2 months ago
parent
commit
5af411aab1
  1. 41
      dk-modules/business/src/main/java/org/dromara/business/service/impl/BusinessAlertStatisticsServiceImpl.java

41
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.IBusinessAlertService;
import org.dromara.business.service.IBusinessAlertStatisticsService; import org.dromara.business.service.IBusinessAlertStatisticsService;
import org.dromara.common.core.exception.ServiceException; 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.redis.utils.RedisUtils;
import org.dromara.common.satoken.utils.LoginHelper; import org.dromara.common.satoken.utils.LoginHelper;
import org.dromara.system.api.RemoteDataScopeService; import org.dromara.system.api.RemoteDataScopeService;
@ -775,20 +776,32 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist
} }
private void createPermissions(BusinessAlertBo businessAlertBo) { private void createPermissions(BusinessAlertBo businessAlertBo) {
Long roleId = Optional.ofNullable(LoginHelper.getLoginUser()) RoleDTO roleDTO = LoginHelper.getLoginUser().getRoles().getFirst();
.map(LoginUser::getRoles)
.filter(roles -> !roles.isEmpty()) //自定义权限
.map(List::getFirst) if (roleDTO.getDataScope().equalsIgnoreCase(DataScopeType.CUSTOM.getCode())){
.map(RoleDTO::getRoleId) String roleCustom = remoteDataScopeService.getRoleCustom(roleDTO.getRoleId());
.orElse(null); if (roleCustom.equalsIgnoreCase("-1")){
businessAlertBo.setDeptIdList(ListUtil.empty());
String roleCustom = remoteDataScopeService.getRoleCustom(roleId); }else {
if (roleCustom.equalsIgnoreCase("-1")){ businessAlertBo.setDeptIdList(Arrays.stream(roleCustom.split(","))
businessAlertBo.setDeptIdList(ListUtil.empty()); .map(Long::parseLong)
}else { .collect(Collectors.toList()));
businessAlertBo.setDeptIdList(Arrays.stream(roleCustom.split(",")) }
.map(Long::parseLong) } else if (roleDTO.getDataScope().equalsIgnoreCase(DataScopeType.DEPT_AND_CHILD.getCode())) {
.collect(Collectors.toList())); //部门及其以下
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()));
} }
} }
} }

Loading…
Cancel
Save