xueyiming 6 月之前
父節點
當前提交
8015b12f50
共有 1 個文件被更改,包括 38 次插入3 次删除
  1. 38 3
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/controller/TestController.java

+ 38 - 3
we-com-server/src/main/java/com/tzld/piaoquan/wecom/controller/TestController.java

@@ -1,5 +1,7 @@
 package com.tzld.piaoquan.wecom.controller;
 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.service.AccessTokenService;
 import com.tzld.piaoquan.wecom.utils.HttpClientUtil;
 import com.tzld.piaoquan.wecom.utils.HttpClientUtil;
 import com.tzld.piaoquan.wecom.utils.HttpPoolClient;
 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 org.springframework.web.bind.annotation.RestController;
 
 
 import java.io.IOException;
 import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
 
 
 @Slf4j
 @Slf4j
 @RestController
 @RestController
@@ -22,8 +26,8 @@ public class TestController {
     private AccessTokenService accessTokenService;
     private AccessTokenService accessTokenService;
 
 
 
 
-    @GetMapping("/ok")
-    public void test() throws IOException {
+    @GetMapping("/staff")
+    public void staff() throws IOException {
         String weComAccessToken = accessTokenService.getWeComAccessToken();
         String weComAccessToken = accessTokenService.getWeComAccessToken();
         log.info("weComAccessToken={}", weComAccessToken);
         log.info("weComAccessToken={}", weComAccessToken);
         if (weComAccessToken == null) {
         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 url = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/get_follow_user_list?access_token=" + weComAccessToken;
         String s = httpPoolClientDefault.get(url);
         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);
 
 
     }
     }
 }
 }