mirror of https://gitee.com/stylefeng/roses
【7.2.5】【org】增加获取当前用户的上级部门负责人
parent
566f53600f
commit
01c78b3795
|
@ -1,5 +1,6 @@
|
|||
package cn.stylefeng.roses.kernel.system.modular.organization.controller;
|
||||
|
||||
import cn.stylefeng.roses.kernel.auth.api.context.LoginContext;
|
||||
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
|
||||
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
|
||||
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
|
||||
|
@ -63,4 +64,17 @@ public class HrOrgApproverController {
|
|||
return new SuccessResponseData<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前用户,指定部门负责人
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2022/9/18 14:46
|
||||
*/
|
||||
@GetResource(name = "获取当前用户,指定部门负责人", path = "/hrOrgApprover/getAssignOrgApprover")
|
||||
public ResponseData<List<Long>> getAssignOrgApprover(@Validated(HrOrgApproverRequest.getAssignOrgApprover.class) HrOrgApproverRequest hrOrgApproverRequest) {
|
||||
Long userId = LoginContext.me().getLoginUser().getUserId();
|
||||
List<Long> result = hrOrgApproverService.getUserOrgApprover(userId, hrOrgApproverRequest.getOrgApproverType(), hrOrgApproverRequest.getParentLevel());
|
||||
return new SuccessResponseData<>(result);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -53,4 +53,17 @@ public class HrOrgApproverRequest extends BaseRequest {
|
|||
@NotEmpty(message = "用户id集合不能为空", groups = {add.class})
|
||||
private List<Long> userIdList;
|
||||
|
||||
|
||||
/**
|
||||
* 上级负责人的级别,从0开始,0为同部门领导,1为上一级领导,以此类推
|
||||
*/
|
||||
@ChineseDescription("上级负责人的级别,从0开始,0为同部门领导,1为上一级领导,以此类推")
|
||||
private Integer parentLevel;
|
||||
|
||||
/**
|
||||
* 参数校验分组:获取指定部门的负责人
|
||||
*/
|
||||
public @interface getAssignOrgApprover {
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -52,4 +52,28 @@ public interface HrOrgApproverService extends IService<HrOrgApprover> {
|
|||
*/
|
||||
List<HrOrgApprover> getBindingList(HrOrgApproverRequest hrOrgApproverRequest);
|
||||
|
||||
/**
|
||||
* 获取指定用户的部门负责人
|
||||
*
|
||||
* @param userId 指定用户的部门负责人
|
||||
* @param orgApproverType 部门负责人类型
|
||||
* @param parentLevel 从0开始,0为获取指定用户同部门的领导,1为上一级部门的领导,以此类推
|
||||
* @return 用户的部门负责人id集合
|
||||
* @author fengshuonan
|
||||
* @date 2022/9/18 14:52
|
||||
*/
|
||||
List<Long> getUserOrgApprover(Long userId, Integer orgApproverType, Integer parentLevel);
|
||||
|
||||
/**
|
||||
* 获取指定部门的部门负责人
|
||||
*
|
||||
* @param deptId 指定部门id
|
||||
* @param orgApproverType 部门负责人类型
|
||||
* @param parentLevel 从0开始,0为获取指定同部门的领导,1为上一级部门的领导,以此类推
|
||||
* @return 负责人id集合
|
||||
* @author fengshuonan
|
||||
* @date 2022/9/18 14:52
|
||||
*/
|
||||
List<Long> getDeptOrgApprover(Long deptId, Integer orgApproverType, Integer parentLevel);
|
||||
|
||||
}
|
|
@ -2,10 +2,13 @@ package cn.stylefeng.roses.kernel.system.modular.organization.service.impl;
|
|||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.stylefeng.roses.kernel.rule.exception.base.ServiceException;
|
||||
import cn.stylefeng.roses.kernel.system.api.OrganizationServiceApi;
|
||||
import cn.stylefeng.roses.kernel.system.api.UserOrgServiceApi;
|
||||
import cn.stylefeng.roses.kernel.system.api.UserServiceApi;
|
||||
import cn.stylefeng.roses.kernel.system.api.enums.OrgApproverTypeEnum;
|
||||
import cn.stylefeng.roses.kernel.system.api.pojo.organization.BindUserItem;
|
||||
import cn.stylefeng.roses.kernel.system.api.pojo.user.SysUserDTO;
|
||||
import cn.stylefeng.roses.kernel.system.api.pojo.user.SysUserOrgDTO;
|
||||
import cn.stylefeng.roses.kernel.system.modular.organization.entity.HrOrgApprover;
|
||||
import cn.stylefeng.roses.kernel.system.modular.organization.enums.HrOrgApproverExceptionEnum;
|
||||
import cn.stylefeng.roses.kernel.system.modular.organization.mapper.HrOrgApproverMapper;
|
||||
|
@ -33,6 +36,13 @@ public class HrOrgApproverServiceImpl extends ServiceImpl<HrOrgApproverMapper, H
|
|||
@Resource
|
||||
private UserServiceApi userServiceApi;
|
||||
|
||||
@Resource
|
||||
private OrganizationServiceApi organizationServiceApi;
|
||||
|
||||
@Resource
|
||||
private UserOrgServiceApi userOrgServiceApi;
|
||||
|
||||
|
||||
@Override
|
||||
public void bindUserList(HrOrgApproverRequest hrOrgApproverRequest) {
|
||||
|
||||
|
@ -142,6 +152,42 @@ public class HrOrgApproverServiceImpl extends ServiceImpl<HrOrgApproverMapper, H
|
|||
return resultList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Long> getUserOrgApprover(Long userId, Integer orgApproverType, Integer parentLevel) {
|
||||
|
||||
// 获取用户的所属机构id
|
||||
SysUserOrgDTO sysUserOrgDTO = userOrgServiceApi.getUserOrgByUserId(userId);
|
||||
Long orgId = sysUserOrgDTO.getOrgId();
|
||||
|
||||
// 用户没有机构,则返回空
|
||||
if (ObjectUtil.isEmpty(orgId)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
// 获取指定部门的负责人id信息
|
||||
return getDeptOrgApprover(orgId, orgApproverType, parentLevel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Long> getDeptOrgApprover(Long deptId, Integer orgApproverType, Integer parentLevel) {
|
||||
|
||||
// 根据参数的级别,获取组织机构的父级机构
|
||||
Long parentLevelOrgId = this.organizationServiceApi.getParentLevelOrgId(deptId, parentLevel);
|
||||
|
||||
// 如果没有上级组织机构,则直接返回为空
|
||||
if (ObjectUtil.isEmpty(parentLevelOrgId)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
// 获取该组织机构的指定类型的负责人
|
||||
LambdaQueryWrapper<HrOrgApprover> hrOrgApproverLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
hrOrgApproverLambdaQueryWrapper.eq(HrOrgApprover::getOrgId, parentLevelOrgId);
|
||||
hrOrgApproverLambdaQueryWrapper.eq(HrOrgApprover::getOrgApproverType, orgApproverType);
|
||||
List<HrOrgApprover> userList = this.list(hrOrgApproverLambdaQueryWrapper);
|
||||
|
||||
return userList.stream().map(HrOrgApprover::getUserId).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取信息
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue