NewsArticleBizResource.java 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. package com.jkcredit.sysnews.resource.biz.newsArticle;
  2. import com.baomidou.mybatisplus.core.metadata.IPage;
  3. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  4. import com.jkcredit.sysnews.model.dto.newsArticle.NewsArticleDto;
  5. import com.jkcredit.sysnews.model.vo.newsArticle.NewsArticleBizVo;
  6. import com.jkcredit.sysnews.model.vo.newsArticle.NewsArticleVo;
  7. import com.jkcredit.sysnews.resource.base.BizResource;
  8. import com.jkcredit.sysnews.resource.web.newsArticle.fb.NewsArticleQueryFB;
  9. import com.jkcredit.sysnews.service.newsArticle.NewsArticleService;
  10. import com.jkcredit.sysnews.spi.lang.exception.ServiceException;
  11. import com.jkcredit.sysnews.spi.web.data.ResponseData;
  12. import io.swagger.annotations.ApiOperation;
  13. import lombok.extern.slf4j.Slf4j;
  14. import org.springframework.beans.factory.annotation.Autowired;
  15. import org.springframework.security.access.prepost.PreAuthorize;
  16. import org.springframework.web.bind.annotation.GetMapping;
  17. import org.springframework.web.bind.annotation.PathVariable;
  18. import org.springframework.web.bind.annotation.RestController;
  19. import java.util.List;
  20. /**
  21. * @description:
  22. * @author: xusonglin
  23. * @create: 2020/3/16 15:20
  24. * @version: V1.0
  25. **/
  26. @Slf4j
  27. @RestController
  28. public class NewsArticleBizResource extends BizResource {
  29. @Autowired
  30. NewsArticleService newsArticleService;
  31. @GetMapping("/newsArticles/{id}")
  32. @ApiOperation("用户展示页面-根据模块id获取新闻")
  33. public ResponseData getNewsArticlesByNavigationBarId(Page page, @PathVariable Long id) {
  34. try {
  35. IPage<NewsArticleBizVo> newsArticleVoList = newsArticleService.getNewsArticleByNavigationBarId(page, id);
  36. return ResponseData.success(newsArticleVoList);
  37. } catch (ServiceException e) {
  38. log.error(e.getMessage());
  39. return ResponseData.failed("获取新闻失败");
  40. }
  41. }
  42. @GetMapping("newsArticle/{id}")
  43. @ApiOperation("用户展示页面-根据新闻id获取新闻详情")
  44. public ResponseData getNewsArticleById(@PathVariable Long id) {
  45. try {
  46. NewsArticleVo newsArticleVo = newsArticleService.getNewsArticleById(id);
  47. return ResponseData.success(newsArticleVo);
  48. } catch (Exception e) {
  49. return ResponseData.failed("获取新闻信息失败");
  50. }
  51. }
  52. @GetMapping("newsArticles")
  53. @ApiOperation("用户展示页面-根据条件获取新闻")
  54. public ResponseData getNewsArticles(Page page, NewsArticleQueryFB queryFB) {
  55. try {
  56. NewsArticleDto newsArticleDto = mapper.map(queryFB, NewsArticleDto.class);
  57. IPage<NewsArticleBizVo> newsArticleVoIPage = newsArticleService.getBizNewsArticles(page, newsArticleDto);
  58. return ResponseData.success(newsArticleVoIPage);
  59. } catch (ServiceException e) {
  60. return ResponseData.failed("获取新闻列表失败");
  61. }
  62. }
  63. }