机构相关
This commit is contained in:
parent
710f442390
commit
033e030dc6
@ -6,6 +6,8 @@ import cn.iocoder.yudao.module.inspect.dal.dataobject.inspectorg.InspectOrgDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* tb_org Service 接口
|
||||
@ -52,4 +54,11 @@ public interface InspectOrgService {
|
||||
*/
|
||||
PageResult<InspectOrgDO> getInspectOrgPage(InspectOrgPageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 获取机构信息列表
|
||||
*
|
||||
* @param ids 机构ID集合
|
||||
* @return 机构信息列表
|
||||
*/
|
||||
List<InspectOrgDO> getOrgList(Collection<Long> ids);
|
||||
}
|
@ -17,6 +17,8 @@ import javax.annotation.Resource;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.tb.enums.ErrorCodeConstants.*;
|
||||
@ -127,4 +129,12 @@ public class InspectOrgServiceImpl implements InspectOrgService {
|
||||
return inspectOrgMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<InspectOrgDO> getOrgList(Collection<Long> ids) {
|
||||
if (ids == null || ids.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return inspectOrgMapper.selectBatchIds(ids);
|
||||
}
|
||||
|
||||
}
|
@ -8,8 +8,8 @@ import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
import cn.iocoder.yudao.module.inspect.dal.dataobject.inspectdepartment.InspectDepartmentDO;
|
||||
import cn.iocoder.yudao.module.inspect.service.inspectdepartment.InspectDepartmentService;
|
||||
import cn.iocoder.yudao.module.inspect.dal.dataobject.inspectorg.InspectOrgDO;
|
||||
import cn.iocoder.yudao.module.inspect.service.inspectorg.InspectOrgService;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.user.vo.user.*;
|
||||
import cn.iocoder.yudao.module.system.convert.user.UserConvert;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO;
|
||||
@ -49,7 +49,8 @@ public class UserController {
|
||||
@Resource
|
||||
private DeptService deptService;
|
||||
@Resource
|
||||
private InspectDepartmentService departmentService;
|
||||
private InspectOrgService orgService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "新增用户")
|
||||
@PreAuthorize("@ss.hasPermission('system:user:create')")
|
||||
@ -100,14 +101,11 @@ public class UserController {
|
||||
if (CollUtil.isEmpty(pageResult.getList())) {
|
||||
return success(new PageResult<>(pageResult.getTotal()));
|
||||
}
|
||||
// 拼接自己的科室数据
|
||||
List<InspectDepartmentDO> list = departmentService.getDeptList(convertList(pageResult.getList(), AdminUserDO::getDeptId));
|
||||
Map<String, InspectDepartmentDO> deptMap = CollectionUtils.convertMap(list, InspectDepartmentDO::getDepartmentCode);
|
||||
// 拼接机构数据
|
||||
List<InspectOrgDO> list = orgService.getOrgList(convertList(pageResult.getList(), AdminUserDO::getDeptId));
|
||||
Map<Long, InspectOrgDO> orgMap = CollectionUtils.convertMap(list, InspectOrgDO::getOrgid);
|
||||
|
||||
// 框架原本的拼接数据
|
||||
// Map<Long, DeptDO> deptMap = deptService.getDeptMap(
|
||||
// convertList(pageResult.getList(), AdminUserDO::getDeptId));
|
||||
return success(new PageResult<>(UserConvert.INSTANCE.convertdeptList(pageResult.getList(), deptMap),
|
||||
return success(new PageResult<>(UserConvert.INSTANCE.convertOrgList(pageResult.getList(), orgMap),
|
||||
pageResult.getTotal()));
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.inspect.dal.dataobject.inspectdepartment.InspectDepartmentDO;
|
||||
import cn.iocoder.yudao.module.inspect.dal.dataobject.inspectorg.InspectOrgDO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.dept.vo.dept.DeptSimpleRespVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.dept.vo.post.PostSimpleRespVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.permission.vo.role.RoleSimpleRespVO;
|
||||
@ -32,6 +33,9 @@ public interface UserConvert {
|
||||
default List<UserRespVO> convertdeptList(List<AdminUserDO> list, Map<String, InspectDepartmentDO> deptMap) {
|
||||
return CollectionUtils.convertList(list, user -> convertdept(user, deptMap.get(String.valueOf(user.getDeptId()))));
|
||||
}
|
||||
default List<UserRespVO> convertOrgList(List<AdminUserDO> list, Map<Long, InspectOrgDO> orgMap) {
|
||||
return CollectionUtils.convertList(list, user -> convertOrg(user, orgMap.get(user.getDeptId())));
|
||||
}
|
||||
default UserRespVO convert(AdminUserDO user, DeptDO dept) {
|
||||
UserRespVO userVO = BeanUtils.toBean(user, UserRespVO.class);
|
||||
if (dept != null) {
|
||||
@ -46,8 +50,13 @@ public interface UserConvert {
|
||||
}
|
||||
return userVO;
|
||||
}
|
||||
|
||||
|
||||
default UserRespVO convertOrg(AdminUserDO user, InspectOrgDO org) {
|
||||
UserRespVO userVO = BeanUtils.toBean(user, UserRespVO.class);
|
||||
if (org != null) {
|
||||
userVO.setDeptName(org.getOrgName());
|
||||
}
|
||||
return userVO;
|
||||
}
|
||||
|
||||
default List<UserSimpleRespVO> convertSimpleList(List<AdminUserDO> list, Map<Long, DeptDO> deptMap) {
|
||||
return CollectionUtils.convertList(list, user -> {
|
||||
|
Loading…
Reference in New Issue
Block a user