|
@ -579,10 +579,18 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit |
|
|
try { |
|
|
try { |
|
|
ArticleCoverEntity articleCoverEntity = articleCoverDao.selectByArticleId(formDTO.getArticleId()); |
|
|
ArticleCoverEntity articleCoverEntity = articleCoverDao.selectByArticleId(formDTO.getArticleId()); |
|
|
ArticleContentEntity articleContentEntity = articleContentDao.selectByArticleId(formDTO.getArticleId()); |
|
|
ArticleContentEntity articleContentEntity = articleContentDao.selectByArticleId(formDTO.getArticleId()); |
|
|
ElasticsearchArticleDTO elasticsearchArticleDTO = ElasticsearchArticleDTO.builder().id(articleEntity.getId()).author(articleEntity.getPublisherName()) |
|
|
ElasticsearchArticleDTO elasticsearchArticleDTO = ElasticsearchArticleDTO.builder() |
|
|
.abstracts(articleEntity.getPreviewContent()).category("ARTICLE").title(articleEntity.getTitle()) |
|
|
.id(articleEntity.getId()) |
|
|
.content(articleContentEntity.getContent()).source(articleEntity.getPublisherName()).updateDate(String.valueOf(articleEntity.getUpdatedTime())) |
|
|
.author(articleEntity.getPublisherName()) |
|
|
.thumbnail(articleCoverEntity.getImgUrl()).uri("/aritcle/"+articleEntity.getId()).gridIdList(formDTO.getGridIdList()).build(); |
|
|
.abstracts(articleEntity.getPreviewContent()) |
|
|
|
|
|
.category("ARTICLE") |
|
|
|
|
|
.title(articleEntity.getTitle()) |
|
|
|
|
|
.content(articleContentEntity.getContent()) |
|
|
|
|
|
.source(articleEntity.getPublisherName()) |
|
|
|
|
|
.updateDate(String.valueOf(articleEntity.getUpdatedTime())) |
|
|
|
|
|
.thumbnail(articleCoverEntity.getImgUrl()) |
|
|
|
|
|
.uri("/aritcle/"+articleEntity.getId()) |
|
|
|
|
|
.gridIdList(formDTO.getGridIdList()).build(); |
|
|
if (elasticsearchUtils.addArticle(elasticsearchArticleDTO)){ |
|
|
if (elasticsearchUtils.addArticle(elasticsearchArticleDTO)){ |
|
|
//删除成功
|
|
|
//删除成功
|
|
|
log.info("文章添加,更新es成功"); |
|
|
log.info("文章添加,更新es成功"); |
|
@ -1655,10 +1663,18 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit |
|
|
} |
|
|
} |
|
|
// 9.更新es
|
|
|
// 9.更新es
|
|
|
try { |
|
|
try { |
|
|
ElasticsearchArticleDTO elasticsearchArticleDTO = ElasticsearchArticleDTO.builder().id(article.getId()).author(article.getPublisherName()) |
|
|
ElasticsearchArticleDTO elasticsearchArticleDTO = ElasticsearchArticleDTO.builder() |
|
|
.abstracts(article.getPreviewContent()).category("ARTICLE").title(article.getTitle()) |
|
|
.id(article.getId()) |
|
|
.content(articleContent.getContent()).source(article.getPublisherName()).updateDate(String.valueOf(article.getUpdatedTime())) |
|
|
.author(article.getPublisherName()) |
|
|
.thumbnail(formDTO.getImgUrl()).uri("/aritcle/"+article.getId()).gridIdList(formDTO.getGridIdList()).build(); |
|
|
.abstracts(article.getPreviewContent()) |
|
|
|
|
|
.category("ARTICLE") |
|
|
|
|
|
.title(article.getTitle()) |
|
|
|
|
|
.content(articleContent.getContent()) |
|
|
|
|
|
.source(article.getPublisherName()) |
|
|
|
|
|
.updateDate(String.valueOf(article.getUpdatedTime())) |
|
|
|
|
|
.thumbnail(formDTO.getImgUrl()) |
|
|
|
|
|
.uri("/aritcle/"+article.getId()) |
|
|
|
|
|
.gridIdList(formDTO.getGridIdList()).build(); |
|
|
if (elasticsearchUtils.addArticle(elasticsearchArticleDTO)){ |
|
|
if (elasticsearchUtils.addArticle(elasticsearchArticleDTO)){ |
|
|
//删除成功
|
|
|
//删除成功
|
|
|
log.info("文章添加,更新es成功"); |
|
|
log.info("文章添加,更新es成功"); |
|
@ -2138,4 +2154,66 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit |
|
|
PageInfo<ArticleLatestResultDTO> pageInfo = new PageInfo<>(list); |
|
|
PageInfo<ArticleLatestResultDTO> pageInfo = new PageInfo<>(list); |
|
|
return new PageData<>(list, pageInfo.getTotal()); |
|
|
return new PageData<>(list, pageInfo.getTotal()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 初始化ES索引 |
|
|
|
|
|
* article 文章表 |
|
|
|
|
|
* article_content 文章内容表 |
|
|
|
|
|
* article_cover 文章封面表 |
|
|
|
|
|
* article_operate_record 文章操作记录表 |
|
|
|
|
|
* article_publish_range 文章发布范围表 |
|
|
|
|
|
* article_tags 文章标签表 |
|
|
|
|
|
* article_visit_record 文章访问记录表 |
|
|
|
|
|
* @param customerId |
|
|
|
|
|
* @param currentOperUserId |
|
|
|
|
|
*/ |
|
|
|
|
|
@Override |
|
|
|
|
|
public void initIndex(String customerId, String currentOperUserId) { |
|
|
|
|
|
//1.ES删除该ducument下全部索引
|
|
|
|
|
|
if (elasticsearchUtils.deleteAllArticle(ElasticsearchArticleConstant.ARTICLE)){ |
|
|
|
|
|
//删除成功
|
|
|
|
|
|
log.info("删除文章索引ducument,更新es成功"); |
|
|
|
|
|
}else{ |
|
|
|
|
|
//删除失败
|
|
|
|
|
|
log.info("文章更新,更新es失败"); |
|
|
|
|
|
} |
|
|
|
|
|
//2.查询得到现在全部可用文章并添加至ES中
|
|
|
|
|
|
|
|
|
|
|
|
// ElasticsearchArticleDTO elasticsearchArticleDTO = ElasticsearchArticleDTO.builder().id(article.getId()).author(article.getPublisherName())
|
|
|
|
|
|
// .abstracts(article.getPreviewContent()).category("ARTICLE").title(article.getTitle())
|
|
|
|
|
|
// .content(articleContent.getContent()).source(article.getPublisherName()).updateDate(String.valueOf(article.getUpdatedTime()))
|
|
|
|
|
|
// .thumbnail(formDTO.getImgUrl()).uri("/aritcle/"+article.getId()).gridIdList(formDTO.getGridIdList()).build();
|
|
|
|
|
|
// LambdaQueryWrapper<ArticleListFormDTO> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
|
// queryWrapper.eq(ArticleListFormDTO::getStatusFlag, ArticleConstant.PUBLISHED);
|
|
|
|
|
|
ArticleListFormDTO articleListFormDTO = new ArticleListFormDTO(); |
|
|
|
|
|
articleListFormDTO.setCustomerId(customerId); |
|
|
|
|
|
articleListFormDTO.setStatusFlag(ArticleConstant.PUBLISHED); |
|
|
|
|
|
List<PublishedListResultDTO> list = baseDao.selectAllArticle2(articleListFormDTO); |
|
|
|
|
|
List<ElasticsearchArticleDTO> elasticsearchArticleDTOList = new ArrayList<>(); |
|
|
|
|
|
for (PublishedListResultDTO publishedListResultDTO : list) { |
|
|
|
|
|
ElasticsearchArticleDTO elasticsearchArticleDTO = ElasticsearchArticleDTO.builder() |
|
|
|
|
|
.id(publishedListResultDTO.getArticleId()) |
|
|
|
|
|
.abstracts(publishedListResultDTO.getPreviewContent()) |
|
|
|
|
|
.author(publishedListResultDTO.getPublisherName()) |
|
|
|
|
|
.source(ElasticsearchArticleConstant.SHE_QU) |
|
|
|
|
|
.category(ElasticsearchArticleConstant.ARTICLE) |
|
|
|
|
|
.thumbnail(publishedListResultDTO.getImgUrl()) |
|
|
|
|
|
.updateDate(publishedListResultDTO.getPublishDate()) |
|
|
|
|
|
.content(publishedListResultDTO.getPreviewContent()) |
|
|
|
|
|
.title(publishedListResultDTO.getTitle()) |
|
|
|
|
|
.uri("/aritcle/"+publishedListResultDTO.getArticleId()) |
|
|
|
|
|
.gridIdList(publishedListResultDTO.getGridIdList()).build(); |
|
|
|
|
|
elasticsearchArticleDTOList.add(elasticsearchArticleDTO); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// List<ElasticsearchArticleDTO> elasticsearchArticleDTOList = list.stream()
|
|
|
|
|
|
// .map(ElasticsearchArticleDTO::new)
|
|
|
|
|
|
// .collect(Collectors.toList());
|
|
|
|
|
|
if (elasticsearchUtils.addAllArticle(elasticsearchArticleDTOList)){ |
|
|
|
|
|
log.info("初始化索引成功"); |
|
|
|
|
|
}else{ |
|
|
|
|
|
log.info("初始化索引异常"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|