diff --git a/kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/api/UserOrgServiceApi.java b/kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/api/UserOrgServiceApi.java index fa97794e6..52c9703a4 100644 --- a/kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/api/UserOrgServiceApi.java +++ b/kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/api/UserOrgServiceApi.java @@ -25,6 +25,6 @@ public interface UserOrgServiceApi { * @author fengshuonan * @date 2020/12/19 22:33 */ - SysUserOrgDTO getUserOrgInfo(Long userId); + SysUserOrgDTO getUserOrgByUserId(Long userId); } diff --git a/kernel-s-system/system-business-organization/src/main/java/cn/stylefeng/roses/kernel/system/modular/organization/service/DataScopeService.java b/kernel-s-system/system-business-organization/src/main/java/cn/stylefeng/roses/kernel/system/modular/organization/service/DataScopeService.java index 97704a9c7..15b447610 100644 --- a/kernel-s-system/system-business-organization/src/main/java/cn/stylefeng/roses/kernel/system/modular/organization/service/DataScopeService.java +++ b/kernel-s-system/system-business-organization/src/main/java/cn/stylefeng/roses/kernel/system/modular/organization/service/DataScopeService.java @@ -53,7 +53,7 @@ public class DataScopeService implements DataScopeApi { } // 获取用户的主要部门信息 - SysUserOrgDTO sysUserOrgResponse = userOrgServiceApi.getUserOrgInfo(userId); + SysUserOrgDTO sysUserOrgResponse = userOrgServiceApi.getUserOrgByUserId(userId); // 获取角色中的数据范围类型 Set dataScopeTypeEnums = sysRoles.stream().map(SysRoleDTO::getDataScopeTypeEnum).collect(Collectors.toSet()); diff --git a/kernel-s-system/system-business-user/src/main/java/cn/stylefeng/roses/kernel/system/modular/user/service/impl/SysUserOrgServiceServiceImpl.java b/kernel-s-system/system-business-user/src/main/java/cn/stylefeng/roses/kernel/system/modular/user/service/impl/SysUserOrgServiceServiceImpl.java index c1d65e768..a6d43142c 100644 --- a/kernel-s-system/system-business-user/src/main/java/cn/stylefeng/roses/kernel/system/modular/user/service/impl/SysUserOrgServiceServiceImpl.java +++ b/kernel-s-system/system-business-user/src/main/java/cn/stylefeng/roses/kernel/system/modular/user/service/impl/SysUserOrgServiceServiceImpl.java @@ -16,7 +16,6 @@ import org.springframework.transaction.annotation.Transactional; import java.util.List; -import static cn.stylefeng.roses.kernel.system.api.exception.enums.user.SysUserOrgExceptionEnum.EMPLOYEE_MANY_MAIN_NOT_FOUND; /** * 用户组织机构关联信息 @@ -28,20 +27,17 @@ import static cn.stylefeng.roses.kernel.system.api.exception.enums.user.SysUserO public class SysUserOrgServiceServiceImpl extends ServiceImpl implements SysUserOrgService { @Override - public SysUserOrgDTO getUserOrgInfo(Long userId) { + public SysUserOrgDTO getUserOrgByUserId(Long userId) { - LambdaQueryWrapper sysUserOrgLambdaQueryWrapper = new LambdaQueryWrapper<>(); - sysUserOrgLambdaQueryWrapper.eq(SysUserOrg::getUserId, userId); - - List list = this.list(sysUserOrgLambdaQueryWrapper); - if (list.size() != 1) { - throw new SystemModularException(EMPLOYEE_MANY_MAIN_NOT_FOUND); - } else { - SysUserOrg sysUserOrg = list.get(0); - SysUserOrgDTO sysUserOrgResponse = new SysUserOrgDTO(); - BeanUtil.copyProperties(sysUserOrg, sysUserOrgResponse); - return sysUserOrgResponse; + UserOrgRequest userOrgRequest = new UserOrgRequest(); + userOrgRequest.setUserId(userId); + SysUserOrg sysUserOrg = this.detail(userOrgRequest); + if(ObjectUtil.isEmpty(sysUserOrg)){ + throw new SystemModularException(SysUserOrgExceptionEnum.EMPLOYEE_MANY_MAIN_NOT_FOUND); } + SysUserOrgDTO sysUserOrgDTO = new SysUserOrgDTO(); + BeanUtil.copyProperties(sysUserOrg, sysUserOrgDTO); + return sysUserOrgDTO; } @@ -84,22 +80,16 @@ public class SysUserOrgServiceServiceImpl extends ServiceImpl queryWrapper = this.createWrapper(userOrgResponse); - return this.getOne(queryWrapper, false); + return this.getOne( this.createWrapper(userOrgResponse), false); } @Override diff --git a/kernel-s-system/system-business-user/src/main/java/cn/stylefeng/roses/kernel/system/modular/user/service/impl/SysUserServiceImpl.java b/kernel-s-system/system-business-user/src/main/java/cn/stylefeng/roses/kernel/system/modular/user/service/impl/SysUserServiceImpl.java index 54b268dd4..406691ab5 100644 --- a/kernel-s-system/system-business-user/src/main/java/cn/stylefeng/roses/kernel/system/modular/user/service/impl/SysUserServiceImpl.java +++ b/kernel-s-system/system-business-user/src/main/java/cn/stylefeng/roses/kernel/system/modular/user/service/impl/SysUserServiceImpl.java @@ -159,7 +159,7 @@ public class SysUserServiceImpl extends ServiceImpl impl } // 获取被授权用户的所属机构 - SysUserOrgDTO userOrgInfo = sysUserOrgService.getUserOrgInfo(sysUser.getUserId()); + SysUserOrgDTO userOrgInfo = sysUserOrgService.getUserOrgByUserId(sysUser.getUserId()); Long organizationId = userOrgInfo.getOrgId(); // 判断当前用户有无该用户的权限 @@ -318,7 +318,7 @@ public class SysUserServiceImpl extends ServiceImpl impl SysUser sysUser = this.querySysUser(sysUserRequest); // 获取要授权角色的用户的所属机构 - SysUserOrgDTO userOrgInfo = sysUserOrgService.getUserOrgInfo(sysUser.getUserId()); + SysUserOrgDTO userOrgInfo = sysUserOrgService.getUserOrgByUserId(sysUser.getUserId()); Long organizationId = userOrgInfo.getOrgId(); // 判断当前用户有无该用户的权限 @@ -334,7 +334,7 @@ public class SysUserServiceImpl extends ServiceImpl impl SysUser sysUser = this.querySysUser(sysUserRequest); // 获取被授权用户的所属机构 - SysUserOrgDTO userOrgInfo = sysUserOrgService.getUserOrgInfo(sysUser.getUserId()); + SysUserOrgDTO userOrgInfo = sysUserOrgService.getUserOrgByUserId(sysUser.getUserId()); Long organizationId = userOrgInfo.getOrgId(); // 判断当前用户有无该用户的权限 @@ -352,7 +352,7 @@ public class SysUserServiceImpl extends ServiceImpl impl BeanUtil.copyProperties(sysUser, sysUserResponse); // 获取用户组织绑定信息 - SysUserOrgDTO userOrgInfo = sysUserOrgService.getUserOrgInfo(sysUser.getUserId()); + SysUserOrgDTO userOrgInfo = sysUserOrgService.getUserOrgByUserId(sysUser.getUserId()); sysUserResponse.setOrgId(userOrgInfo.getOrgId()); sysUserResponse.setPositionId(userOrgInfo.getPositionId()); @@ -504,7 +504,7 @@ public class SysUserServiceImpl extends ServiceImpl impl DataScopeDTO dataScopeResponse = dataScopeApi.getDataScope(userId, roleResponseList); // 4. 获取用户的组织机构和职位信息 - SysUserOrgDTO userOrgInfo = sysUserOrgService.getUserOrgInfo(userId); + SysUserOrgDTO userOrgInfo = sysUserOrgService.getUserOrgByUserId(userId); // 5. 获取用户的所有资源url List resourceCodeList = roleServiceApi.getRoleResourceCodeList(roleIds);