package com.fjhx.utils; //import com.dingtalk.api.DefaultDingTalkClient; //import com.dingtalk.api.DingTalkClient; //import com.dingtalk.api.request.OapiServiceGetCorpTokenRequest; //import com.dingtalk.api.request.OapiV2DepartmentGetRequest; //import com.dingtalk.api.request.OapiV2DepartmentListsubRequest; //import com.dingtalk.api.request.OapiV2UserGetRequest; //import com.dingtalk.api.response.OapiServiceGetCorpTokenResponse; //import com.dingtalk.api.response.OapiV2DepartmentGetResponse; //import com.dingtalk.api.response.OapiV2DepartmentListsubResponse; //import com.dingtalk.api.response.OapiV2UserGetResponse; //import com.taobao.api.ApiException; public class DingUtil { // private static final String accessKey = "suitepgu4shlatgllyiqp"; // private static final String accessSecret = "52-_2aKc3WGd8qVX5FRFmR6MnkeAOi6seUKYxjMWBCeiXZJ0l01_YaDfABIP-hmk"; // // public static void main(String[] args) throws ApiException { // OapiServiceGetCorpTokenResponse corpToken = getCorpToken("ding53d823e205604918a39a90f97fcb1e09", // "R9lsfWBExszmJuiJwF8gd3LQ31YUnUaPRQ0L0W4CsslEsyM1L5GVfLXPJExnhbqRsLntMnFp7KYCha9msIjRCY"); // // if (corpToken.getErrcode().equals(0L)) { // String accessToken = corpToken.getAccessToken(); // getDeptList(accessToken, 1L); // // } // } // // /** // * 获取token // */ // public static OapiServiceGetCorpTokenResponse getCorpToken(String authCorpid, String suiteTicket) throws ApiException { // // DefaultDingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/service/get_corp_token"); // OapiServiceGetCorpTokenRequest req = new OapiServiceGetCorpTokenRequest(); // req.setAuthCorpid(authCorpid); // // return client.execute(req, accessKey, accessSecret, suiteTicket); // } // // public static void getDeptList(String accessToken, Long deptId) throws ApiException { // DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/v2/department/listsub"); // OapiV2DepartmentListsubRequest req = new OapiV2DepartmentListsubRequest(); // req.setDeptId(deptId); // OapiV2DepartmentListsubResponse rsp = client.execute(req, accessToken); // // List result = rsp.getResult(); // // for (OapiV2DepartmentListsubResponse.DeptBaseResponse deptBaseResponse : result) { // getDeptList(accessToken, deptBaseResponse.getDeptId()); // // getDeptDetails(accessToken,deptBaseResponse.getDeptId()); // } // // } // // public static void getDeptDetails(String accessToken, Long deptId) throws ApiException { // DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/v2/department/get"); // OapiV2DepartmentGetRequest req = new OapiV2DepartmentGetRequest(); // req.setDeptId(deptId); // OapiV2DepartmentGetResponse rsp = client.execute(req, accessToken); // System.out.println(rsp.getBody()); // } // // // public static void getUser(String accessToken, String userId) throws ApiException { // DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/v2/user/get"); // OapiV2UserGetRequest req = new OapiV2UserGetRequest(); // req.setUserid(userId); // OapiV2UserGetResponse rsp = client.execute(req, accessToken); // System.out.println(rsp.getBody()); // } }