【8.0】【org】更新org名称的获取

pull/57/head
fengshuonan 2023-07-14 16:56:28 +08:00
parent 6d615425d5
commit 255fb40162
4 changed files with 81 additions and 15 deletions

View File

@ -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);
}

View File

@ -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);
}
}

View File

@ -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 {
/** /**
* *

View File

@ -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,
} }
} }
} }