Commit bf90dd22 by 墨竹

feat:上传图片报错修改

parent b9e0ccae
......@@ -4,10 +4,7 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.gic.clerk.api.dto.ClerkQwDTO;
import com.gic.clerk.api.service.ClerkService;
import com.gic.commons.util.EntityUtil;
import com.gic.commons.util.GICMQClientUtil;
import com.gic.commons.util.GlobalInfo;
import com.gic.commons.util.GlobalVar;
import com.gic.commons.util.*;
import com.gic.haoban.app.customer.service.api.service.InnerApiService;
import com.gic.haoban.base.api.common.Constant;
import com.gic.haoban.base.api.common.ServiceResponse;
......@@ -27,15 +24,12 @@ import com.gic.wechat.api.service.qywx.QywxDepartmentApiService;
import com.gic.wechat.api.service.qywx.QywxSuiteApiService;
import com.google.common.collect.Sets;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.io.InputStream;
import java.net.URL;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
......@@ -482,13 +476,16 @@ public class MessageApiServiceImpl implements MessageApiService {
private String changeHeaderImageUrl(String headImgUrl) {
try {
InputStream in = new URL(headImgUrl).openStream();
byte[] data = IOUtils.toByteArray(in);
log.info("图片headImgUrl:{}",headImgUrl);
if (StringUtils.isBlank(headImgUrl)) {
return headImgUrl;
}
byte[] data = ImageUtil.getImgbyte(headImgUrl);
PicUploadResDTO uploadPic = qqCloudPicService.uploadPic(GlobalVar.ctxPropertiesMap.get(GlobalInfo.QQPIC_KEY_ENTERPRISE), data);
log.info("腾讯云万象优图返回" + JSON.toJSONString(uploadPic));
return uploadPic.downloadUrl;
} catch (Exception e) {
log.info("上传腾讯云万象优图返回失败了:", e);
log.info("上传腾讯云万象优图返回失败了:{}", e.getMessage());
return headImgUrl;
}
}
......
......@@ -25,7 +25,6 @@ import com.gic.haoban.manage.api.dto.*;
import com.gic.haoban.manage.api.enums.SecretTypeEnum;
import com.gic.haoban.manage.api.service.DepartmentApiService;
import com.gic.haoban.manage.api.service.StaffApiService;
import com.gic.haoban.manage.service.config.Config;
import com.gic.haoban.manage.service.dao.mapper.StaffDepartmentRelatedMapper;
import com.gic.haoban.manage.service.dao.mapper.StaffMapper;
import com.gic.haoban.manage.service.entity.TabHaobanDepartment;
......@@ -101,8 +100,6 @@ public class StaffApiServiceImpl implements StaffApiService {
private SecretSettingService secretSettingService;
@Autowired
private StaffPrivacyUseLogService staffPrivacyUseLogService;
@Autowired
private Config config;
@Override
public StaffDTO selectById(String staffId) {
......@@ -1297,16 +1294,17 @@ public class StaffApiServiceImpl implements StaffApiService {
}
private String changeHeaderImageUrl(String headImgUrl) {
// InputStream in = new URL(headImgUrl).openStream();
try {
logger.info("图片headImgUrl:{}", headImgUrl);
if (StringUtils.isBlank(headImgUrl)) {
return headImgUrl;
}
byte[] data = ImageUtil.getImgbyte(headImgUrl);
// byte[] data = IOUtils.toByteArray(in);
PicUploadResDTO uploadPic = qqCloudPicService.uploadPic(GlobalVar.ctxPropertiesMap.get(GlobalInfo.QQPIC_KEY_ENTERPRISE), data);
logger.info("腾讯云万象优图返回" + JSON.toJSONString(uploadPic));
return uploadPic.downloadUrl;
} catch (Exception e) {
logger.info("上传腾讯云万象优图返回失败了:", e);
logger.info("上传腾讯云万象优图返回失败了:{}", e.getMessage());
return headImgUrl;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment