From 6b479c5774ed3d6e2dc92693ddeda3e7ad1494db Mon Sep 17 00:00:00 2001
From: Andru <769883346@qq.com>
Date: 星期一, 23 十月 2023 17:34:08 +0800
Subject: [PATCH] 添加获客方法

---
 src/main/java/com/hx/mp/util/CorpMpUtil.java |   61 ++++++++++++++++++++++++++++--
 1 files changed, 57 insertions(+), 4 deletions(-)

diff --git a/src/main/java/com/hx/mp/util/CorpMpUtil.java b/src/main/java/com/hx/mp/util/CorpMpUtil.java
index bd83c76..8dd010b 100644
--- a/src/main/java/com/hx/mp/util/CorpMpUtil.java
+++ b/src/main/java/com/hx/mp/util/CorpMpUtil.java
@@ -1,16 +1,19 @@
 package com.hx.mp.util;
 
+import com.hx.util.corp.entity.AppLetInfo;
 import com.hx.exception.TipsException;
+import com.hx.util.HttpMethodUtil;
 import com.hx.util.StringUtils;
 import net.sf.json.JSONException;
 import net.sf.json.JSONObject;
 import org.apache.commons.io.IOUtils;
-import org.apache.poi.util.SystemOutLogger;
 
 import java.io.OutputStream;
 import java.net.HttpURLConnection;
 import java.net.URL;
 import java.text.MessageFormat;
+import java.util.HashMap;
+import java.util.Map;
 
 /**
  * 浼佷笟寰俊宸ュ叿绫�
@@ -39,6 +42,7 @@
     public static final String URL_INFO_USER = "https://qyapi.weixin.qq.com/cgi-bin/user/get?access_token={0}&userid={1}";
     /**鍙戦�佹秷鎭�*/
     public static final String URL_MESSAGE_SEND = "https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=";
+
 
     /**
      * 娣诲姞宸ヤ綔浜哄憳
@@ -71,6 +75,42 @@
         }
         return -1;
     }
+
+    /**
+     * 娣诲姞宸ヤ綔浜哄憳
+     * @param at 璁块棶at
+     * @param userId 鐢ㄦ埛id
+     * @param name 鍚嶇О
+     * @param depId 閮ㄩ棬id
+     * @param position 鑱屼綅
+     * @param tel 鐢佃瘽
+     * @param email 閭
+     * @return 杩斿洖
+     */
+    public static JSONObject addUserObj(String at, String userId, String name, int depId
+            , String position,String tel,String email) {
+
+        if(StringUtils.isEmpty(tel)&&StringUtils.isEmpty(email)){
+            throw new TipsException("娣诲姞浼佷笟寰俊鎵嬫満鍙峰拰閭涓嶈兘閮戒负绌猴紒");
+        }
+
+        JSONObject obj = new JSONObject();
+        obj.put("userid", userId);
+        obj.put("name", name);
+        obj.put("department", depId);
+        obj.put("position", position);
+        obj.put("mobile", tel);
+        obj.put("email", email);
+        obj = HttpURLUtil(MessageFormat.format(URL_ADD_USER, at), obj.toString());
+
+        if(obj == null){
+            obj = new JSONObject();
+        }
+
+        return obj;
+
+    }
+
     /**
      * 鏇存柊宸ヤ綔浜哄憳
      * @param at 璁块棶at
@@ -103,7 +143,7 @@
     /**
      * 鍒犻櫎宸ヤ綔浜哄憳
      * @param at 璁块棶at
-     * @param userId 鐢ㄦ埛id
+     * @param userId 浼佷笟鐢ㄦ埛id
      * @return 杩斿洖
      */
     public static int deleteUser(String at, String userId) {
@@ -128,12 +168,24 @@
         obj.put("userid", userId);
 
         obj = HttpURLUtil(MessageFormat.format(URL_INFO_USER, at,userId), obj.toString());
-        System.out.println("userId:"+userId);
-        System.out.println("obj:"+obj.toString());
+
         if(obj != null) {
             return obj.optInt("errcode", -1);
         }
         return -1;
+    }
+
+    /**
+     * 鑾峰彇浼佷笟鐢ㄦ埛淇℃伅
+     * @param at 璁块棶at
+     * @param userId 鐢ㄦ埛id
+     * @return 杩斿洖
+     */
+    public static JSONObject userData(String at, String userId) {
+        JSONObject obj = new JSONObject();
+        obj.put("userid", userId);
+
+        return obj = HttpURLUtil(MessageFormat.format(URL_INFO_USER, at,userId), obj.toString());
     }
 
 
@@ -291,4 +343,5 @@
         }
         return obj;
     }
+
 }

--
Gitblit v1.8.0