You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

86 lines
3.8 KiB

2 years ago
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());
}
}