|
@@ -1,5 +1,6 @@
|
|
|
package org.dromara.backstage.wx.service.impl;
|
|
package org.dromara.backstage.wx.service.impl;
|
|
|
|
|
|
|
|
|
|
+import cn.hutool.core.codec.Base64;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.core.util.RandomUtil;
|
|
import cn.hutool.core.util.RandomUtil;
|
|
@@ -26,6 +27,8 @@ import org.dromara.common.core.constant.DefaultConstants;
|
|
|
import org.dromara.common.core.domain.R;
|
|
import org.dromara.common.core.domain.R;
|
|
|
import org.dromara.common.core.utils.ByteArrayUtilByYC;
|
|
import org.dromara.common.core.utils.ByteArrayUtilByYC;
|
|
|
import org.dromara.common.core.utils.StringUtilsByYC;
|
|
import org.dromara.common.core.utils.StringUtilsByYC;
|
|
|
|
|
+import org.dromara.common.core.utils.file.FileUtils;
|
|
|
|
|
+import org.dromara.common.core.utils.file.PicCompressor;
|
|
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
|
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
|
import org.dromara.system.api.RemoteDictService;
|
|
import org.dromara.system.api.RemoteDictService;
|
|
@@ -160,6 +163,15 @@ public class WxServiceImpl implements IWxService {
|
|
|
// 过滤掉data:image/jpg;base64,字符串
|
|
// 过滤掉data:image/jpg;base64,字符串
|
|
|
imgData = imgData.substring(strIndex + 8);
|
|
imgData = imgData.substring(strIndex + 8);
|
|
|
}
|
|
}
|
|
|
|
|
+ // String imgData ;
|
|
|
|
|
+ byte[] sBytes = Base64.decode(imgData);
|
|
|
|
|
+ if(sBytes.length > 200*1024){
|
|
|
|
|
+ // 如果图片大于200k,压缩至200k以内
|
|
|
|
|
+ byte[] compressed = PicCompressor.compressPicForScale(sBytes, 200);
|
|
|
|
|
+ imgData = Base64.encode(compressed);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ imgData = Base64.encode(sBytes);
|
|
|
|
|
+ }
|
|
|
String locationFlag = defaultConfig.getLocationFlag();
|
|
String locationFlag = defaultConfig.getLocationFlag();
|
|
|
R<Void> result;
|
|
R<Void> result;
|
|
|
// 如果是本地部署
|
|
// 如果是本地部署
|