1. 新增查询所有本人加下属公司列表接口

This commit is contained in:
chenbowen
2025-09-18 16:37:20 +08:00
parent 377f5d7494
commit 79c1d5e6a4
8 changed files with 72 additions and 3 deletions

View File

@@ -32,7 +32,7 @@
<url>https://github.com/YunaiV/ruoyi-vue-pro</url>
<properties>
<revision>3.0.31</revision>
<revision>3.0.33</revision>
<!-- Maven 相关 -->
<java.version>17</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>

View File

@@ -26,7 +26,7 @@
<url>https://github.com/YunaiV/ruoyi-vue-pro</url>
<properties>
<revision>3.0.31</revision>
<revision>3.0.33</revision>
<flatten-maven-plugin.version>1.6.0</flatten-maven-plugin.version>
<!-- 统一依赖管理 -->
<spring.boot.version>3.4.5</spring.boot.version>

View File

@@ -46,6 +46,10 @@ public interface DeptApi {
@Operation(summary = "获得公司精简信息列表")
CommonResult<List<DeptSimpleRespDTO>> getSimpleCompanyList();
@GetMapping(PREFIX + "/all-company-list")
@Operation(summary = "获得所有公司精简信息列表")
CommonResult<List<DeptSimpleRespDTO>> getAllCompanyList();
@GetMapping(PREFIX + "/get")
@Operation(summary = "获得部门信息")
@Parameter(name = "id", description = "部门编号", example = "1024", required = true)

View File

@@ -66,6 +66,17 @@ public class DeptApiImpl implements DeptApi {
return success(BeanUtils.toBean(companies, DeptSimpleRespDTO.class));
}
@Override
public CommonResult<List<DeptSimpleRespDTO>> getAllCompanyList() {
List<DeptDO> allCompanies = deptService.getAllCompanyList();
// 还需要把用户归属的公司加上
List<DeptDO> userCompanyList = deptService.getUserCompanyList();
allCompanies.addAll(userCompanyList);
// 去重
List<DeptDO> companies = allCompanies.stream().distinct().toList();
return success(BeanUtils.toBean(companies, DeptSimpleRespDTO.class));
}
@Override
public CommonResult<DeptRespDTO> getDept(Long id) {
DeptDO dept = deptService.getDept(id);

View File

@@ -2,8 +2,10 @@ package cn.iocoder.yudao.module.system.controller.admin.dept;
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.CompanyDeptInfo;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
import cn.iocoder.yudao.module.system.api.dept.dto.CompanyDeptInfoRespDTO;
import cn.iocoder.yudao.module.system.controller.admin.dept.vo.dept.DeptListReqVO;
import cn.iocoder.yudao.module.system.controller.admin.dept.vo.dept.DeptRespVO;
import cn.iocoder.yudao.module.system.controller.admin.dept.vo.dept.DeptSaveReqVO;
@@ -20,6 +22,7 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Set;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@@ -78,12 +81,27 @@ public class DeptController {
}
@GetMapping(value = {"/list-company-simple", "/simple-company-list"})
@Operation(summary = "获取公司精简信息列表", description = "只包含被开启的部门,主要用于前端的下拉选项")
@Operation(summary = "获取用户所属公司精简信息列表", description = "只包含被开启的部门,主要用于前端的下拉选项")
public CommonResult<List<DeptSimpleRespVO>> getSimpleCompanyList() {
List<DeptDO> list = deptService.getUserCompanyList();
return success(BeanUtils.toBean(list, DeptSimpleRespVO.class));
}
@GetMapping(value = {"/list-all-company", "/all-company-list"})
@Operation(summary = "获取所有公司精简信息列表", description = "只包含被开启的公司部门,主要用于前端的下拉选项")
@PreAuthorize("@ss.hasPermission('system:dept:query')")
public CommonResult<List<DeptSimpleRespVO>> getAllCompanyList() {
List<DeptDO> list = deptService.getAllCompanyList();
// 还需要把用户归属的公司加上
List<DeptDO> userCompanyList = deptService.getUserCompanyList();
list.addAll(userCompanyList);
// 去重
list = list.stream().distinct().toList();
return success(BeanUtils.toBean(list, DeptSimpleRespVO.class));
}
@GetMapping("/top-level-list")
@Operation(summary = "获取顶级部门列表", description = "用于懒加载,只返回没有父部门的顶级部门")
@PreAuthorize("@ss.hasPermission('system:dept:query')")
@@ -110,4 +128,13 @@ public class DeptController {
return success(BeanUtils.toBean(dept, DeptRespVO.class));
}
@GetMapping("/company-dept-info")
@Operation(summary = "获得指定用户的公司部门信息")
@Parameter(name = "userId", description = "用户编号", required = true, example = "1")
@PreAuthorize("@ss.hasPermission('system:dept:query')")
public CommonResult<Set<CompanyDeptInfoRespDTO>> getCompanyDeptInfoListByUserId(@RequestParam("userId") Long userId) {
Set<CompanyDeptInfo> companyDeptInfos = deptService.getCompanyDeptInfoListByUserId(userId);
return success(BeanUtils.toBean(companyDeptInfos, CompanyDeptInfoRespDTO.class));
}
}

View File

@@ -98,4 +98,18 @@ public interface DeptMapper extends BaseMapperX<DeptDO> {
return selectOne(DeptDO::getCode, code);
}
/**
* 查询所有公司列表
*
* @param status 状态
* @return 公司列表
*/
default List<DeptDO> selectAllCompanyList(Integer status) {
return selectList(new LambdaQueryWrapperX<DeptDO>()
.eq(DeptDO::getIsCompany, true)
.eqIfPresent(DeptDO::getStatus, status)
.orderByAsc(DeptDO::getSort)
);
}
}

View File

@@ -135,4 +135,11 @@ public interface DeptService {
* @return 直接子部门列表
*/
List<DeptDO> getDirectChildDeptList(Long parentId);
/**
* 获取所有公司列表
*
* @return 公司列表
*/
List<DeptDO> getAllCompanyList();
}

View File

@@ -347,4 +347,10 @@ public class DeptServiceImpl implements DeptService {
return deptMapper.selectListByParentId(parentId, CommonStatusEnum.ENABLE.getStatus());
}
@Override
public List<DeptDO> getAllCompanyList() {
// 查询所有启用状态的公司部门
return deptMapper.selectAllCompanyList(CommonStatusEnum.ENABLE.getStatus());
}
}