From ac2230cf612417b2dcbdcc23814e19f4955941b2 Mon Sep 17 00:00:00 2001
From: k94314517 <8417338+k94314517@user.noreply.gitee.com>
Date: 星期二, 16 七月 2024 16:26:36 +0800
Subject: [PATCH] 代码提交
---
server/service/src/main/java/com/doumee/core/utils/Constants.java | 96 ++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 96 insertions(+), 0 deletions(-)
diff --git a/server/service/src/main/java/com/doumee/core/utils/Constants.java b/server/service/src/main/java/com/doumee/core/utils/Constants.java
index 4841bbb..7c59e5e 100644
--- a/server/service/src/main/java/com/doumee/core/utils/Constants.java
+++ b/server/service/src/main/java/com/doumee/core/utils/Constants.java
@@ -2,16 +2,30 @@
import com.alibaba.fastjson.JSONObject;
+import com.doumee.core.constants.ResponseStatus;
+import com.doumee.core.exception.BusinessException;
import com.doumee.dao.business.vo.UnitCodeVo;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
+import okhttp3.OkHttpClient;
+import okhttp3.Request;
+import okhttp3.Response;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.utils.URIBuilder;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.util.EntityUtils;
+import java.io.ByteArrayInputStream;
import java.io.IOException;
+import java.io.InputStream;
import java.math.BigDecimal;
+import java.net.URI;
import java.net.URLDecoder;
import java.text.SimpleDateFormat;
import java.util.*;
@@ -96,6 +110,8 @@
public static final String USER_CARD_HEADER_IMG ="USER_CARD_HEADER_IMG" ;
public static final String USER_CARD_PHONE_IMG ="USER_CARD_PHONE_IMG" ;
public static final String USER_CARD_ADDR_IMG ="USER_CARD_ADDR_IMG" ;
+ public static final String USER_CARD_SHOP_IMG ="USER_CARD_SHOP_IMG" ;
+ public static final String USER_CARD_LOGO_IMG ="USER_CARD_LOGO_IMG" ;
public static Integer parseIntByStr(String idtOrgStatus) {
try {
@@ -308,6 +324,8 @@
public static final String ACCESS_ID="ACCESS_ID";
public static final String BUCKETNAME = "BUCKETNAME";
public static final String OBJCET_STORAGE = "OBJCET_STORAGE";
+ public static final String ZBOM_CUSTOMIZED = "ZBOM_CUSTOMIZED";
+
public static final String ACCESS_KEY = "ACCESS_KEY";
public static final String ENDPOINT = "ENDPOINT";
@@ -316,6 +334,7 @@
public static final String USER_CARD_DEFAULT_IMG = "USER_CARD_DEFAULT_IMG";
public static final String USERS_FILE = "USERS_FILE";
public static final String NEWS_FILE = "NEWS_FILE";
+ public static final String USER_LABEL = "USER_LABEL";
//鍙戦�佷細璁紑濮� 瀹氭椂鎻愬墠澶氬皯鍒嗛挓鍙戦��
public static final String SYSTEM ="SYSTEM";
@@ -350,6 +369,8 @@
public static final String WX_SECRET_CUSTOMER = "WX_SECRET_CUSTOMER";
public static final String WX_APPID_PERSONNEL = "WX_APPID_PERSONNEL";
public static final String WX_SECRET_PERSONNEL = "WX_SECRET_PERSONNEL";
+ public static final String WX_TOKEN_CUSTOMER = "WX_TOKEN_CUSTOMER";
+ public static final String WX_TOKEN_PERSONNEL = "WX_TOKEN_PERSONNEL";
public interface RedisKeys {
@@ -663,4 +684,79 @@
return sb.toString();
}
+
+
+ public InputStream generateWxMiniImgStream(String accessToken,String scene,String page) {
+ //鐢熸垚鍥剧墖涓婁紶OSS
+ Map<String,Object> body = new HashMap<>();
+ // 鍦烘櫙鐮侊紝涓庡墠绔害瀹氾紝鏈�缁堟槸闇�瑕佸墠绔В鏋�
+ body.put("scene", scene);
+ // 姝e紡鐗堜负 "release"锛屼綋楠岀増涓� "trial"锛屽紑鍙戠増涓� "develop"銆傞粯璁ゆ槸姝e紡鐗堛��
+ body.put("env_version", "release");
+ body.put("page", page);
+ // 閫忔槑锛屾牴鎹綘鐨勫満鏅嚜琛岃缃産ody鍙傛暟
+ body.put("is_hyaline", true);
+ OkHttpClient client = new OkHttpClient().newBuilder().build();
+ okhttp3.MediaType mediaType = okhttp3.MediaType.parse("application/json");
+ okhttp3.RequestBody requestBody = okhttp3.RequestBody.create(mediaType, JSONObject.toJSONString(body));
+ Request request = new Request.Builder().url("https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token="+accessToken)
+ .method("POST", requestBody).build();
+ try {
+ Response response = client.newCall(request).execute();
+ if (response.isSuccessful()) {
+ InputStream inputStream = new ByteArrayInputStream(response.body().bytes());
+ return inputStream;
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鐢熸垚鍥剧墖澶辫触");
+ }
+
+
+ /**
+ * 鍙戦�乬et璇锋眰
+ * @param url 璇锋眰URL
+ * @param param 璇锋眰鍙傛暟 key:value url鎼哄甫鍙傛暟 鎴栬�呮棤鍙傚彲涓嶅~
+ * @return
+ */
+ public static String doGet(String url, Map<String, String> param) {
+ // 鍒涘缓Httpclient瀵硅薄
+ CloseableHttpClient httpclient = HttpClients.createDefault();
+ String resultString = "";
+ CloseableHttpResponse response = null;
+ try {
+ // 鍒涘缓uri
+ URIBuilder builder = new URIBuilder(url);
+ if (param != null) {
+ for (String key : param.keySet()) {
+ builder.addParameter(key, param.get(key));
+ }
+ }
+ URI uri = builder.build();
+ // 鍒涘缓http GET璇锋眰
+ HttpGet httpGet = new HttpGet(uri);
+ // 鎵ц璇锋眰
+ response = httpclient.execute(httpGet);
+ // 鍒ゆ柇杩斿洖鐘舵�佹槸鍚︿负200
+ if (response.getStatusLine().getStatusCode() == 200) {
+ resultString = EntityUtils.toString(response.getEntity(), "UTF-8");
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+ try {
+ if (response != null) {
+ response.close();
+ }
+ httpclient.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ return resultString;
+ }
+
+
+
}
--
Gitblit v1.9.3