【7.6.0】【sys】【org】更新组织机构的查询接口,增加一个orgId条件

pull/57/head
fengshuonan 2023-06-27 14:28:01 +08:00
parent c3e13291b5
commit 58fed480d7
1 changed files with 13 additions and 0 deletions

View File

@ -5,6 +5,7 @@ import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.spring.SpringUtil;
import cn.stylefeng.roses.kernel.auth.api.context.LoginContext;
import cn.stylefeng.roses.kernel.db.api.DbOperatorApi;
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.PageResultFactory;
@ -61,6 +62,9 @@ public class HrOrganizationServiceImpl extends ServiceImpl<HrOrganizationMapper,
@Resource
private SysUserOrgService sysUserOrgService;
@Resource
private DbOperatorApi dbOperatorApi;
@Override
public void add(HrOrganizationRequest hrOrganizationRequest) {
HrOrganization hrOrganization = new HrOrganization();
@ -303,6 +307,15 @@ public class HrOrganizationServiceImpl extends ServiceImpl<HrOrganizationMapper,
Integer statusFlag = hrOrganizationRequest.getStatusFlag();
queryWrapper.eq(ObjectUtil.isNotNull(statusFlag), HrOrganization::getStatusFlag, statusFlag);
// 如果查询条件有orgId则查询指定机构下的子机构
Long orgId = hrOrganizationRequest.getOrgId();
if (orgId != null) {
// 查询orgId对应的所有子机构包含本orgId
Set<Long> subOrgIdList = dbOperatorApi.findSubListByParentId("hr_organization", "org_pids", "org_id", orgId);
subOrgIdList.add(orgId);
queryWrapper.nested(i -> i.in(HrOrganization::getOrgId, subOrgIdList));
}
// 根据排序正序查询
queryWrapper.orderByAsc(HrOrganization::getOrgSort);