main
parent
1c98acb167
commit
660c7955ff
@ -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);
|
||||
}
|
||||
}
|
@ -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…
Reference in new issue