mirror of https://gitee.com/stylefeng/roses
【7.6.0】【org】org详情增加上级名称字段
parent
81d6653dde
commit
c1ca7bda9c
|
@ -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.
|
||||
*
|
||||
* Guns采用APACHE 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 = "无上级机构";
|
||||
|
||||
}
|
|
@ -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) {
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue