Commit 01971b69 by 淡漠

fix

1 parent c85adc3a
...@@ -3,17 +3,21 @@ package com.tencent.wework; ...@@ -3,17 +3,21 @@ package com.tencent.wework;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.linkwechat.common.config.CosConfig;
import com.linkwechat.common.config.RuoYiConfig; import com.linkwechat.common.config.RuoYiConfig;
import com.linkwechat.common.constant.Constants; import com.linkwechat.common.constant.Constants;
import com.linkwechat.common.constant.WeConstans; import com.linkwechat.common.constant.WeConstans;
import com.linkwechat.common.core.redis.RedisCache; import com.linkwechat.common.core.redis.RedisCache;
import com.linkwechat.common.utils.DateUtils; import com.linkwechat.common.utils.DateUtils;
import com.linkwechat.common.utils.StringUtils; import com.linkwechat.common.utils.StringUtils;
import com.linkwechat.common.utils.file.FileUploadUtils;
import com.linkwechat.common.utils.spring.SpringUtils;
import com.linkwechat.common.utils.uuid.IdUtils; import com.linkwechat.common.utils.uuid.IdUtils;
import com.linkwechat.common.utils.wecom.RSAUtil; import com.linkwechat.common.utils.wecom.RSAUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import java.io.File; import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.security.PrivateKey; import java.security.PrivateKey;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -245,7 +249,7 @@ public class FinanceUtils { ...@@ -245,7 +249,7 @@ public class FinanceUtils {
getPath(realJsonData, msgType, fileName); getPath(realJsonData, msgType, fileName);
} }
//本地存储 /*//本地存储
private static void getPath(JSONObject realJsonData, String msgType, String fileName) { private static void getPath(JSONObject realJsonData, String msgType, String fileName) {
String filePath = getFilePath(msgType); String filePath = getFilePath(msgType);
JSONObject data = Optional.ofNullable(realJsonData.getJSONObject(msgType)) JSONObject data = Optional.ofNullable(realJsonData.getJSONObject(msgType))
...@@ -270,6 +274,31 @@ public class FinanceUtils { ...@@ -270,6 +274,31 @@ public class FinanceUtils {
realJsonData.put(msgType, data); realJsonData.put(msgType, data);
} }
}*/
//云存储
private static void getPath(JSONObject realJsonData, String msgType, String fileName) {
String filePath = getFilePath(msgType);
JSONObject data = Optional.ofNullable(realJsonData.getJSONObject(msgType))
.orElse(realJsonData.getJSONObject("content"));
String sdkfileid = data.getString("sdkfileid");
try {
getMediaData(sdkfileid, "", "", filePath, fileName);
CosConfig cosConfig = SpringUtils.getBean(CosConfig.class);
String suffix = fileName.substring(fileName.lastIndexOf(".") + 1);
StringBuilder cosUrl = new StringBuilder(cosConfig.getImgUrlPrefix());
String cosFilePath = FileUploadUtils.upload2Cos(new FileInputStream(filePath + fileName), suffix, cosConfig);
cosUrl.append(cosFilePath);
data.put("attachment", cosUrl.toString());
} catch (Exception e) {
e.printStackTrace();
}
if (realJsonData.containsKey("content")) {
realJsonData.put("content", data);
} else {
realJsonData.put(msgType, data);
}
} }
private static String getFilePath(String msgType) { private static String getFilePath(String msgType) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!