fix(smartfactory): 修复用户数据权限导致的工厂列表获取问题
- 优化了工厂列表获取逻辑,确保用户可以正确获取其有权限访问的工厂信息 - 新增对自己所在工厂的判断和添加逻辑 - 修复了原代码中可能存在的空指针异常问题
This commit is contained in:
parent
a25bd59e00
commit
2462b89750
@ -233,20 +233,23 @@ public class FactoryInfoServiceImpl implements FactoryInfoService {
|
|||||||
@Override
|
@Override
|
||||||
public List<FactoryInfoDO> getFactoryListByAuthority() {
|
public List<FactoryInfoDO> getFactoryListByAuthority() {
|
||||||
|
|
||||||
List<Long> factoryIds = null;
|
List<Long> factoryIds = new ArrayList<>();
|
||||||
DeptDataPermissionRespDTO deptDataPermission = permissionApi.getDeptDataPermission(getLoginUserId()).getCheckedData();
|
DeptDataPermissionRespDTO deptDataPermission = permissionApi.getDeptDataPermission(getLoginUserId()).getCheckedData();
|
||||||
// 如果当前登录用户数据权限 不是查看全部数据
|
// 如果当前登录用户数据权限 不是查看全部数据
|
||||||
if (!deptDataPermission.getAll()) {
|
if (!deptDataPermission.getAll()) {
|
||||||
|
|
||||||
|
// 获取自己所在工厂
|
||||||
|
DeptRespDTO respDTO = deptApi.getDept(userApi.getUser(getLoginUserId()).getCheckedData().getDeptId()).getCheckedData();
|
||||||
|
if (respDTO != null && respDTO.getFactoryId() != null) {
|
||||||
|
factoryIds.add(respDTO.getFactoryId());
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查找担任负责人的工厂信息
|
||||||
List<DeptRespDTO> deptRespDTO = deptApi.getDeptByLeaderId(getLoginUserId()).getCheckedData();
|
List<DeptRespDTO> deptRespDTO = deptApi.getDeptByLeaderId(getLoginUserId()).getCheckedData();
|
||||||
|
|
||||||
if (deptRespDTO != null) {
|
if (deptRespDTO != null) {
|
||||||
|
|
||||||
factoryIds = convertList(deptRespDTO, DeptRespDTO::getFactoryId);
|
factoryIds.addAll(convertList(deptRespDTO, DeptRespDTO::getFactoryId));
|
||||||
} else {
|
|
||||||
|
|
||||||
DeptRespDTO respDTO = deptApi.getDept(userApi.getUser(getLoginUserId()).getCheckedData().getDeptId()).getCheckedData();
|
|
||||||
factoryIds = Collections.singletonList(respDTO.getFactoryId());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user