提交 b078e4c6 authored 作者: 000516's avatar 000516

根据部门ID查询上级部门树

上级 1ffc538b
......@@ -122,7 +122,6 @@ public class FeiShuUtil {
public Department getDepartmentCorehr(String deptId) {
// 判断部门ID,如果是"od-"开头,部门ID类型为"open_department_id",否则为"people_corehr_department_id"
String departmentIdType = deptId.startsWith("od-") ? "open_department_id" : "people_corehr_department_id";
log.info("部门ID<{}>所属类型为:{}", deptId, departmentIdType);
String[] deptIds = new String[]{deptId};
try {
Client client = getClientLUZX();
......@@ -160,6 +159,32 @@ public class FeiShuUtil {
}
}
public DepartmentParentInfo[] getParentsDepartmentReq(String deptId){
// 延迟3s
String[] deptIds = new String[]{deptId};
String departmentIdType = deptId.startsWith("od-") ? "open_department_id" : "people_corehr_department_id";
try {
Client client = getClientLUZX();
ParentsDepartmentReq req = ParentsDepartmentReq.newBuilder()
.departmentIdType(departmentIdType)
.parentsDepartmentReqBody(ParentsDepartmentReqBody.newBuilder()
.departmentIdList(deptIds)
.build())
.build();
ParentsDepartmentResp resp = client.corehr().v2().department().parents(req);
if(!resp.success()) {
log.error("获取飞书人事部门上级树结构失效:code:{},msg:{},body{}",resp.getCode(),resp.getMsg(),new String(resp.getRawResponse().getBody(), UTF_8));
return null;
}
return resp.getData().getItems()[0].getParentDepartmentList();
} catch (Exception e) {
log.error("获取飞书人事部门上级树结构失效,停止执行!");
throw new RuntimeException(e);
}
}
/**
* 根据部门父编码获取子部门
* 公司编码:"0"
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论