【7.6.0】【org】org详情增加上级名称字段

pull/57/head
fengshuonan 2023-06-28 22:45:10 +08:00
parent 81d6653dde
commit c1ca7bda9c
3 changed files with 77 additions and 5 deletions

View File

@ -0,0 +1,40 @@
/*
* Copyright [2020-2030] [https://www.stylefeng.cn]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* GunsAPACHE LICENSE 2.0使
*
* 1.LICENSE
* 2.Guns
* 3.
* 4. https://gitee.com/stylefeng/guns
* 5. https://gitee.com/stylefeng/guns
* 6.
*/
package cn.stylefeng.roses.kernel.sys.modular.org.constants;
/**
*
*
* @author fengshuonan
* @since 2023/6/28 22:44
*/
public interface OrgConstants {
/**
*
*/
String NONE_PARENT_ORG = "无上级机构";
}

View File

@ -133,6 +133,13 @@ public class HrOrganization extends BaseExpandFieldEntity implements AbstractTre
@ChineseDescription("子节点的集合")
private List<HrOrganization> children;
/**
* id
*/
@TableField(exist = false)
@ChineseDescription("父级id的名称")
private String parentOrgName;
@Override
public String getNodeId() {
if (this.orgId == null) {

View File

@ -6,7 +6,6 @@ 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;
@ -20,6 +19,7 @@ import cn.stylefeng.roses.kernel.sys.api.enums.org.OrgTypeEnum;
import cn.stylefeng.roses.kernel.sys.api.exception.enums.OrgExceptionEnum;
import cn.stylefeng.roses.kernel.sys.api.pojo.org.CompanyDeptDTO;
import cn.stylefeng.roses.kernel.sys.api.pojo.user.UserOrgDTO;
import cn.stylefeng.roses.kernel.sys.modular.org.constants.OrgConstants;
import cn.stylefeng.roses.kernel.sys.modular.org.entity.HrOrganization;
import cn.stylefeng.roses.kernel.sys.modular.org.factory.OrganizationFactory;
import cn.stylefeng.roses.kernel.sys.modular.org.mapper.HrOrganizationMapper;
@ -63,9 +63,6 @@ public class HrOrganizationServiceImpl extends ServiceImpl<HrOrganizationMapper,
@Resource
private SysUserOrgService sysUserOrgService;
@Resource
private DbOperatorApi dbOperatorApi;
@Override
public void add(HrOrganizationRequest hrOrganizationRequest) {
HrOrganization hrOrganization = new HrOrganization();
@ -120,7 +117,35 @@ public class HrOrganizationServiceImpl extends ServiceImpl<HrOrganizationMapper,
@Override
public HrOrganization detail(HrOrganizationRequest hrOrganizationRequest) {
return this.queryHrOrganization(hrOrganizationRequest);
LambdaQueryWrapper<HrOrganization> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(HrOrganization::getOrgId, hrOrganizationRequest.getOrgId());
wrapper.select(HrOrganization::getOrgId, HrOrganization::getOrgName, HrOrganization::getOrgShortName, HrOrganization::getOrgCode,
HrOrganization::getOrgParentId, HrOrganization::getOrgSort, HrOrganization::getOrgType, HrOrganization::getStatusFlag,
HrOrganization::getTaxNo, HrOrganization::getRemark);
HrOrganization hrOrganization = this.getOne(wrapper, false);
if (ObjectUtil.isEmpty(hrOrganization)) {
throw new ServiceException(OrgExceptionEnum.HR_ORGANIZATION_NOT_EXISTED);
}
// 获取机构的上级机构名称
if (TreeConstants.DEFAULT_PARENT_ID.equals(hrOrganization.getOrgParentId())) {
hrOrganization.setParentOrgName(OrgConstants.NONE_PARENT_ORG);
} else {
LambdaQueryWrapper<HrOrganization> parentWrapper = new LambdaQueryWrapper<>();
parentWrapper.eq(HrOrganization::getOrgId, hrOrganization.getOrgParentId());
parentWrapper.select(HrOrganization::getOrgName);
HrOrganization parentInfo = this.getOne(parentWrapper, false);
if (parentInfo == null) {
hrOrganization.setParentOrgName(OrgConstants.NONE_PARENT_ORG);
} else {
hrOrganization.setParentOrgName(parentInfo.getOrgName());
}
}
return hrOrganization;
}
@Override