Browse Source

[feat]

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

29
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,14 +776,11 @@ 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);
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 {
@ -790,5 +788,20 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist
.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()));
}
}
}

Loading…
Cancel
Save