mirror of https://gitee.com/stylefeng/roses
【7.2.5】【org】完善获取组织机构绑定人员列表
parent
8ff237fd15
commit
967698bdae
|
@ -155,4 +155,10 @@ public class SysUserDTO {
|
|||
@ChineseDescription("是否密码重试次数过多")
|
||||
private Boolean loginErrorCountFlag = false;
|
||||
|
||||
/**
|
||||
* 头像地址
|
||||
*/
|
||||
@ChineseDescription("头像地址")
|
||||
private String avatarUrl;
|
||||
|
||||
}
|
||||
|
|
|
@ -35,8 +35,8 @@ public class HrOrgApproverController {
|
|||
* @date 2022/09/13 23:15
|
||||
*/
|
||||
@GetResource(name = "获取组织机构审批人绑定列表", path = "/hrOrgApprover/getBindingList")
|
||||
public ResponseData<List<HrOrgApprover>> getBindingList() {
|
||||
return new SuccessResponseData<>(hrOrgApproverService.getBindingList());
|
||||
public ResponseData<List<HrOrgApprover>> getBindingList(@Validated(HrOrgApproverRequest.list.class) HrOrgApproverRequest hrOrgApproverRequest) {
|
||||
return new SuccessResponseData<>(hrOrgApproverService.getBindingList(hrOrgApproverRequest));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -34,6 +34,7 @@ public class HrOrgApproverRequest extends BaseRequest {
|
|||
* 组织机构id
|
||||
*/
|
||||
@ChineseDescription("组织机构id")
|
||||
@NotNull(message = "组织机构id不能为空", groups = list.class)
|
||||
private Long orgId;
|
||||
|
||||
/**
|
||||
|
|
|
@ -57,6 +57,6 @@ public interface HrOrgApproverService extends IService<HrOrgApprover> {
|
|||
* @author fengshuonan
|
||||
* @date 2022/09/13 23:15
|
||||
*/
|
||||
List<HrOrgApprover> getBindingList();
|
||||
List<HrOrgApprover> getBindingList(HrOrgApproverRequest hrOrgApproverRequest);
|
||||
|
||||
}
|
|
@ -3,7 +3,10 @@ package cn.stylefeng.roses.kernel.system.modular.organization.service.impl;
|
|||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.stylefeng.roses.kernel.rule.exception.base.ServiceException;
|
||||
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.modular.organization.entity.HrOrgApprover;
|
||||
import cn.stylefeng.roses.kernel.system.modular.organization.enums.HrOrgApproverExceptionEnum;
|
||||
import cn.stylefeng.roses.kernel.system.modular.organization.mapper.HrOrgApproverMapper;
|
||||
|
@ -13,8 +16,11 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 组织机构审批人业务实现层
|
||||
|
@ -25,6 +31,9 @@ import java.util.List;
|
|||
@Service
|
||||
public class HrOrgApproverServiceImpl extends ServiceImpl<HrOrgApproverMapper, HrOrgApprover> implements HrOrgApproverService {
|
||||
|
||||
@Resource
|
||||
private UserServiceApi userServiceApi;
|
||||
|
||||
@Override
|
||||
public void add(HrOrgApproverRequest hrOrgApproverRequest) {
|
||||
HrOrgApprover hrOrgApprover = new HrOrgApprover();
|
||||
|
@ -51,21 +60,34 @@ public class HrOrgApproverServiceImpl extends ServiceImpl<HrOrgApproverMapper, H
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<HrOrgApprover> getBindingList() {
|
||||
public List<HrOrgApprover> getBindingList(HrOrgApproverRequest hrOrgApproverRequest) {
|
||||
|
||||
// 获取当前系统一共有哪些组织审批人类型
|
||||
OrgApproverTypeEnum[] values = OrgApproverTypeEnum.values();
|
||||
|
||||
// 获取指定机构的绑定情况
|
||||
LambdaQueryWrapper<HrOrgApprover> hrOrgApproverLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
hrOrgApproverLambdaQueryWrapper.eq(HrOrgApprover::getOrgId, hrOrgApproverRequest.getOrgId());
|
||||
List<HrOrgApprover> orgTotalBindingList = this.list(hrOrgApproverLambdaQueryWrapper);
|
||||
|
||||
// 将每个类型的用户分组
|
||||
Map<Integer, List<HrOrgApprover>> groupingByUsers = orgTotalBindingList.stream().collect(Collectors.groupingBy(HrOrgApprover::getOrgApproverType));
|
||||
|
||||
ArrayList<HrOrgApprover> resultList = new ArrayList<>();
|
||||
for (OrgApproverTypeEnum orgApproverTypeEnum : values) {
|
||||
HrOrgApprover hrOrgApprover = new HrOrgApprover();
|
||||
|
||||
// 设置类型
|
||||
hrOrgApprover.setOrgApproverType(orgApproverTypeEnum.getCode());
|
||||
|
||||
// 获取改类型下有没有人
|
||||
List<HrOrgApprover> userList = groupingByUsers.get(orgApproverTypeEnum.getCode());
|
||||
List<BindUserItem> bindUserItems = this.convertUserItem(userList);
|
||||
|
||||
hrOrgApprover.setBindUserItemList(bindUserItems);
|
||||
resultList.add(hrOrgApprover);
|
||||
}
|
||||
|
||||
// 获取当前系统所有的绑定情况 todo
|
||||
List<HrOrgApprover> list = this.list();
|
||||
|
||||
return resultList;
|
||||
}
|
||||
|
||||
|
@ -105,4 +127,35 @@ public class HrOrgApproverServiceImpl extends ServiceImpl<HrOrgApproverMapper, H
|
|||
return queryWrapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将approver信息转化为用户详情信息
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2022/9/14 22:58
|
||||
*/
|
||||
private List<BindUserItem> convertUserItem(List<HrOrgApprover> userList) {
|
||||
|
||||
// 获取所有用户id
|
||||
List<Long> userIdList = userList.stream().map(HrOrgApprover::getUserId).collect(Collectors.toList());
|
||||
|
||||
if (ObjectUtil.isNotEmpty(userIdList)) {
|
||||
List<BindUserItem> users = new ArrayList<>();
|
||||
for (Long userId : userIdList) {
|
||||
BindUserItem bindUserItem = new BindUserItem();
|
||||
bindUserItem.setUserId(userId);
|
||||
|
||||
// 获取用户详情信息
|
||||
SysUserDTO sysUserDTO = userServiceApi.getUserInfoByUserId(userId);
|
||||
bindUserItem.setName(sysUserDTO.getRealName());
|
||||
bindUserItem.setAvatarUrl(sysUserDTO.getAvatarUrl());
|
||||
|
||||
users.add(bindUserItem);
|
||||
}
|
||||
return users;
|
||||
}
|
||||
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -895,6 +895,13 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|||
SysUser sysUser = this.getById(userId);
|
||||
if (ObjectUtil.isNotEmpty(sysUser)) {
|
||||
SysUserDTO result = BeanUtil.copyProperties(sysUser, SysUserDTO.class);
|
||||
|
||||
// 获取用户的头像地址
|
||||
String fileAuthUrl = fileInfoApi.getFileAuthUrl(sysUser.getAvatar());
|
||||
if (fileAuthUrl != null) {
|
||||
result.setAvatarUrl(fileAuthUrl);
|
||||
}
|
||||
|
||||
sysUserCacheOperatorApi.put(String.valueOf(userId), result);
|
||||
return result;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue