From daa04a061ac3be4bb812c26fcf8f1b62838cec5a Mon Sep 17 00:00:00 2001
From: jiangping <jp@doumee.com>
Date: 星期五, 18 四月 2025 16:17:03 +0800
Subject: [PATCH] 代码初始化
---
server/src/main/java/com/doumee/core/utils/qiyeweixin/QywxUtil.java | 47 +++++++++++++++++++++++++++++++++++++++--------
1 files changed, 39 insertions(+), 8 deletions(-)
diff --git a/server/src/main/java/com/doumee/core/utils/qiyeweixin/QywxUtil.java b/server/src/main/java/com/doumee/core/utils/qiyeweixin/QywxUtil.java
index 18bd4b9..35b38e9 100644
--- a/server/src/main/java/com/doumee/core/utils/qiyeweixin/QywxUtil.java
+++ b/server/src/main/java/com/doumee/core/utils/qiyeweixin/QywxUtil.java
@@ -9,6 +9,7 @@
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
@@ -28,6 +29,8 @@
private SystemDictDataBiz systemDictDataBiz;
private static QywxUtil qyUtil;
+ @Value("${qiwei.serviceurl}")
+ private static String qiweiUrl;
@PostConstruct
private void init() {
@@ -81,13 +84,18 @@
return null;
}
public static QywxSendMsgResponse sendMsg(String token, QywxSendMsgRequest param) {
- String[] interfaceUrl = QywxConstant.SEND_MSG;
- String url = interfaceUrl[0].replace("${accesstoken}",token);
- QywxSendMsgResponse response = sendHttpRequestSingle(url,interfaceUrl[1],JSONObject.toJSONString(param)
- ,new TypeReference<QywxSendMsgResponse>(){});
- if(response.getErrcode()!=null && response.getErrcode() ==0){
- return response;
+ try{
+ String[] interfaceUrl = QywxConstant.SEND_MSG;
+ String url = interfaceUrl[0].replace("${accesstoken}",token);
+ QywxSendMsgResponse response = sendHttpRequestSingle(url,interfaceUrl[1],JSONObject.toJSONString(param)
+ ,new TypeReference<QywxSendMsgResponse>(){});
+ if(response.getErrcode()!=null && response.getErrcode() ==0){
+ return response;
+ }
+ }catch (Exception e){
+
}
+
return null;
}
public static List<QywxUserListResponse> getUserList(String token,String depatId) {
@@ -114,6 +122,29 @@
}
return null;
}
+ public static QywxBaseResponse<String> getUserInfoByCode(String token,String code) {
+ String[] interfaceUrl = QywxConstant.GET_USER_BY_AUTH_CODE;
+ String url = interfaceUrl[0].replace("${accesstoken}",token).replace("${code}",code);
+ QywxBaseResponse<String> response = sendHttpRequest(url,interfaceUrl[1],""
+ ,new TypeReference<QywxBaseResponse<String>>(){});
+ if(response.getErrcode()!=null && response.getErrcode() ==0){
+ return response;
+ }
+ return null;
+ }
+
+
+ public static String getJsApiTicket(String token) {
+ String[] interfaceUrl = QywxConstant.GET_JSAPI_TICKET;
+ String url = interfaceUrl[0].replace("${accesstoken}",token);
+ QywxBaseResponse<String> response = sendHttpRequest(url,interfaceUrl[1],""
+ ,new TypeReference<QywxBaseResponse<String>>(){});
+ if(response.getErrcode()!=null && response.getErrcode() ==0){
+ return response.getTicket();
+ }
+ return null;
+ }
+
/**
* 鍙戣捣wms鎺ュ彛璇锋眰
@@ -130,7 +161,7 @@
String res = null;
try {
Map<String,String> headers = new HashMap<>();
- res = HttpsUtil.postJson(url,param);
+ res = HttpsUtil.postJson(qiweiUrl+url,param);
QywxBaseResponse result = JSONObject.parseObject(res, typeReference.getType());
logResult(result,name);
return result;
@@ -147,7 +178,7 @@
String res = null;
try {
Map<String,String> headers = new HashMap<>();
- res = HttpsUtil.postJson(url,param);
+ res = HttpsUtil.postJson(qiweiUrl+url,param);
T result = JSONObject.parseObject(res, typeReference.getType());
// logResult(result,name);
return result;
--
Gitblit v1.9.3