main
黄海 2 years ago
parent 1c98acb167
commit 660c7955ff

@ -1,11 +1,11 @@
package UnitTest;
import com.alibaba.druid.filter.stat.StatFilter;
import com.dsideal.FengHuang.DingTalk.OrgPerson;
import com.dsideal.FengHuang.Util.CommonUtil;
import com.dsideal.FengHuang.Util.DingTalkUtil;
import com.dsideal.FengHuang.DingTalk.Common;
import com.jfinal.kit.PropKit;
import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
import com.jfinal.plugin.activerecord.Record;
import com.jfinal.plugin.activerecord.dialect.MysqlDialect;
import com.jfinal.plugin.druid.DruidPlugin;
import com.jfinal.plugin.redis.RedisPlugin;
@ -57,19 +57,19 @@ public class TestDingTalk {
redis.start();
//accessToken
String accessToken = DingTalkUtil.getAccessToken(appKey, appSecret);
String accessToken = Common.getAccessToken(appKey, appSecret);
//同步钉钉与云平台中部门信息
String orgName = "长春市东光学校";
//同步组织机构
DingTalkUtil.syncOrg(accessToken, orgName);
OrgPerson.syncOrg(accessToken, orgName);
//删除单位下所有人员(开发测试时使用)
//DingTalkUtil.delBureauPerson(accessToken,orgName);
//同步人员
DingTalkUtil.syncPerson(accessToken,orgName);
OrgPerson.syncPerson(accessToken,orgName);
CommonUtil.Print("恭喜,所有操作成功完成!");
}

@ -0,0 +1,115 @@
package com.dsideal.FengHuang.DingTalk;
import com.aliyun.dingtalkoauth2_1_0.models.CreateJsapiTicketResponse;
import com.aliyun.dingtalkoauth2_1_0.models.GetAccessTokenResponse;
import com.aliyun.dingtalkoauth2_1_0.models.GetSsoAccessTokenRequest;
import com.aliyun.dingtalkoauth2_1_0.models.GetSsoAccessTokenResponse;
import com.aliyun.tea.TeaException;
import com.jfinal.plugin.redis.Redis;
public class Common {
/**
* 使 Token Client
*
* @return Client
* @throws Exception
*/
public static com.aliyun.dingtalkoauth2_1_0.Client createClient() throws Exception {
com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config();
config.protocol = "https";
config.regionId = "central";
return new com.aliyun.dingtalkoauth2_1_0.Client(config);
}
/*
AccessToken
2023-06-06
*/
public static String getAccessToken(String appKey, String appSecret) throws Exception {
final String KEY = "DingTalkAccessToken";
if (!Redis.use().exists(KEY)) {
String accessToken = null;
com.aliyun.dingtalkoauth2_1_0.Client client = createClient();
com.aliyun.dingtalkoauth2_1_0.models.GetAccessTokenRequest getAccessTokenRequest = new com.aliyun.dingtalkoauth2_1_0.models.GetAccessTokenRequest()
.setAppKey(appKey)
.setAppSecret(appSecret);
try {
GetAccessTokenResponse res = client.getAccessToken(getAccessTokenRequest);
accessToken = res.getBody().getAccessToken();
} catch (TeaException err) {
if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
}
} catch (Exception _err) {
TeaException err = new TeaException(_err.getMessage(), _err);
if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
}
}
Redis.use().setex(KEY, 5400, accessToken);//5400:一个半小时过期
return accessToken;
} else {
return Redis.use().get(KEY);
}
}
/*
JsApiToken->ticket
2023-06-06
*/
public static String getJsApiToken(String access_token) throws Exception {
final String KEY = "DingTalkJsApiToken";
if (!Redis.use().exists(KEY)) {
String jsApiToken = null;
com.aliyun.dingtalkoauth2_1_0.Client client = createClient();
com.aliyun.dingtalkoauth2_1_0.models.CreateJsapiTicketHeaders createJsapiTicketHeaders = new com.aliyun.dingtalkoauth2_1_0.models.CreateJsapiTicketHeaders();
createJsapiTicketHeaders.xAcsDingtalkAccessToken = access_token;
try {
CreateJsapiTicketResponse res = client.createJsapiTicketWithOptions(createJsapiTicketHeaders, new com.aliyun.teautil.models.RuntimeOptions());
jsApiToken = res.getBody().getJsapiTicket();
} catch (TeaException err) {
if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
}
} catch (Exception _err) {
TeaException err = new TeaException(_err.getMessage(), _err);
if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
}
}
Redis.use().setex(KEY, 5400, jsApiToken);//5400:一个半小时过期
return jsApiToken;
} else {
return Redis.use().get(KEY);
}
}
/*
SsoToken()
2023-06-06
*/
public static String getSsoToken(String corpId, String ssoSecret) throws Exception {
final String KEY = "DingTalkSsoToken";
if (!Redis.use().exists(KEY)) {
String ssoToken = null;
com.aliyun.dingtalkoauth2_1_0.Client client = createClient();
GetSsoAccessTokenRequest getSsoAccessTokenRequest = new GetSsoAccessTokenRequest()
.setCorpid(corpId)
.setSsoSecret(ssoSecret);
try {
GetSsoAccessTokenResponse res = client.getSsoAccessToken(getSsoAccessTokenRequest);
ssoToken = res.getBody().getAccessToken();
} catch (TeaException err) {
if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
}
} catch (Exception _err) {
TeaException err = new TeaException(_err.getMessage(), _err);
if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
}
}
Redis.use().setex(KEY, 5400, ssoToken);//5400:一个半小时过期
return ssoToken;
} else {
return Redis.use().get(KEY);
}
}
}

