|
@@ -1,5 +1,7 @@
|
|
|
package com.tzld.piaoquan.wecom.controller;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.tzld.piaoquan.wecom.service.AccessTokenService;
|
|
|
import com.tzld.piaoquan.wecom.utils.HttpClientUtil;
|
|
|
import com.tzld.piaoquan.wecom.utils.HttpPoolClient;
|
|
@@ -10,6 +12,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
|
|
|
@Slf4j
|
|
|
@RestController
|
|
@@ -22,8 +26,8 @@ public class TestController {
|
|
|
private AccessTokenService accessTokenService;
|
|
|
|
|
|
|
|
|
- @GetMapping("/ok")
|
|
|
- public void test() throws IOException {
|
|
|
+ @GetMapping("/staff")
|
|
|
+ public void staff() throws IOException {
|
|
|
String weComAccessToken = accessTokenService.getWeComAccessToken();
|
|
|
log.info("weComAccessToken={}", weComAccessToken);
|
|
|
if (weComAccessToken == null) {
|
|
@@ -31,7 +35,38 @@ public class TestController {
|
|
|
}
|
|
|
String url = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/get_follow_user_list?access_token=" + weComAccessToken;
|
|
|
String s = httpPoolClientDefault.get(url);
|
|
|
- log.info("getTest={}", s);
|
|
|
+ log.info("staff={}", s);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/user")
|
|
|
+ public void user() throws IOException {
|
|
|
+ String weComAccessToken = accessTokenService.getWeComAccessToken();
|
|
|
+ log.info("weComAccessToken={}", weComAccessToken);
|
|
|
+ if (weComAccessToken == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ String url = String.format("https://qyapi.weixin.qq.com/cgi-bin/externalcontact/list?access_token=%s&userid=%s", weComAccessToken, "SongYi");
|
|
|
+ String s = httpPoolClientDefault.get(url);
|
|
|
+ log.info("user={}", s);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/userListDetail")
|
|
|
+ public void userListDetail() throws IOException {
|
|
|
+ String weComAccessToken = accessTokenService.getWeComAccessToken();
|
|
|
+ log.info("weComAccessToken={}", weComAccessToken);
|
|
|
+ if (weComAccessToken == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ String url = String.format("https://qyapi.weixin.qq.com/cgi-bin/externalcontact/batch/get_by_user?access_token=%s", weComAccessToken);
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ JSONArray jsonArray = new JSONArray();
|
|
|
+ jsonArray.add("SongYi");
|
|
|
+ jsonObject.put("userid_list", jsonArray);
|
|
|
+ jsonObject.put("limit", 10);
|
|
|
+ String post = httpPoolClientDefault.post(url, jsonObject.toJSONString());
|
|
|
+ log.info("userListDetail={}", post);
|
|
|
|
|
|
}
|
|
|
}
|