新增机构名称列表接口

This commit is contained in:
阿沐 2024-04-29 19:00:56 +08:00
parent 22689c3fee
commit e3aa1dec14
3 changed files with 35 additions and 10 deletions

View File

@ -84,4 +84,12 @@ public class SysOrgController {
return Result.ok(); return Result.ok();
} }
@PostMapping("nameList")
@Operation(summary = "名称列表")
public Result<List<String>> nameList(@RequestBody List<Long> idList) {
List<String> list = sysOrgService.getNameList(idList);
return Result.ok(list);
}
} }

View File

@ -24,7 +24,15 @@ public interface SysOrgService extends BaseService<SysOrgEntity> {
/** /**
* 根据机构ID获取子机构ID列表(包含本机构ID) * 根据机构ID获取子机构ID列表(包含本机构ID)
*
* @param id 机构ID * @param id 机构ID
*/ */
List<Long> getSubOrgIdList(Long id); List<Long> getSubOrgIdList(Long id);
/**
* 根据机构ID列表获取机构名称列表
*
* @param idList 机构ID列表
*/
List<String> getNameList(List<Long> idList);
} }

View File

@ -107,6 +107,15 @@ public class SysOrgServiceImpl extends BaseServiceImpl<SysOrgDao, SysOrgEntity>
return subIdList; return subIdList;
} }
@Override
public List<String> getNameList(List<Long> idList) {
if (idList.isEmpty()) {
return null;
}
return baseMapper.selectBatchIds(idList).stream().map(SysOrgEntity::getName).toList();
}
private void getTree(Long id, List<SysOrgEntity> orgList, List<Long> subIdList) { private void getTree(Long id, List<SysOrgEntity> orgList, List<Long> subIdList) {
for (SysOrgEntity org : orgList) { for (SysOrgEntity org : orgList) {
if (ObjectUtil.equals(org.getPid(), id)) { if (ObjectUtil.equals(org.getPid(), id)) {