package com.jkcredit.sysnews.resource.biz.newsArticle; 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.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.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(@PathVariable Long id) { try { List newsArticleVoList = newsArticleService.getNewsArticleByNavigationBarId(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("获取新闻信息失败"); } } }