【7.2.5】【org】增加获取当前用户的上级部门负责人

pull/37/head
fengshuonan 2022-09-18 16:15:52 +08:00
parent 566f53600f
commit 01c78b3795
4 changed files with 97 additions and 0 deletions

View File

@ -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);
}
}

View File

@ -53,4 +53,17 @@ public class HrOrgApproverRequest extends BaseRequest {
@NotEmpty(message = "用户id集合不能为空", groups = {add.class})
private List<Long> userIdList;
/**
* 001
*/
@ChineseDescription("上级负责人的级别从0开始0为同部门领导1为上一级领导以此类推")
private Integer parentLevel;
/**
*
*/
public @interface getAssignOrgApprover {
}
}

View File

@ -52,4 +52,28 @@ public interface HrOrgApproverService extends IService<HrOrgApprover> {
*/
List<HrOrgApprover> getBindingList(HrOrgApproverRequest hrOrgApproverRequest);
/**
*
*
* @param userId
* @param orgApproverType
* @param parentLevel 001
* @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 001
* @return id
* @author fengshuonan
* @date 2022/9/18 14:52
*/
List<Long> getDeptOrgApprover(Long deptId, Integer orgApproverType, Integer parentLevel);
}

View File

@ -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());
}
/**
*
*