From a9f950c0d11a687a7a940443b8c765f6d87ae4f1 Mon Sep 17 00:00:00 2001
From: jyy <935090232@qq.com>
Date: Tue, 20 Apr 2021 00:26:22 +0800
Subject: [PATCH] 合并新的修改
---
zq-erp/src/main/java/com/matrix/component/tools/WxacodeUtil.java | 38 ++++++--------------------------------
1 files changed, 6 insertions(+), 32 deletions(-)
diff --git a/zq-erp/src/main/java/com/matrix/component/tools/WxacodeUtil.java b/zq-erp/src/main/java/com/matrix/component/tools/WxacodeUtil.java
index 7b0c2a4..1bd3bc1 100644
--- a/zq-erp/src/main/java/com/matrix/component/tools/WxacodeUtil.java
+++ b/zq-erp/src/main/java/com/matrix/component/tools/WxacodeUtil.java
@@ -19,14 +19,9 @@
import java.util.Map;
public class WxacodeUtil {
- /**
- * 小程序秘钥
- */
- private static final String XCX_SECRET = "xcx_secret";
- /**
- * 小程序appid
- */
- private static final String XCX_APPID = "xcx_appid";
+
+
+
/**
* token获取地址
*/
@@ -37,11 +32,9 @@
*/
private static final String GET_WXACODE ="https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=";
- public static String getWxacode(String scene,String page,String fileName) throws Exception {
+ public static String getWxacode(String scene,String page,String fileName,String appid,String secret) throws Exception {
LogUtil.debug("scene={},page={},fileName={}",scene,page,fileName);
//获取token
- String appid = PropertiesUtil.getString(XCX_APPID);
- String secret = PropertiesUtil.getString(XCX_SECRET);
String result1 = get(TOKEN_URL.replace("APPID", appid).replace("SECRET", secret));
String access_token = JSONObject.parseObject(result1).getString("access_token");
if(StringUtils.isNotBlank(access_token)) {
@@ -61,12 +54,6 @@
HttpResponse response;
response = httpClient.execute(httpPost);
InputStream inputStream = response.getEntity().getContent();
- /*Object inputObj= response.getEntity().getContent();
- if(inputObj instanceof InputStream){
- String strError = streamToString(inputStream,"GBK");
- LogUtil.info("-------------二维码生成------"+strError);
- return "error:" + strError;
- }*/
// 图片保存目录路径
String baseSavePath = PropertiesUtil.getString(AppConstance.FILES_TORAGE_PATH);
@@ -74,11 +61,6 @@
if(!targetFile.exists()){
targetFile.mkdirs();
}
-
- /*String inputstreamtofile = inputstreamtofile(inputStream, targetFile);
- if(null != inputstreamtofile){
- return inputstreamtofile;
- }*/
// 创建图片文件夹
baseSavePath += "wxacode" + File.separatorChar;
@@ -89,23 +71,15 @@
String qrcodePath = baseSavePath + fileName + ".png";
FileOutputStream out = new FileOutputStream(qrcodePath);
LogUtil.debug("qrcodePath:{}",qrcodePath);
- //本地调试创建(不用删)
- /*String filePath = "e:/test.png";
- File file = new File(filePath);
- if (!file.exists()) {
- file.mkdir();
- }
- FileOutputStream outs = new FileOutputStream(file);*/
+
byte[] buffer = new byte[1024];
int bytesRead = 0;
while((bytesRead = inputStream.read(buffer, 0, 1024)) != -1) {
out.write(buffer, 0, bytesRead);
- //outs.write(buffer, 0, bytesRead);
+
}
out.flush();
out.close();
- //outs.flush();
- //outs.close();
return qrcodePath;
} else {
--
Gitblit v1.9.1