12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- package com.jkcredit.sysnews.resource.biz.newsArticle;
- import com.baomidou.mybatisplus.core.metadata.IPage;
- import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
- import com.jkcredit.sysnews.model.dto.newsArticle.NewsArticleDto;
- import com.jkcredit.sysnews.model.vo.newsArticle.NewsArticleBizVo;
- import com.jkcredit.sysnews.model.vo.newsArticle.NewsArticleVo;
- import com.jkcredit.sysnews.resource.base.BizResource;
- import com.jkcredit.sysnews.resource.web.newsArticle.fb.NewsArticleQueryFB;
- import com.jkcredit.sysnews.service.newsArticle.NewsArticleService;
- import com.jkcredit.sysnews.spi.lang.exception.ServiceException;
- import com.jkcredit.sysnews.spi.web.data.ResponseData;
- import io.swagger.annotations.ApiOperation;
- import lombok.extern.slf4j.Slf4j;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.security.access.prepost.PreAuthorize;
- import org.springframework.web.bind.annotation.GetMapping;
- import org.springframework.web.bind.annotation.PathVariable;
- import org.springframework.web.bind.annotation.RestController;
- import java.util.List;
- /**
- * @description:
- * @author: xusonglin
- * @create: 2020/3/16 15:20
- * @version: V1.0
- **/
- @Slf4j
- @RestController
- public class NewsArticleBizResource extends BizResource {
- @Autowired
- NewsArticleService newsArticleService;
- @GetMapping("/newsArticles/{id}")
- @ApiOperation("用户展示页面-根据模块id获取新闻")
- public ResponseData getNewsArticlesByNavigationBarId(Page page, @PathVariable Long id) {
- try {
- IPage<NewsArticleBizVo> newsArticleVoList = newsArticleService.getNewsArticleByNavigationBarId(page, id);
- return ResponseData.success(newsArticleVoList);
- } catch (ServiceException e) {
- log.error(e.getMessage());
- return ResponseData.failed("获取新闻失败");
- }
- }
- @GetMapping("newsArticle/{id}")
- @ApiOperation("用户展示页面-根据新闻id获取新闻详情")
- public ResponseData getNewsArticleById(@PathVariable Long id) {
- try {
- NewsArticleVo newsArticleVo = newsArticleService.getNewsArticleById(id);
- return ResponseData.success(newsArticleVo);
- } catch (Exception e) {
- return ResponseData.failed("获取新闻信息失败");
- }
- }
- @GetMapping("newsArticles")
- @ApiOperation("用户展示页面-根据条件获取新闻")
- public ResponseData getNewsArticles(Page page, NewsArticleQueryFB queryFB) {
- try {
- NewsArticleDto newsArticleDto = mapper.map(queryFB, NewsArticleDto.class);
- IPage<NewsArticleBizVo> newsArticleVoIPage = newsArticleService.getBizNewsArticles(page, newsArticleDto);
- return ResponseData.success(newsArticleVoIPage);
- } catch (ServiceException e) {
- return ResponseData.failed("获取新闻列表失败");
- }
- }
- }
|