NewsArticleBizResource.java 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package com.jkcredit.sysnews.resource.biz.newsArticle;
  2. import com.jkcredit.sysnews.model.vo.newsArticle.NewsArticleBizVo;
  3. import com.jkcredit.sysnews.model.vo.newsArticle.NewsArticleVo;
  4. import com.jkcredit.sysnews.resource.base.BizResource;
  5. import com.jkcredit.sysnews.service.newsArticle.NewsArticleService;
  6. import com.jkcredit.sysnews.spi.lang.exception.ServiceException;
  7. import com.jkcredit.sysnews.spi.web.data.ResponseData;
  8. import io.swagger.annotations.ApiOperation;
  9. import lombok.extern.slf4j.Slf4j;
  10. import org.springframework.beans.factory.annotation.Autowired;
  11. import org.springframework.web.bind.annotation.GetMapping;
  12. import org.springframework.web.bind.annotation.PathVariable;
  13. import org.springframework.web.bind.annotation.RestController;
  14. import java.util.List;
  15. /**
  16. * @description:
  17. * @author: xusonglin
  18. * @create: 2020/3/16 15:20
  19. * @version: V1.0
  20. **/
  21. @Slf4j
  22. @RestController
  23. public class NewsArticleBizResource extends BizResource {
  24. @Autowired
  25. NewsArticleService newsArticleService;
  26. @GetMapping("/newsArticles/{id}")
  27. @ApiOperation("用户展示页面-根据模块id获取新闻")
  28. public ResponseData getNewsArticlesByNavigationBarId(@PathVariable Long id) {
  29. try {
  30. List<NewsArticleBizVo> newsArticleVoList = newsArticleService.getNewsArticleByNavigationBarId(id);
  31. return ResponseData.success(newsArticleVoList);
  32. } catch (ServiceException e) {
  33. log.error(e.getMessage());
  34. return ResponseData.failed("获取新闻失败");
  35. }
  36. }
  37. @GetMapping("newsArticle/{id}")
  38. @ApiOperation("用户展示页面-根据新闻id获取新闻详情")
  39. public ResponseData getNewsArticleById(@PathVariable Long id) {
  40. try {
  41. NewsArticleVo newsArticleVo = newsArticleService.getNewsArticleById(id);
  42. return ResponseData.success(newsArticleVo);
  43. } catch (Exception e) {
  44. return ResponseData.failed("获取新闻信息失败");
  45. }
  46. }
  47. }