mirror of https://gitee.com/stylefeng/roses
【SysUserOrg】方法优化
parent
1e7c08c1f5
commit
1b09a27578
|
@ -25,6 +25,6 @@ public interface UserOrgServiceApi {
|
|||
* @author fengshuonan
|
||||
* @date 2020/12/19 22:33
|
||||
*/
|
||||
SysUserOrgDTO getUserOrgInfo(Long userId);
|
||||
SysUserOrgDTO getUserOrgByUserId(Long userId);
|
||||
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ public class DataScopeService implements DataScopeApi {
|
|||
}
|
||||
|
||||
// 获取用户的主要部门信息
|
||||
SysUserOrgDTO sysUserOrgResponse = userOrgServiceApi.getUserOrgInfo(userId);
|
||||
SysUserOrgDTO sysUserOrgResponse = userOrgServiceApi.getUserOrgByUserId(userId);
|
||||
|
||||
// 获取角色中的数据范围类型
|
||||
Set<DataScopeTypeEnum> dataScopeTypeEnums = sysRoles.stream().map(SysRoleDTO::getDataScopeTypeEnum).collect(Collectors.toSet());
|
||||
|
|
|
@ -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<SysUserOrgMapper, SysUserOrg> implements SysUserOrgService {
|
||||
|
||||
@Override
|
||||
public SysUserOrgDTO getUserOrgInfo(Long userId) {
|
||||
public SysUserOrgDTO getUserOrgByUserId(Long userId) {
|
||||
|
||||
LambdaQueryWrapper<SysUserOrg> sysUserOrgLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
sysUserOrgLambdaQueryWrapper.eq(SysUserOrg::getUserId, userId);
|
||||
|
||||
List<SysUserOrg> 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<SysUserOrgMapper,
|
|||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void edit(Long userId, Long orgId, Long positionId) {
|
||||
UserOrgRequest userOrgResponse = new UserOrgRequest();
|
||||
userOrgResponse.setUserId(userId);
|
||||
userOrgResponse.setOrgId(orgId);
|
||||
userOrgResponse.setPositionId(positionId);
|
||||
|
||||
// 删除已有
|
||||
this.delByUserId(userId);
|
||||
|
||||
// 新增
|
||||
this.add(userId, orgId, positionId);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public SysUserOrg detail(UserOrgRequest userOrgResponse) {
|
||||
LambdaQueryWrapper<SysUserOrg> queryWrapper = this.createWrapper(userOrgResponse);
|
||||
return this.getOne(queryWrapper, false);
|
||||
return this.getOne( this.createWrapper(userOrgResponse), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -159,7 +159,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> 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<SysUserMapper, SysUser> 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<SysUserMapper, SysUser> 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<SysUserMapper, SysUser> 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<SysUserMapper, SysUser> impl
|
|||
DataScopeDTO dataScopeResponse = dataScopeApi.getDataScope(userId, roleResponseList);
|
||||
|
||||
// 4. 获取用户的组织机构和职位信息
|
||||
SysUserOrgDTO userOrgInfo = sysUserOrgService.getUserOrgInfo(userId);
|
||||
SysUserOrgDTO userOrgInfo = sysUserOrgService.getUserOrgByUserId(userId);
|
||||
|
||||
// 5. 获取用户的所有资源url
|
||||
List<String> resourceCodeList = roleServiceApi.getRoleResourceCodeList(roleIds);
|
||||
|
|
Loading…
Reference in New Issue