@ -0,0 +1,40 @@
package com.dsideal.FengHuang.DingTalk;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Record;
import java.util.List;
public class Model {
public static List<Record> getOrgList(int orgId) {
// 学校及学校下的部门
String sql = "select org_id,org_name,parent_id,sort_id,dingtalk_dept_id from t_base_organization where bureau_id=? and org_id<>bureau_id order by org_id";
List<Record> list = Db.find(sql, orgId);
return list;
}
public static List<Record> getDeptPerson(int bureau_id) {
String sql = "select t1.person_id,t1.person_name,t2.dingtalk_dept_id,t1.tel from t_base_person as t1 " +
"inner join t_base_organization as t2 on t1.org_id=t2.org_id " +
" where t1.bureau_id=? and t1.b_use=1";
return Db.find(sql, bureau_id);
}
public static void writeDtDeptId(int orgId, String value) {
String sql = "update t_base_organization set dingtalk_dept_id=? where org_id=?";
Db.update(sql, value, orgId);
}
public static long getDtDeptId(int org_id) {
String sql = "select dingtalk_dept_id from t_base_organization where org_id=?";
Record r = Db.findFirst(sql, org_id);
if (r.get("dingtalk_dept_id") == null) return 1;
return r.get("dingtalk_dept_id");
}
public static Record getOrgByOrgName(String org_name) {
String sql = "select org_id,org_name,sort_id,dingtalk_dept_id from t_base_organization where org_name = ?";
return Db.findFirst(sql, org_name);
}
}

