...
|
...
|
@@ -155,6 +155,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:";
|
...
|
...
|
@@ -215,6 +216,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());
|
...
|
...
|
@@ -347,7 +349,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;
|
|
|
}
|
...
|
...
|
@@ -369,7 +377,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());
|
...
|
...
|
@@ -381,7 +390,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());
|
...
|
...
|
@@ -663,6 +673,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);
|
|
|
|
|
|
//文章内容
|
...
|
...
|
@@ -1242,6 +1253,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);
|
...
|
...
|
@@ -1418,6 +1430,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());
|
...
|
...
|
@@ -1551,6 +1564,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<>();
|
...
|
...
|
@@ -1577,11 +1592,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)) {
|
...
|
...
|
@@ -1724,6 +1746,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());
|
...
|
...
|
@@ -1756,6 +1779,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);
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
...
|
...
|
@@ -1799,6 +1828,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);
|
...
|
...
|
@@ -1840,19 +1870,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"));
|
...
|
...
|
@@ -2035,12 +2064,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);
|
|
|
}
|
...
|
...
|
|