Commit 9a1acb92 authored by 刘基明's avatar 刘基明

同步专栏

parent 83b257e0
package com.tanpu.community.manager;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.core.type.TypeReference;
import com.google.common.collect.Sets;
import com.tanpu.biz.common.enums.RelTypeEnum;
......@@ -31,7 +30,11 @@ import com.tanpu.community.api.beans.vo.ImagesDTO;
import com.tanpu.community.api.beans.vo.feign.fatools.UserInfoResp;
import com.tanpu.community.api.beans.vo.feign.newsfeed.NewsFeedResReq;
import com.tanpu.community.api.beans.vo.feign.newsfeed.NewsFeedSave4NewCommReq;
import com.tanpu.community.api.enums.*;
import com.tanpu.community.api.enums.BlockTypeEnum;
import com.tanpu.community.api.enums.DeleteTagEnum;
import com.tanpu.community.api.enums.OperationTypeEnum;
import com.tanpu.community.api.enums.ThemeListTypeEnum;
import com.tanpu.community.api.enums.ThemeTypeEnum;
import com.tanpu.community.cache.RedisCache;
import com.tanpu.community.dao.entity.community.BlackListEntity;
import com.tanpu.community.dao.entity.community.CollectionEntity;
......@@ -269,16 +272,15 @@ public class ThemeManager {
private NewsFeedResReq convertImg(ImagesDTO img, String userId) {
String[] arr = StringUtils.split(img.getRemark(), ".");
String imgUrl = img.getRemark();
String[] arr = StringUtils.split(imgUrl, ".");
String suffix = arr[arr.length - 1];
String fileName = imgUrl.substring(imgUrl.lastIndexOf('/') + 1);
ResponseEntity<byte[]> resp = restTemplate.getForEntity(img.getRemark(), byte[].class);
byte[] rst = resp.getBody();
// todo
String fileName = tmpDir + System.currentTimeMillis() + ".jpg";
File f = new File(fileName);
try {
FileUtils.writeByteArrayToFile(f, rst);
......@@ -303,17 +305,15 @@ public class ThemeManager {
if (StringUtils.isBlank(response.getBody())) {
throw new RuntimeException("response body is blank");
}
CommonResp<JSONObject> ret = JSON.parseObject(response.getBody(), CommonResp.class);
if (!ret.isSuccess()) {
CommonResp<LinkedHashMap<String, String>> responseBody = JsonUtil.toBean(response.getBody(), CommonResp.class);
if (!responseBody.isSuccess()) {
throw new RuntimeException("reponse is not success");
}
JSONObject data = ret.getData();
NewsFeedResReq newsFeedResReq = new NewsFeedResReq();
newsFeedResReq.setRelId(data.getString("fileId"));
newsFeedResReq.setRelType(Integer.parseInt(RelTypeEnum.IMAGE_FILE.type));
newsFeedResReq.setRemark(data.getString("fileurl"));
HashMap<String, String> data = responseBody.getData();
return NewsFeedResReq.builder().relId(data.get("fileId"))
.relType(Integer.parseInt(RelTypeEnum.IMAGE_FILE.type))
.remark(data.get("fileurl")).build();
return newsFeedResReq;
} catch (Exception e) {
log.error("error in handleSyncImg for imgUrl: {}", img.getRemark(), e);
......
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