|
|
|
@ -155,14 +155,14 @@ public class OrgPerson {
|
|
|
|
|
* @param zhiWei
|
|
|
|
|
* @throws ApiException
|
|
|
|
|
*/
|
|
|
|
|
public static void createPerson(String access_token, String deptId, int userId, String personName, String tel, String zhiWei) throws ApiException {
|
|
|
|
|
public static void createPerson(String access_token, long deptId, int userId, String personName, String tel, String zhiWei) throws ApiException {
|
|
|
|
|
DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/v2/user/create");
|
|
|
|
|
OapiV2UserCreateRequest req = new OapiV2UserCreateRequest();
|
|
|
|
|
req.setUserid(String.valueOf(userId));
|
|
|
|
|
req.setName(personName);
|
|
|
|
|
req.setMobile(tel);
|
|
|
|
|
req.setTitle(zhiWei);
|
|
|
|
|
req.setDeptIdList(deptId);
|
|
|
|
|
req.setDeptIdList(String.valueOf(deptId));
|
|
|
|
|
OapiV2UserCreateResponse rsp = client.execute(req, access_token);
|
|
|
|
|
System.out.println(rsp.getBody());
|
|
|
|
|
}
|
|
|
|
@ -174,18 +174,18 @@ public class OrgPerson {
|
|
|
|
|
* @param userId
|
|
|
|
|
* @throws ApiException
|
|
|
|
|
*/
|
|
|
|
|
public static void delPerson(String access_token, String userId) throws ApiException {
|
|
|
|
|
public static void delPerson(String access_token, int userId) throws ApiException {
|
|
|
|
|
DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/v2/user/delete");
|
|
|
|
|
OapiV2UserDeleteRequest req = new OapiV2UserDeleteRequest();
|
|
|
|
|
req.setUserid(userId);
|
|
|
|
|
req.setUserid(String.valueOf(userId));
|
|
|
|
|
OapiV2UserDeleteResponse rsp = client.execute(req, access_token);
|
|
|
|
|
//System.out.println(rsp.getBody());
|
|
|
|
|
System.out.println(rsp.getBody());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void updatePerson(String access_token, String person_id, String person_name) throws ApiException {
|
|
|
|
|
public static void updatePerson(String access_token, int person_id, String person_name) throws ApiException {
|
|
|
|
|
DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/v2/user/update");
|
|
|
|
|
OapiV2UserUpdateRequest req = new OapiV2UserUpdateRequest();
|
|
|
|
|
req.setUserid(person_id);
|
|
|
|
|
req.setUserid(String.valueOf(person_id));
|
|
|
|
|
req.setName(person_name);
|
|
|
|
|
OapiV2UserUpdateResponse rsp = client.execute(req, access_token);
|
|
|
|
|
System.out.println(rsp.getBody());
|
|
|
|
@ -253,13 +253,9 @@ public class OrgPerson {
|
|
|
|
|
int person_id = record.getInt("person_id");
|
|
|
|
|
String person_name = record.getStr("person_name");
|
|
|
|
|
String tel = record.getStr("tel");
|
|
|
|
|
//模拟处理一下手机号
|
|
|
|
|
if (StrKit.isBlank(tel) || !PhoneUtil.isMobile(tel)) {
|
|
|
|
|
tel = ChineseMobileNumberGenerator.getInstance().generate();//生成一个随机临时测试用的手机号
|
|
|
|
|
tel = "14" + tel.substring(2);//以14段开头,避开已存在的号码
|
|
|
|
|
}
|
|
|
|
|
tel = DingTalkCommon.getLawfulTel(tel);
|
|
|
|
|
long deptId = record.getLong("dingtalk_dept_id");
|
|
|
|
|
createPerson(accessToken, String.valueOf(deptId), person_id, person_name, tel, "教师");
|
|
|
|
|
createPerson(accessToken, deptId, person_id, person_name, tel, "教师");
|
|
|
|
|
//回写标识
|
|
|
|
|
Model.writePersonDingTalkId(person_id);
|
|
|
|
|
|
|
|
|
@ -281,7 +277,7 @@ public class OrgPerson {
|
|
|
|
|
for (int i = 0; i < personList.size(); i++) {
|
|
|
|
|
String userid = personList.get(i).getStr("userid");
|
|
|
|
|
String person_name = personList.get(i).getStr("name");
|
|
|
|
|
delPerson(accessToken, userid);
|
|
|
|
|
delPerson(accessToken, Integer.parseInt(userid));
|
|
|
|
|
CommonUtil.Print("成功删除:" + person_name);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|