|
@@ -126,16 +126,34 @@ public class DingServiceImpl implements DingService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void deleteStaff(String loginName) throws ApiException {
|
|
|
+ public void deleteStaff(String mobile) throws ApiException {
|
|
|
String accessToken = getDingTalkToken();
|
|
|
+ //获取员工信息
|
|
|
+ Map<String, Object> staffMap = new HashMap<>();
|
|
|
+ staffMap.put("access_token", accessToken);
|
|
|
+ staffMap.put("mobile", mobile);
|
|
|
+ String res = HttpUtil.get("https://oapi.dingtalk.com/user/get_by_mobile", staffMap);
|
|
|
+ System.out.println(res);
|
|
|
+ Map map = JSONUtil.toBean(res, Map.class);
|
|
|
+ String errCode = map.get("errcode").toString();
|
|
|
+ String errMsg = map.get("errmsg").toString();
|
|
|
+ if (!errCode.equals("0")) {
|
|
|
+ throw new ApiException(errMsg);
|
|
|
+ }
|
|
|
+ String userId = map.get("userid").toString();
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
Map<String, Object> paramMap = new HashMap<>();
|
|
|
paramMap.put("access_token", accessToken);
|
|
|
- paramMap.put("userid", loginName);
|
|
|
- String res = HttpUtil.post("https://oapi.dingtalk.com/topapi/v2/user/delete", paramMap);
|
|
|
- Map map = JSONUtil.toBean(res, Map.class);
|
|
|
- String errorCode = map.get("errcode").toString();
|
|
|
+ paramMap.put("userid", userId);
|
|
|
+ String resign = HttpUtil.post("https://oapi.dingtalk.com/topapi/v2/user/delete", paramMap);
|
|
|
+ Map resignMap = JSONUtil.toBean(resign, Map.class);
|
|
|
+ String errorCode = resignMap.get("errcode").toString();
|
|
|
if (!errorCode.equals("0")) {
|
|
|
- throw new ApiException(map.get("errmsg").toString());
|
|
|
+ throw new ApiException(resignMap.get("errmsg").toString());
|
|
|
}
|
|
|
}
|
|
|
|