...
|
...
|
@@ -149,6 +149,7 @@ public class GrassArticleServiceImpl implements IGrassArticleService { |
|
|
private final static String BLOCK_LINK = "link";
|
|
|
private final static String BLOCK_VIDEO = "video";
|
|
|
private final static String BLOCK_COVER = "coverImage";
|
|
|
private final static String BLOCK_COVER_F = "coverImage_flat";
|
|
|
|
|
|
//记录某一天@用户的推送次数
|
|
|
private final static String ATINBOX_SEND_TIMES_INTEL_IN_DAY = "yh:msg:ATINBOX_SEND_TIMES_INTEL_IN_DAY:";
|
...
|
...
|
@@ -209,6 +210,7 @@ public class GrassArticleServiceImpl implements IGrassArticleService { |
|
|
article.setArticleTitle(req.getTitle());
|
|
|
article.setFlowType(req.getFlowType());
|
|
|
article.setDispatchChannel(req.getDispatchChannel());
|
|
|
article.setProductLink(req.getProductLink());
|
|
|
try {
|
|
|
grassArticleDao.insertArticleSeletive(article);
|
|
|
logger.info("insert grass article success, uid is {}, ariticle id is {}", article.getAuthorUid(), article.getId());
|
...
|
...
|
@@ -341,7 +343,13 @@ public class GrassArticleServiceImpl implements IGrassArticleService { |
|
|
dataObject.put("width", 1);
|
|
|
dataObject.put("height", 1);
|
|
|
break;
|
|
|
|
|
|
case BLOCK_COVER_F:
|
|
|
String cover = convertImageUrlWithDefault(data);
|
|
|
// JSONObject imageInfo = getImageInfoFromQN(data);
|
|
|
dataObject.put("src", cover);
|
|
|
dataObject.put("width", 1);
|
|
|
dataObject.put("height", 1);
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
...
|
...
|
@@ -363,7 +371,8 @@ public class GrassArticleServiceImpl implements IGrassArticleService { |
|
|
List<GrassArticleBlock> blockList = grassArticleBlockDao.selectByArticleId(articleId);
|
|
|
Map<String, Future<JSONObject>> map = Maps.newConcurrentMap();
|
|
|
for (GrassArticleBlock block : blockList) {
|
|
|
if (!block.getTemplateKey().equals("image") && !block.getTemplateKey().equals("coverImage")) {
|
|
|
if (!block.getTemplateKey().equals("image") && !block.getTemplateKey().equals("coverImage")
|
|
|
&& !block.getTemplateKey().equals(BLOCK_COVER_F)) {
|
|
|
continue;
|
|
|
}
|
|
|
JSONObject object = JSONObject.parseObject(block.getContentData());
|
...
|
...
|
@@ -375,7 +384,8 @@ public class GrassArticleServiceImpl implements IGrassArticleService { |
|
|
}
|
|
|
List<GrassArticleBlock> needUpdateBlocks = Lists.newArrayList();
|
|
|
for (GrassArticleBlock block : blockList) {
|
|
|
if (!block.getTemplateKey().equals("image") && !block.getTemplateKey().equals("coverImage")) {
|
|
|
if (!block.getTemplateKey().equals("image") && !block.getTemplateKey().equals("coverImage")
|
|
|
&& !block.getTemplateKey().equals(BLOCK_COVER_F)) {
|
|
|
continue;
|
|
|
}
|
|
|
JSONObject object = JSONObject.parseObject(block.getContentData());
|
...
|
...
|
@@ -657,6 +667,7 @@ public class GrassArticleServiceImpl implements IGrassArticleService { |
|
|
grassArticle.setArticleTitle(req.getTitle());
|
|
|
grassArticle.setDispatchChannel(req.getDispatchChannel());
|
|
|
grassArticle.setFlowType(req.getFlowType());
|
|
|
grassArticle.setProductLink(req.getProductLink());
|
|
|
grassArticleDao.updateByPrimaryKeySelective(grassArticle);
|
|
|
|
|
|
//文章内容
|
...
|
...
|
@@ -1236,6 +1247,7 @@ public class GrassArticleServiceImpl implements IGrassArticleService { |
|
|
grassArticle.setCopyright(req.getCopyright());
|
|
|
grassArticle.setDispatchChannel(req.getDispatchChannel());
|
|
|
grassArticle.setFlowType(req.getFlowType());
|
|
|
grassArticle.setProductLink(req.getProductLink());
|
|
|
if (type == 3) {
|
|
|
time = Long.valueOf(publishTime) + new Random().nextInt(999);
|
|
|
grassArticle.setIsRecommend(1);
|
...
|
...
|
@@ -1412,6 +1424,7 @@ public class GrassArticleServiceImpl implements IGrassArticleService { |
|
|
article.setArticleTitle(req.getTitle());
|
|
|
article.setFlowType(req.getFlowType());
|
|
|
article.setDispatchChannel(req.getDispatchChannel());
|
|
|
article.setProductLink(req.getProductLink());
|
|
|
try {
|
|
|
grassArticleDao.insertArticleSeletive(article);
|
|
|
logger.info("insert grass article success, uid is {}, ariticle id is {}", article.getAuthorUid(), article.getId());
|
...
|
...
|
@@ -1545,6 +1558,8 @@ public class GrassArticleServiceImpl implements IGrassArticleService { |
|
|
//分发渠道,信息流结构
|
|
|
rspBo.setDispatchChannel(grassArticle.getDispatchChannel());
|
|
|
rspBo.setFlowType(grassArticle.getFlowType());
|
|
|
rspBo.setProductLink(grassArticle.getProductLink());
|
|
|
|
|
|
//1)文章内容
|
|
|
List<GrassArticleBlock> grassArticleContentList = grassArticleBlockDao.selectByArticleId(articleId);
|
|
|
List<String> imageList = new ArrayList<>();
|
...
|
...
|
@@ -1571,11 +1586,18 @@ public class GrassArticleServiceImpl implements IGrassArticleService { |
|
|
else if("video".equals(content.getTemplateKey())){
|
|
|
rspBo.setCoverImg(JSON.parseObject(data.getString("data")).getString("coverUrl"));
|
|
|
rspBo.setVideoUrl(JSON.parseObject(data.getString("data")).getString("videoUrl"));
|
|
|
}else if("coverImage".equals(content.getTemplateKey())){
|
|
|
String src = JSON.parseObject(JSON.parseObject(content.getContentData()).getString("data")).getString("src");
|
|
|
src = StringUtils.isEmpty(src) ? "" : src.substring(0, src.indexOf("?"));
|
|
|
rspBo.setCoverImgSquare(src);
|
|
|
}else if("coverImage_flat".equals(content.getTemplateKey())){
|
|
|
String src = JSON.parseObject(JSON.parseObject(content.getContentData()).getString("data")).getString("src");
|
|
|
src = StringUtils.isEmpty(src) ? "" : src.substring(0, src.indexOf("?"));
|
|
|
rspBo.setCoverImgFlat(src);
|
|
|
}
|
|
|
}
|
|
|
rspBo.setArticleContent(text);
|
|
|
rspBo.setImgList(imageList);
|
|
|
|
|
|
//2)关联的标签
|
|
|
List<GrassArticleLabel> labelList = grassArticleLabelDao.selectByArticleId(articleId);
|
|
|
if (CollectionUtils.isNotEmpty(labelList)) {
|
...
|
...
|
@@ -1716,6 +1738,7 @@ public class GrassArticleServiceImpl implements IGrassArticleService { |
|
|
Map<Integer,JSONObject> videoMap = Maps.newHashMap();
|
|
|
//笔记的封面图
|
|
|
Map<Integer,String> coverImageMap = Maps.newHashMap();
|
|
|
Map<Integer,String> coverImage2Map = Maps.newHashMap();
|
|
|
grassArticleContentList.forEach(content -> {
|
|
|
if ("image".equals(content.getTemplateKey())) {
|
|
|
List<String> images = imgMap.get(content.getArticleId());
|
...
|
...
|
@@ -1748,6 +1771,12 @@ public class GrassArticleServiceImpl implements IGrassArticleService { |
|
|
src = StringUtils.isEmpty(src) ? "" : src.substring(0, src.indexOf("?"));
|
|
|
coverImageMap.put(content.getArticleId(), src);
|
|
|
}
|
|
|
if("coverImage_flat".equals(content.getTemplateKey())){
|
|
|
JSONObject data = JSON.parseObject(content.getContentData());
|
|
|
String src = JSON.parseObject(data.getString("data")).getString("src");
|
|
|
src = StringUtils.isEmpty(src) ? "" : src.substring(0, src.indexOf("?"));
|
|
|
coverImageMap.put(content.getArticleId(), src);
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
...
|
...
|
@@ -1791,6 +1820,7 @@ public class GrassArticleServiceImpl implements IGrassArticleService { |
|
|
rspBo.setAuthTimeStr(DateUtil.long2DateStr(article.getAuthTime(), DateUtil.DATE_TIME_FORMAT));
|
|
|
rspBo.setAuthStatus(article.getAuthStatus());
|
|
|
rspBo.setSource(article.getArticleType());
|
|
|
rspBo.setProductLink(article.getProductLink());
|
|
|
/* if (article.getArticleType() == ArticleTypeEnum.NORMAL.getValue()) {//文章类型是1 的
|
|
|
if (vitualUids.contains(article.getAuthorUid())) {//属于马甲用户发布的
|
|
|
rspBo.setSource(6);
|
...
|
...
|
@@ -1831,19 +1861,18 @@ public class GrassArticleServiceImpl implements IGrassArticleService { |
|
|
rspBo.setHasPublished(article.getCreateTime() >= System.currentTimeMillis() ? "N" : "Y");
|
|
|
//拼接文章预览的url 类似:http://yoho-community-web.test3.ingress.dev.yohocorp.com/grass/article/1408536?type=preview
|
|
|
rspBo.setPreviewUrl(previewUrl + article.getId() + "?type=preview");
|
|
|
|
|
|
//笔记封面图 长文章
|
|
|
//如果没有单独的给笔记设置封面图,取图片列表的第一张作为封面图
|
|
|
String coverImage = imgMap.get(article.getId()).get(0);
|
|
|
rspBo.setCoverImg(coverImage);
|
|
|
|
|
|
//短视频封面图
|
|
|
if(sort == 4){
|
|
|
rspBo.setCoverImg(videoMap.get(article.getId()) == null ? "" : videoMap.get(article.getId()).getString("coverUrl"));
|
|
|
}
|
|
|
//笔记封面图
|
|
|
else if(sort == 1){
|
|
|
//如果没有单独的给笔记设置封面图,取图片列表的第一张作为封面图
|
|
|
String coverImage = coverImageMap.get(article.getId()) == null ? "" : coverImageMap.get(article.getId());
|
|
|
if(StringUtils.isEmpty(coverImage)){
|
|
|
coverImage = imgMap.get(article.getId()).get(0);
|
|
|
}
|
|
|
rspBo.setCoverImg(coverImage);
|
|
|
}
|
|
|
rspBo.setCoverImgSquare(coverImageMap.get(article.getId()));
|
|
|
rspBo.setCoverImgFlat(coverImage2Map.get(article.getId()));
|
|
|
//短视频url
|
|
|
rspBo.setVideoUrl(videoMap.get(article.getId()) == null ? "" : videoMap.get(article.getId()).getString("videoUrl"));
|
|
|
rspBo.setFileId(videoMap.get(article.getId()) == null ? "" : videoMap.get(article.getId()).getString("fileId"));
|
...
|
...
|
@@ -1999,12 +2028,21 @@ public class GrassArticleServiceImpl implements IGrassArticleService { |
|
|
}
|
|
|
}
|
|
|
//针对笔记的封面新增templateKey coverImage单独处理
|
|
|
if(sort == 1 && StringUtils.isNotEmpty(req.getCoverImage())){
|
|
|
if(StringUtils.isNotEmpty(req.getCoverImage())){
|
|
|
GrassArticleBlock content = new GrassArticleBlock();
|
|
|
content.setArticleId(articleId);
|
|
|
content.setContentData(getBlock(BLOCK_COVER, req.getCoverImage()));
|
|
|
content.setCreateTime(now);
|
|
|
content.setTemplateKey("coverImage");
|
|
|
content.setTemplateKey(BLOCK_COVER);
|
|
|
content.setOrderBy(0);
|
|
|
contentList.add(content);
|
|
|
}
|
|
|
if(StringUtils.isNotEmpty(req.getCoverImage2())){
|
|
|
GrassArticleBlock content = new GrassArticleBlock();
|
|
|
content.setArticleId(articleId);
|
|
|
content.setContentData(getBlock(BLOCK_COVER_F, req.getCoverImage2()));
|
|
|
content.setCreateTime(now);
|
|
|
content.setTemplateKey(BLOCK_COVER_F);
|
|
|
content.setOrderBy(0);
|
|
|
contentList.add(content);
|
|
|
}
|
...
|
...
|
|