@ -1,173 +1,26 @@
package com.dsideal.FengHuang.Util;
package com.dsideal.FengHuang.DingTalk;
import cn.binarywang.tools.generator.ChineseMobileNumberGenerator;
import cn.hutool.core.util.PhoneUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.aliyun.dingtalkoauth2_1_0.models.*;
import com.aliyun.dingtalkoauth2_1_0.models.GetUserTokenRequest;
import com.aliyun.dingtalkoauth2_1_0.models.GetUserTokenResponse;
import com.aliyun.tea.TeaException;
import com.aspose.slides.Collections.ArrayList;
import com.dingtalk.api.DefaultDingTalkClient;
import com.dingtalk.api.DingTalkClient;
import com.dingtalk.api.request.*;
import com.dingtalk.api.response.*;
import com.dsideal.FengHuang.Util.CommonUtil;
import com.jfinal.kit.Kv;
import com.jfinal.kit.StrKit;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Record;
import com.jfinal.plugin.redis.Redis;
import com.taobao.api.ApiException;
import java.util.*;
public class DingTalkUtil {
/**
* 使 Token Client
*
* @return Client
* @throws Exception
*/
private static com.aliyun.dingtalkoauth2_1_0.Client createClient() throws Exception {
com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config();
config.protocol = "https";
config.regionId = "central";
return new com.aliyun.dingtalkoauth2_1_0.Client(config);
}
/*
AccessToken
2023-06-06
*/
public static String getAccessToken(String appKey, String appSecret) throws Exception {
final String KEY = "DingTalkAccessToken";
if (!Redis.use().exists(KEY)) {
String accessToken = null;
com.aliyun.dingtalkoauth2_1_0.Client client = createClient();
com.aliyun.dingtalkoauth2_1_0.models.GetAccessTokenRequest getAccessTokenRequest = new com.aliyun.dingtalkoauth2_1_0.models.GetAccessTokenRequest()
.setAppKey(appKey)
.setAppSecret(appSecret);
try {
GetAccessTokenResponse res = client.getAccessToken(getAccessTokenRequest);
accessToken = res.getBody().getAccessToken();
} catch (TeaException err) {
if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
}
} catch (Exception _err) {
TeaException err = new TeaException(_err.getMessage(), _err);
if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
}
}
Redis.use().setex(KEY, 5400, accessToken);//5400:一个半小时过期
return accessToken;
} else {
return Redis.use().get(KEY);
}
}
/*
JsApiToken->ticket
2023-06-06
*/
public static String getJsApiToken(String access_token) throws Exception {
final String KEY = "DingTalkJsApiToken";
if (!Redis.use().exists(KEY)) {
String jsApiToken = null;
com.aliyun.dingtalkoauth2_1_0.Client client = createClient();
com.aliyun.dingtalkoauth2_1_0.models.CreateJsapiTicketHeaders createJsapiTicketHeaders = new com.aliyun.dingtalkoauth2_1_0.models.CreateJsapiTicketHeaders();
createJsapiTicketHeaders.xAcsDingtalkAccessToken = access_token;
try {
CreateJsapiTicketResponse res = client.createJsapiTicketWithOptions(createJsapiTicketHeaders, new com.aliyun.teautil.models.RuntimeOptions());
jsApiToken = res.getBody().getJsapiTicket();
} catch (TeaException err) {
if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
}
} catch (Exception _err) {
TeaException err = new TeaException(_err.getMessage(), _err);
if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
}
}
Redis.use().setex(KEY, 5400, jsApiToken);//5400:一个半小时过期
return jsApiToken;
} else {
return Redis.use().get(KEY);
}
}
/*
SsoToken()
2023-06-06
*/
public static String getSsoToken(String corpId, String ssoSecret) throws Exception {
final String KEY = "DingTalkSsoToken";
if (!Redis.use().exists(KEY)) {
String ssoToken = null;
com.aliyun.dingtalkoauth2_1_0.Client client = createClient();
GetSsoAccessTokenRequest getSsoAccessTokenRequest = new GetSsoAccessTokenRequest()
.setCorpid(corpId)
.setSsoSecret(ssoSecret);
try {
GetSsoAccessTokenResponse res = client.getSsoAccessToken(getSsoAccessTokenRequest);
ssoToken = res.getBody().getAccessToken();
} catch (TeaException err) {
if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
}
} catch (Exception _err) {
TeaException err = new TeaException(_err.getMessage(), _err);
if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
}
}
Redis.use().setex(KEY, 5400, ssoToken);//5400:一个半小时过期
return ssoToken;
} else {
return Redis.use().get(KEY);
}
}
/**
*
*
* @param access_token
* @param userId
* @return
*/
public static String getPerson(String access_token, String userId) {
try {
DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/v2/user/get");
OapiV2UserGetRequest req = new OapiV2UserGetRequest();
req.setUserid(userId);
req.setLanguage("zh_CN");
OapiV2UserGetResponse rsp = client.execute(req, access_token);
return rsp.getBody();
} catch (ApiException e) {
e.printStackTrace();
}
return null;
}
//TODO 未完成
public static String getPersonToken(String appKey, String appSecret) throws Exception {
com.aliyun.dingtalkoauth2_1_0.Client client = createClient();
GetUserTokenRequest getUserTokenRequest = new GetUserTokenRequest()
.setClientId(appKey)
.setClientSecret(appSecret)
//.setCode("abcd")
.setRefreshToken("abcd")
.setGrantType("authorization_code");
try {
GetUserTokenResponse res = client.getUserToken(getUserTokenRequest);
System.out.println(res.getBody().getAccessToken());
System.out.println(res.getBody().getRefreshToken());
} catch (TeaException err) {
System.out.println(err);
} catch (Exception _err) {
System.out.println(_err);
}
return null;
}
public class OrgPerson {
/**
*
@ -268,17 +121,17 @@ public class DingTalkUtil {
}
public static void syncOrg(String accessToken, String orgName) throws ApiException {
Record rOrg = getOrgByOrgName(orgName);
Record rOrg = Model.getOrgByOrgName(orgName);
int bureauId = rOrg.getInt("org_id");
int sortId = rOrg.getInt("sort_id");
//获取数据库中记录的钉钉端的dept_id,但不一定准确存在,需要继续判断一下
long DT_BureauId = getDtDeptId(bureauId);
long DT_BureauId = Model.getDtDeptId(bureauId);
//获取部门信息
deptList.clear();
JSONObject jRes = getDeptInfo(accessToken, DT_BureauId);
if (jRes.getLong("errcode") > 0) {
DT_BureauId = createDept(accessToken, orgName, 1, sortId);
writeDtDeptId(bureauId, String.valueOf(DT_BureauId));//记得要回写
Model.writeDtDeptId(bureauId, String.valueOf(DT_BureauId));//记得要回写
CommonUtil.Print("单位名称:" + orgName + "不存在!已创建!");
} else {
CommonUtil.Print("单位名称:" + orgName + "已存在,保留!");
@ -306,7 +159,7 @@ public class DingTalkUtil {
mapOfA.put(deptId, jo);
}
//B:云平台
List<Record> list = getOrgList(bureauId);
List<Record> list = Model.getOrgList(bureauId);
for (int i = 0; i < list.size(); i++) {
if (list.get(i).get("dingtalk_dept_id") != null) {
long deptId = list.get(i).getLong("dingtalk_dept_id");
@ -356,15 +209,14 @@ public class DingTalkUtil {
int parentId = mapOfB.get(key).getInteger("parent_id");
int org_id = mapOfB.get(key).getInteger("org_id");
//这个部门是在哪个部门下的
long dingTalkParentDeptId = getDtDeptId(parentId);
long dingTalkParentDeptId = Model.getDtDeptId(parentId);
long dt_dept_id = createDept(accessToken, org_name, dingTalkParentDeptId, sId);
writeDtDeptId(org_id, String.valueOf(dt_dept_id));
Model.writeDtDeptId(org_id, String.valueOf(dt_dept_id));
CommonUtil.Print("成功创建部门:" + org_name);
}
}
}
/**
*
*
@ -457,13 +309,13 @@ public class DingTalkUtil {
}
public static void delBureauPerson(String accessToken, String orgName) throws ApiException {
Record record = DingTalkUtil.getOrgByOrgName(orgName);
Record record = Model.getOrgByOrgName(orgName);
int dingtalk_dept_id = record.getInt("dingtalk_dept_id");
DingTalkUtil.getBureauPerson(accessToken, dingtalk_dept_id);
for (int i = 0; i < DingTalkUtil.personList.size(); i++) {
String userid = DingTalkUtil.personList.get(i).getStr("userid");
String person_name = DingTalkUtil.personList.get(i).getStr("name");
getBureauPerson(accessToken, dingtalk_dept_id);
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);
CommonUtil.Print("成功删除:" + person_name);
}
@ -477,11 +329,11 @@ public class DingTalkUtil {
* @throws ApiException
*/
public static void syncPerson(String accessToken, String orgName) throws ApiException {
Record rOrg = getOrgByOrgName(orgName);
Record rOrg = Model.getOrgByOrgName(orgName);
int bureauId = rOrg.getInt("org_id");
//获取数据库中记录的钉钉端的dept_id,但不一定准确存在,需要继续判断一下
long DT_BureauId = getDtDeptId(bureauId);
long DT_BureauId = Model.getDtDeptId(bureauId);
getBureauPerson(accessToken, DT_BureauId);
Set<String> keysOfA = new HashSet<>();
@ -502,7 +354,7 @@ public class DingTalkUtil {
}
//B:云平台
List<Record> list = getDeptPerson(bureauId);
List<Record> list = Model.getDeptPerson(bureauId);
for (int i = 0; i < list.size(); i++) {
Record r = list.get(i);
int person_id = r.getInt("person_id");
@ -550,43 +402,52 @@ public class DingTalkUtil {
String person_name = mapOfB.get(key).getString("person_name");
String tel = mapOfB.get(key).getString("tel");
long deptId = mapOfB.get(key).getLong("dingtalk_dept_id");
DingTalkUtil.createPerson(accessToken, String.valueOf(deptId), person_id, person_name, tel, "教师");
createPerson(accessToken, String.valueOf(deptId), person_id, person_name, tel, "教师");
CommonUtil.Print("成功加入人员:" + person_name);
}
}
}
//-----------------------------------------------------下面是数据库操作---------------------------------------------
public static List<Record> getOrgList(int orgId) {
// 学校及学校下的部门
String sql = "select org_id,org_name,parent_id,sort_id,dingtalk_dept_id from t_base_organization where bureau_id=? and org_id<>bureau_id order by org_id";
List<Record> list = Db.find(sql, orgId);
return list;
}
public static List<Record> getDeptPerson(int bureau_id) {
String sql = "select t1.person_id,t1.person_name,t2.dingtalk_dept_id,t1.tel from t_base_person as t1 " +
"inner join t_base_organization as t2 on t1.org_id=t2.org_id " +
" where t1.bureau_id=? and t1.b_use=1";
return Db.find(sql, bureau_id);
}
public static void writeDtDeptId(int orgId, String value) {
String sql = "update t_base_organization set dingtalk_dept_id=? where org_id=?";
Db.update(sql, value, orgId);
}
public static long getDtDeptId(int org_id) {
String sql = "select dingtalk_dept_id from t_base_organization where org_id=?";
Record r = Db.findFirst(sql, org_id);
if (r.get("dingtalk_dept_id") == null) return 1;
return r.get("dingtalk_dept_id");
/**
*
*
* @param access_token
* @param userId
* @return
*/
public static String getPerson(String access_token, String userId) {
try {
DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/v2/user/get");
OapiV2UserGetRequest req = new OapiV2UserGetRequest();
req.setUserid(userId);
req.setLanguage("zh_CN");
OapiV2UserGetResponse rsp = client.execute(req, access_token);
return rsp.getBody();
} catch (ApiException e) {
e.printStackTrace();
}
return null;
}
public static Record getOrgByOrgName(String org_name) {
String sql = "select org_id,org_name,sort_id,dingtalk_dept_id from t_base_organization where org_name = ?";
return Db.findFirst(sql, org_name);
//TODO 未完成
public static String getPersonToken(String appKey, String appSecret) throws Exception {
com.aliyun.dingtalkoauth2_1_0.Client client = Common.createClient();
GetUserTokenRequest getUserTokenRequest = new GetUserTokenRequest()
.setClientId(appKey)
.setClientSecret(appSecret)
//.setCode("abcd")
.setRefreshToken("abcd")
.setGrantType("authorization_code");
try {
GetUserTokenResponse res = client.getUserToken(getUserTokenRequest);
System.out.println(res.getBody().getAccessToken());
System.out.println(res.getBody().getRefreshToken());
} catch (TeaException err) {
System.out.println(err);
} catch (Exception _err) {
System.out.println(_err);
}
return null;
}
}

@ -0,0 +1,85 @@
package com.dsideal.FengHuang.DingTalk;
import com.dingtalk.api.DefaultDingTalkClient;
import com.dingtalk.api.DingTalkClient;
import com.dingtalk.api.request.*;
import com.dingtalk.api.response.*;
import com.taobao.api.ApiException;
public class RolePerson {
//暂未改修改,因为我们的角色与测试架构的角色存在冲突,不能在人家的环境中实现全部测试功能,需要搭建自己的专用服务器+架构
/**
*
*
* @param accessToken
* @throws ApiException
*/
public static void getRoleList(String accessToken) throws ApiException {
DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/role/list");
OapiRoleListRequest req = new OapiRoleListRequest();
req.setSize(20L);
req.setOffset(0L);
OapiRoleListResponse rsp = client.execute(req, accessToken);
System.out.println(rsp.getBody());
}
/**
*
*
* @param accessToken
*/
public static void getRolePersonList(String accessToken) throws ApiException {
DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/role/simplelist");
OapiRoleSimplelistRequest req = new OapiRoleSimplelistRequest();
req.setRoleId(1203141L);
req.setSize(20L);
req.setOffset(0L);
OapiRoleSimplelistResponse rsp = client.execute(req, accessToken);
System.out.println(rsp.getBody());
}
public static void createRole(String accessToken) throws ApiException {
DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/role/add_role");
OapiRoleAddRoleRequest req = new OapiRoleAddRoleRequest();
req.setRoleName("测试1");
req.setGroupId(1507113595L);
OapiRoleAddRoleResponse rsp = client.execute(req, accessToken);
System.out.println(rsp.getBody());
}
public static void updateRole(String accessToken) throws ApiException {
DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/role/update_role");
OapiRoleUpdateRoleRequest req = new OapiRoleUpdateRoleRequest();
req.setRoleId(1560985325L);
req.setRoleName("服装制造");
OapiRoleUpdateRoleResponse rsp = client.execute(req, accessToken);
System.out.println(rsp.getBody());
}
public static void delRole(String accessToken) throws ApiException {
DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/role/deleterole");
OapiRoleDeleteroleRequest req = new OapiRoleDeleteroleRequest();
req.setRoleId(1581321999L);
OapiRoleDeleteroleResponse rsp = client.execute(req, accessToken);
System.out.println(rsp.getBody());
}
public static void addRolePerson(String accessToken) throws ApiException {
DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/role/addrolesforemps");
OapiRoleAddrolesforempsRequest req = new OapiRoleAddrolesforempsRequest();
req.setRoleIds("1507113584,1507113589");
req.setUserIds("user1,user2");
OapiRoleAddrolesforempsResponse rsp = client.execute(req, accessToken);
System.out.println(rsp.getBody());
}
public static void delRolePerson(String accessToken) throws ApiException {
DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/role/removerolesforemps");
OapiRoleRemoverolesforempsRequest req = new OapiRoleRemoverolesforempsRequest();
req.setRoleIds("1507113578");
req.setUserIds("user100,user101");
OapiRoleRemoverolesforempsResponse rsp = client.execute(req, accessToken);
System.out.println(rsp.getBody());
}
}
Loading…
Cancel
Save