🎨 专题页代码结构完善

This commit is contained in:
x ronger 2020-03-24 01:05:03 +08:00
parent 4736f383ce
commit 33d7856bd5
2 changed files with 9 additions and 8 deletions

View File

@ -26,10 +26,10 @@ public interface ArticleService extends Service<Article> {
/**
* 查询文章详情信息
* @param id
* @param i
* @param type
* @return
* */
ArticleDTO findArticleDTOById(Integer id, int i);
ArticleDTO findArticleDTOById(Integer id, Integer type);
/**
* 查询主题下文章列表

View File

@ -66,7 +66,7 @@ public class ArticleServiceImpl extends AbstractService<Article> implements Arti
}
@Override
public ArticleDTO findArticleDTOById(Integer id, int type) {
public ArticleDTO findArticleDTOById(Integer id, Integer type) {
ArticleDTO articleDTO = articleMapper.selectArticleDTOById(id,type);
if (articleDTO == null) {
return null;
@ -78,6 +78,9 @@ public class ArticleServiceImpl extends AbstractService<Article> implements Arti
@Override
public List<ArticleDTO> findArticlesByTopicUri(String name) {
List<ArticleDTO> articleDTOS = articleMapper.selectArticlesByTopicUri(name);
articleDTOS.forEach(articleDTO -> {
genArticle(articleDTO,0);
});
return articleDTOS;
}
@ -266,16 +269,14 @@ public class ArticleServiceImpl extends AbstractService<Article> implements Arti
article.setTimeAgo(Utils.getTimeAgo(article.getUpdatedTime()));
List<ArticleTagDTO> tags = articleMapper.selectTags(article.getIdArticle());
article.setTags(tags);
if(type == 1){
ArticleContent articleContent = articleMapper.selectArticleContent(article.getIdArticle());
ArticleContent articleContent = articleMapper.selectArticleContent(article.getIdArticle());
if (type == 1){
article.setArticleContent(articleContent.getArticleContentHtml());
} else if(type == 2){
ArticleContent articleContent = articleMapper.selectArticleContent(article.getIdArticle());
} else if (type == 2) {
article.setArticleContent(articleContent.getArticleContent());
}
if(StringUtils.isBlank(article.getArticlePreviewContent())){
ArticleContent articleContent = articleMapper.selectArticleContent(article.getIdArticle());
Integer length = articleContent.getArticleContentHtml().length();
if(length > MAX_PREVIEW){
length = 200;