mirror of https://gitee.com/stylefeng/roses
【8.0】【org】更新org名称的获取
parent
6d615425d5
commit
255fb40162
|
@ -0,0 +1,19 @@
|
||||||
|
package cn.stylefeng.roses.kernel.sys.api;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 组织机构信息的api
|
||||||
|
*
|
||||||
|
* @author fengshuonan
|
||||||
|
* @since 2023/7/14 16:47
|
||||||
|
*/
|
||||||
|
public interface OrganizationServiceApi {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取组织机构的名称,通过组织机构id
|
||||||
|
*
|
||||||
|
* @author fengshuonan
|
||||||
|
* @since 2023/7/14 16:47
|
||||||
|
*/
|
||||||
|
String getOrgNameById(Long orgId);
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
package cn.stylefeng.roses.kernel.sys.api.format;
|
||||||
|
|
||||||
|
import cn.hutool.core.convert.Convert;
|
||||||
|
import cn.hutool.extra.spring.SpringUtil;
|
||||||
|
import cn.stylefeng.roses.kernel.rule.format.BaseSimpleFieldFormatProcess;
|
||||||
|
import cn.stylefeng.roses.kernel.sys.api.OrganizationServiceApi;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取机构名称的处理
|
||||||
|
*
|
||||||
|
* @author fengshuonan
|
||||||
|
* @since 2023/7/14 16:46
|
||||||
|
*/
|
||||||
|
public class OrgNameFormatProcess extends BaseSimpleFieldFormatProcess {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<?> getItemClass() {
|
||||||
|
return Long.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object simpleItemFormat(Object businessId) {
|
||||||
|
|
||||||
|
if (businessId == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Long orgId = Convert.toLong(businessId);
|
||||||
|
|
||||||
|
OrganizationServiceApi organizationServiceApi = SpringUtil.getBean(OrganizationServiceApi.class);
|
||||||
|
|
||||||
|
return organizationServiceApi.getOrgNameById(orgId);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
package cn.stylefeng.roses.kernel.sys.modular.org.service;
|
package cn.stylefeng.roses.kernel.sys.modular.org.service;
|
||||||
|
|
||||||
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
||||||
|
import cn.stylefeng.roses.kernel.sys.api.OrganizationServiceApi;
|
||||||
import cn.stylefeng.roses.kernel.sys.api.pojo.org.CompanyDeptDTO;
|
import cn.stylefeng.roses.kernel.sys.api.pojo.org.CompanyDeptDTO;
|
||||||
import cn.stylefeng.roses.kernel.sys.modular.org.entity.HrOrganization;
|
import cn.stylefeng.roses.kernel.sys.modular.org.entity.HrOrganization;
|
||||||
import cn.stylefeng.roses.kernel.sys.modular.org.pojo.request.CommonOrgTreeRequest;
|
import cn.stylefeng.roses.kernel.sys.modular.org.pojo.request.CommonOrgTreeRequest;
|
||||||
|
@ -17,7 +18,7 @@ import java.util.Set;
|
||||||
* @author fengshuonan
|
* @author fengshuonan
|
||||||
* @date 2023/06/10 21:23
|
* @date 2023/06/10 21:23
|
||||||
*/
|
*/
|
||||||
public interface HrOrganizationService extends IService<HrOrganization> {
|
public interface HrOrganizationService extends IService<HrOrganization>, OrganizationServiceApi {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增
|
* 新增
|
||||||
|
|
|
@ -139,19 +139,8 @@ public class HrOrganizationServiceImpl extends ServiceImpl<HrOrganizationMapper,
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取机构的上级机构名称
|
// 获取机构的上级机构名称
|
||||||
if (TreeConstants.DEFAULT_PARENT_ID.equals(hrOrganization.getOrgParentId())) {
|
String parentOrgName = this.getOrgNameById(hrOrganization.getOrgParentId());
|
||||||
hrOrganization.setParentOrgName(OrgConstants.NONE_PARENT_ORG);
|
hrOrganization.setParentOrgName(parentOrgName);
|
||||||
} 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;
|
return hrOrganization;
|
||||||
}
|
}
|
||||||
|
@ -441,6 +430,29 @@ public class HrOrganizationServiceImpl extends ServiceImpl<HrOrganizationMapper,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getOrgNameById(Long orgId) {
|
||||||
|
|
||||||
|
if (TreeConstants.DEFAULT_PARENT_ID.equals(orgId)) {
|
||||||
|
return OrgConstants.NONE_PARENT_ORG;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ObjectUtil.isEmpty(orgId)) {
|
||||||
|
return OrgConstants.NONE_PARENT_ORG;
|
||||||
|
}
|
||||||
|
|
||||||
|
LambdaQueryWrapper<HrOrganization> hrOrganizationLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
hrOrganizationLambdaQueryWrapper.eq(HrOrganization::getOrgId, orgId);
|
||||||
|
hrOrganizationLambdaQueryWrapper.select(HrOrganization::getOrgName);
|
||||||
|
HrOrganization one = this.getOne(hrOrganizationLambdaQueryWrapper);
|
||||||
|
|
||||||
|
if (one != null) {
|
||||||
|
return one.getOrgName();
|
||||||
|
}
|
||||||
|
|
||||||
|
return OrgConstants.NONE_PARENT_ORG;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取信息
|
* 获取信息
|
||||||
*
|
*
|
||||||
|
@ -582,5 +594,4 @@ public class HrOrganizationServiceImpl extends ServiceImpl<HrOrganizationMapper,
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue