mirror of https://gitee.com/stylefeng/roses
【7.2.3】增加获取公司下所有部门接口
parent
4734215e97
commit
da90444889
|
@ -62,4 +62,13 @@ public interface OrganizationServiceApi {
|
||||||
* @date 2022/6/8 14:40
|
* @date 2022/6/8 14:40
|
||||||
*/
|
*/
|
||||||
List<OrganizationTreeNode> getOrgTreeList(HrOrganizationRequest hrOrganizationRequest);
|
List<OrganizationTreeNode> getOrgTreeList(HrOrganizationRequest hrOrganizationRequest);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取某个公司下,所有部门树的集合
|
||||||
|
*
|
||||||
|
* @author fengshuonan
|
||||||
|
* @date 2022/6/16 18:26
|
||||||
|
*/
|
||||||
|
List<OrganizationTreeNode> getDeptOrgTree(Long orgId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -213,4 +213,16 @@ public class HrOrganizationController {
|
||||||
return new SuccessResponseData<>(list);
|
return new SuccessResponseData<>(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取某个公司下部门的机构树
|
||||||
|
*
|
||||||
|
* @author fengshuonan
|
||||||
|
* @date 2021/1/9 18:37
|
||||||
|
*/
|
||||||
|
@GetResource(name = "获取某个公司下部门的机构树", path = "/hrOrganization/getDeptOrgTree")
|
||||||
|
public ResponseData<List<OrganizationTreeNode>> getDeptOrgTree(@Validated(HrOrganizationRequest.detail.class) HrOrganizationRequest hrOrganizationRequest) {
|
||||||
|
List<OrganizationTreeNode> list = hrOrganizationService.getDeptOrgTree(hrOrganizationRequest.getOrgId());
|
||||||
|
return new SuccessResponseData<>(list);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@ import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.stylefeng.roses.kernel.auth.api.context.LoginContext;
|
import cn.stylefeng.roses.kernel.auth.api.context.LoginContext;
|
||||||
import cn.stylefeng.roses.kernel.auth.api.enums.DataScopeTypeEnum;
|
import cn.stylefeng.roses.kernel.auth.api.enums.DataScopeTypeEnum;
|
||||||
|
import cn.stylefeng.roses.kernel.db.api.DbOperatorApi;
|
||||||
import cn.stylefeng.roses.kernel.db.api.context.DbOperatorContext;
|
import cn.stylefeng.roses.kernel.db.api.context.DbOperatorContext;
|
||||||
import cn.stylefeng.roses.kernel.db.api.factory.PageFactory;
|
import cn.stylefeng.roses.kernel.db.api.factory.PageFactory;
|
||||||
import cn.stylefeng.roses.kernel.db.api.factory.PageResultFactory;
|
import cn.stylefeng.roses.kernel.db.api.factory.PageResultFactory;
|
||||||
|
@ -94,6 +95,9 @@ public class HrOrganizationServiceImpl extends ServiceImpl<HrOrganizationMapper,
|
||||||
@Resource
|
@Resource
|
||||||
private ExpandApi expandApi;
|
private ExpandApi expandApi;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private DbOperatorApi dbOperatorApi;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void add(HrOrganizationRequest hrOrganizationRequest) {
|
public void add(HrOrganizationRequest hrOrganizationRequest) {
|
||||||
|
@ -388,6 +392,26 @@ public class HrOrganizationServiceImpl extends ServiceImpl<HrOrganizationMapper,
|
||||||
return new DefaultTreeBuildFactory<OrganizationTreeNode>().doTreeBuild(treeNodeList);
|
return new DefaultTreeBuildFactory<OrganizationTreeNode>().doTreeBuild(treeNodeList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<OrganizationTreeNode> getDeptOrgTree(Long orgId) {
|
||||||
|
|
||||||
|
// 获取该公司下所有的子部门id集合
|
||||||
|
Set<Long> deptIds = dbOperatorApi.findSubListByParentId("hr_organization", "org_pids", "org_id", orgId);
|
||||||
|
deptIds.add(orgId);
|
||||||
|
|
||||||
|
LambdaQueryWrapper<HrOrganization> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.in(HrOrganization::getOrgId, deptIds);
|
||||||
|
List<HrOrganization> hrOrganizationList = this.list(wrapper);
|
||||||
|
|
||||||
|
// 组装部门的树形节点
|
||||||
|
List<OrganizationTreeNode> treeNodeList = CollectionUtil.newArrayList();
|
||||||
|
for (HrOrganization hrOrganization : hrOrganizationList) {
|
||||||
|
OrganizationTreeNode treeNode = OrganizationFactory.parseOrganizationTreeNode(hrOrganization);
|
||||||
|
treeNodeList.add(treeNode);
|
||||||
|
}
|
||||||
|
return new DefaultTreeBuildFactory<OrganizationTreeNode>().doTreeBuild(treeNodeList);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建组织架构的通用条件查询wrapper
|
* 创建组织架构的通用条件查询wrapper
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue