|
@@ -141,32 +141,33 @@ public class DingTalkSyncUtil {
|
|
|
*/
|
|
|
private void processUser(UserDTO user, IUserApi userApi, String accountToken, String assessToken) {
|
|
|
try {
|
|
|
- String token = "10003".equals(user.getTenantDTO().getId()) ? accountToken : assessToken;
|
|
|
- DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/v2/user/getbymobile");
|
|
|
-
|
|
|
- OapiV2UserGetbymobileRequest req = new OapiV2UserGetbymobileRequest();
|
|
|
- req.setMobile(user.getMobile());
|
|
|
- String body = client.execute(req, token).getBody();
|
|
|
- JSONObject jsonObject = JSONUtil.parseObj(body);
|
|
|
- if (!"0".equals(jsonObject.getStr("errcode"))) {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- String ddUserId = jsonObject.getJSONObject("result").getStr("userid");
|
|
|
-
|
|
|
- // 更新用户数据
|
|
|
- UserDTO userDTO = new UserDTO();
|
|
|
- userDTO.setDdId(ddUserId);
|
|
|
- userDTO.setId(user.getId());
|
|
|
- userApi.updateUserById(userDTO);
|
|
|
-
|
|
|
- // 更新入职登记数据
|
|
|
- EnrollmentRegistration enrollmentRegistration = new EnrollmentRegistration();
|
|
|
- enrollmentRegistration.setUserId(user.getId());
|
|
|
- enrollmentRegistration.setDdId(ddUserId);
|
|
|
- enrollmentRegistrationService.updateDdIdById(enrollmentRegistration);
|
|
|
+ String token = "10003".equals(user.getTenantDTO().getId()) ? accountToken : assessToken;
|
|
|
+ DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/v2/user/getbymobile");
|
|
|
+ OapiV2UserGetbymobileRequest req = new OapiV2UserGetbymobileRequest();
|
|
|
+ req.setMobile(user.getMobile());
|
|
|
+ String body = client.execute(req, token).getBody();
|
|
|
+ JSONObject jsonObject = JSONUtil.parseObj(body);
|
|
|
+ String ddUserId = "";
|
|
|
+ UserDTO userDTO = new UserDTO();
|
|
|
+ EnrollmentRegistration enrollmentRegistration = new EnrollmentRegistration();
|
|
|
+ if ("0".equals(jsonObject.getStr("errcode"))) {
|
|
|
+ ddUserId = jsonObject.getJSONObject("result").getStr("userid");
|
|
|
+ userDTO.setDdId(ddUserId);
|
|
|
+ enrollmentRegistration.setDdId(ddUserId);
|
|
|
+ enrollmentRegistration.setDdType("1");
|
|
|
+ // 更新用户数据
|
|
|
+ userDTO.setId(user.getId());
|
|
|
+ userApi.updateUserById(userDTO);
|
|
|
+ } else {
|
|
|
+ //若用户不存在钉钉,则在
|
|
|
+ enrollmentRegistration.setDdType("0");
|
|
|
+ }
|
|
|
+ // 更新入职登记数据
|
|
|
+ enrollmentRegistration.setUserId(user.getId());
|
|
|
+ enrollmentRegistrationService.updateDdIdById(enrollmentRegistration);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
}
|