From 6fb44f4051509f66cc887d18469e2947e3702c11 Mon Sep 17 00:00:00 2001 From: guang <guang@guang.com> Date: 星期二, 01 八月 2023 15:13:20 +0800 Subject: [PATCH] 增加企业微盘操作工具类 --- src/main/java/com/hx/mp/util/CorpMpClientUtil.java | 45 +++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 43 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/hx/mp/util/CorpMpClientUtil.java b/src/main/java/com/hx/mp/util/CorpMpClientUtil.java index 32d0670..8009df7 100644 --- a/src/main/java/com/hx/mp/util/CorpMpClientUtil.java +++ b/src/main/java/com/hx/mp/util/CorpMpClientUtil.java @@ -43,6 +43,10 @@ */ public static final String RELATION_TAG = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/mark_tag?access_token="; + /** + * 鑾峰彇鍛樺伐瀹㈡埛鍒楄〃url + */ + public static final String EXTERNAL_CONTACT_LIST = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/list"; /** * 鐢熸垚浼佷笟鎴愬憳鑱旂郴鎴戠殑id-鍗曚汉 @@ -76,6 +80,16 @@ } /** + * 鑾峰彇瀹㈡埛鍒楄〃 + * @param accessToken 浼佷笟鐨刟ccessToken + * @param userId 浼佷笟鎴愬憳鐨剈serId + * @return 杩斿洖 + */ + public static JSONObject getExternalContactList(String accessToken, String userId) { + return HttpURLUtil(EXTERNAL_CONTACT_LIST + "?access_token=" + accessToken + "&userid=" + userId, null); + } + + /** * 鑾峰彇浼佷笟瀹㈡埛璇︽儏淇℃伅 * * @param accessToken 浼佷笟鐨刟ccessToken @@ -83,7 +97,6 @@ * @return 杩斿洖 */ public static JSONObject getClientData(String accessToken, String externalUserId) { - return HttpURLUtil(GET_CLIENT_DETAIL_URL + "?access_token=" + accessToken + "&external_userid=" + externalUserId, null); } @@ -179,7 +192,6 @@ return HttpURLUtil(RELATION_TAG + accessToken, data.toString()); } - /** * 璇锋眰http鍗忚 鑾峰彇淇℃伅宸ュ叿 **/ @@ -226,4 +238,33 @@ } return obj; } + + /**鐢熸垚浼佷笟鎴愬憳鑱旂郴鎴戠殑id-鍗曚汉 + * @param accessToken 浼佷笟鐨刟ccessToken + * @param userId 浼佷笟鎴愬憳鐨剈serId + * @param scene 鍦烘櫙锛�1-鍦ㄥ皬绋嬪簭涓仈绯伙紝2-閫氳繃浜岀淮鐮佽仈绯� + * @param state 浼佷笟鑷畾涔夌殑state鍙傛暟锛岀敤浜庡尯鍒嗕笉鍚岀殑娣诲姞娓犻亾锛屽湪璋冪敤鈥滆幏鍙栧閮ㄨ仈绯讳汉璇︽儏鈥濇椂浼氳繑鍥炶鍙傛暟鍊硷紝涓嶈秴杩�30涓瓧绗� + * @param remark 鑱旂郴鏂瑰紡鐨勫娉ㄤ俊鎭紝鐢ㄤ簬鍔╄锛屼笉瓒呰繃30涓瓧绗� + * @return 杩斿洖 + */ + public static JSONObject createContactId(String accessToken,String userId,int scene,String state,String remark){ + String configId = null; + JSONObject data = new JSONObject(); + data.put("type",1); + data.put("scene",scene); + data.put("state",state); + data.put("remark",remark); + JSONArray userIds = new JSONArray(); + userIds.add(userId); + data.put("user",userIds); + + //璇锋眰锛岃繑鍥炴牸寮� + /*{ + "errcode": 0, + "errmsg": "ok", + "config_id":"42b34949e138eb6e027c123cba77fAAA"銆�銆� + }*/ + + return HttpURLUtil(CREATE_CONTACT_ID_URL+accessToken,data.toString()); + } } -- Gitblit v1.8.0