Browse Source

员工表钉钉同步

master
luoweijian 1 month ago
parent
commit
16808f7441
  1. 10
      src/main/java/com/project/ding/utils/DingUtil.java

10
src/main/java/com/project/ding/utils/DingUtil.java

@ -20,6 +20,9 @@ public class DingUtil {
@Autowired
private DtService dtService;
public List<DtDepart> getAllDepartment() throws Exception {
return dtService.getDepartmentService().list(null , true);
}
@ -36,7 +39,6 @@ public class DingUtil {
}
public List<DingUserDTO> getUserIdInDepartment(Long id) throws Exception {
List<DingUserDTO> res = new ArrayList<>();
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("dept_id" , id);
@ -45,9 +47,11 @@ public class DingUtil {
String url = dtService.getDtConfigStorage().getApiUrl("/topapi/v2/user/list");
String responseContent = dtService.post(url, jsonObject);
res.addAll(Try.of(() -> new ObjectMapper().convertValue(
List<DingUserDTO> res = new ArrayList<>(Try.of(() -> new ObjectMapper().convertValue(
JsonPath.read(responseContent, "$.result.list"),
new TypeReference<List<DingUserDTO>>() {})).getOrElse(new ArrayList<>()));
new TypeReference<List<DingUserDTO>>() {
})).getOrElse(new ArrayList<>()));
// 游标获取,hasMore判断是否存在下一页
Boolean hasMore = Try.of(() -> new ObjectMapper().convertValue(
JsonPath.read(responseContent, "$.result.has_more"),
new TypeReference<Boolean>() {})).getOrElse(Boolean.FALSE);

Loading…
Cancel
Save