diff --git a/src/main/java/com/rymcu/vertical/dto/ArticleDTO.java b/src/main/java/com/rymcu/vertical/dto/ArticleDTO.java index aaa0759..ac89644 100644 --- a/src/main/java/com/rymcu/vertical/dto/ArticleDTO.java +++ b/src/main/java/com/rymcu/vertical/dto/ArticleDTO.java @@ -50,8 +50,6 @@ public class ArticleDTO { private List tags; - private List articleComments; - private List portfolios; private Integer sortNo; diff --git a/src/main/java/com/rymcu/vertical/dto/ArticleSearchDTO.java b/src/main/java/com/rymcu/vertical/dto/ArticleSearchDTO.java new file mode 100644 index 0000000..1e3bb6f --- /dev/null +++ b/src/main/java/com/rymcu/vertical/dto/ArticleSearchDTO.java @@ -0,0 +1,17 @@ +package com.rymcu.vertical.dto; + +import lombok.Data; + +/** + * @author ronger + */ +@Data +public class ArticleSearchDTO { + + private String searchText; + + private String topicUri; + + private String tag; + +} diff --git a/src/main/java/com/rymcu/vertical/mapper/ArticleMapper.java b/src/main/java/com/rymcu/vertical/mapper/ArticleMapper.java index 6194cee..8c74ece 100644 --- a/src/main/java/com/rymcu/vertical/mapper/ArticleMapper.java +++ b/src/main/java/com/rymcu/vertical/mapper/ArticleMapper.java @@ -19,9 +19,10 @@ public interface ArticleMapper extends Mapper
{ * 获取文章列表 * @param searchText * @param tag + * @param topicUri * @return */ - List selectArticles(@Param("searchText") String searchText, @Param("tag") String tag); + List selectArticles(@Param("searchText") String searchText, @Param("tag") String tag, @Param("topicUri") String topicUri); /** * 根据文章 ID 查询文章 diff --git a/src/main/java/com/rymcu/vertical/service/ArticleService.java b/src/main/java/com/rymcu/vertical/service/ArticleService.java index 497cdf8..65f6718 100644 --- a/src/main/java/com/rymcu/vertical/service/ArticleService.java +++ b/src/main/java/com/rymcu/vertical/service/ArticleService.java @@ -2,6 +2,7 @@ package com.rymcu.vertical.service; import com.rymcu.vertical.core.service.Service; import com.rymcu.vertical.dto.ArticleDTO; +import com.rymcu.vertical.dto.ArticleSearchDTO; import com.rymcu.vertical.entity.Article; import com.rymcu.vertical.web.api.exception.BaseApiException; @@ -17,11 +18,10 @@ public interface ArticleService extends Service
{ /** * 根据检索内容/标签查询文章列表 - * @param searchText - * @param tag + * @param searchDTO * @return * */ - List findArticles(String searchText, String tag); + List findArticles(ArticleSearchDTO searchDTO); /** * 查询文章详情信息 diff --git a/src/main/java/com/rymcu/vertical/service/impl/ArticleServiceImpl.java b/src/main/java/com/rymcu/vertical/service/impl/ArticleServiceImpl.java index 271c40d..a041b7f 100644 --- a/src/main/java/com/rymcu/vertical/service/impl/ArticleServiceImpl.java +++ b/src/main/java/com/rymcu/vertical/service/impl/ArticleServiceImpl.java @@ -52,10 +52,16 @@ public class ArticleServiceImpl extends AbstractService
implements Arti private static final int MAX_PREVIEW = 200; private static final String defaultStatus = "0"; + private static final String defaultTopicUri = "news"; @Override - public List findArticles(String searchText, String tag) { - List list = articleMapper.selectArticles(searchText, tag); + public List findArticles(ArticleSearchDTO searchDTO) { + List list; + if (StringUtils.isNotBlank(searchDTO.getTopicUri()) && !defaultTopicUri.equals(searchDTO.getTopicUri())) { + list = articleMapper.selectArticlesByTopicUri(searchDTO.getTopicUri()); + } else { + list = articleMapper.selectArticles(searchDTO.getSearchText(), searchDTO.getTag(), searchDTO.getTopicUri()); + } list.forEach(article->{ genArticle(article,0); }); @@ -292,9 +298,6 @@ public class ArticleServiceImpl extends AbstractService
implements Arti ArticleContent articleContent = articleMapper.selectArticleContent(article.getIdArticle()); if (type.equals(ARTICLE_VIEW)){ article.setArticleContent(articleContent.getArticleContentHtml()); - // 获取评论列表数据 - List commentDTOList = commentService.getArticleComments(article.getIdArticle()); - article.setArticleComments(commentDTOList); // 获取所属作品集列表数据 List portfolioArticleDTOList = articleMapper.selectPortfolioArticles(article.getIdArticle()); article.setPortfolios(portfolioArticleDTOList); diff --git a/src/main/java/com/rymcu/vertical/web/api/common/CommonApiController.java b/src/main/java/com/rymcu/vertical/web/api/common/CommonApiController.java index 722b5bc..34f4971 100644 --- a/src/main/java/com/rymcu/vertical/web/api/common/CommonApiController.java +++ b/src/main/java/com/rymcu/vertical/web/api/common/CommonApiController.java @@ -43,14 +43,14 @@ public class CommonApiController { @GetMapping("/get-email-code") public GlobalResult> getEmailCode(@RequestParam("email") String email) throws MessagingException { Map map = new HashMap<>(1); - map.put("message",GlobalResultMessage.SEND_SUCCESS.getMessage()); + map.put("message", GlobalResultMessage.SEND_SUCCESS.getMessage()); User user = userService.findByAccount(email); if (user != null) { map.put("message","该邮箱已被注册!"); } else { Integer result = javaMailService.sendEmailCode(email); if(result == 0){ - map.put("message",GlobalResultMessage.SEND_FAIL.getMessage()); + map.put("message", GlobalResultMessage.SEND_FAIL.getMessage()); } } return GlobalResultGenerator.genSuccessResult(map); @@ -60,12 +60,12 @@ public class CommonApiController { @GetMapping("/get-forget-password-email") public GlobalResult> getForgetPasswordEmail(@RequestParam("email") String email) throws MessagingException { Map map = new HashMap<>(1); - map.put("message",GlobalResultMessage.SEND_SUCCESS.getMessage()); + map.put("message", GlobalResultMessage.SEND_SUCCESS.getMessage()); User user = userService.findByAccount(email); if (user != null) { Integer result = javaMailService.sendForgetPasswordEmail(email); if(result == 0){ - map.put("message",GlobalResultMessage.SEND_FAIL.getMessage()); + map.put("message", GlobalResultMessage.SEND_FAIL.getMessage()); } } else { map.put("message","该邮箱未注册!"); @@ -92,9 +92,9 @@ public class CommonApiController { @GetMapping("/articles") @VisitLogger - public GlobalResult articles(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows, @RequestParam(defaultValue = "") String searchText, @RequestParam(defaultValue = "") String tag){ + public GlobalResult articles(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows, ArticleSearchDTO searchDTO){ PageHelper.startPage(page, rows); - List list = articleService.findArticles(searchText,tag); + List list = articleService.findArticles(searchDTO); PageInfo pageInfo = new PageInfo(list); Map map = Utils.getArticlesGlobalResult(pageInfo); return GlobalResultGenerator.genSuccessResult(map);