package com.caimei.www.controller.unlimited; import com.caimei.www.controller.BaseController; import com.caimei.www.pojo.JsonModel; import com.caimei.www.pojo.page.BaseLink; import com.caimei.www.pojo.page.ImageLink; import com.caimei.www.service.ArticleService; import com.github.pagehelper.PageInfo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import java.util.List; /** * 文章页鉴于seo,保留旧链接 * * @author : Charles * @date : 2020/7/31 */ @Controller public class ArticleController extends BaseController { private static final String ARTICLE_LIST_PATH = "article/list"; private static final String ARTICLE_DETAIL_PATH = "article/detail"; private ArticleService articleService; @Autowired public void setArticleService(ArticleService articleService) { this.articleService = articleService; } /** * 文章列表【旧center】 */ @GetMapping("/info/center-{id}-1.html") public String toArticleList(@PathVariable("id") Integer id, final Model model) { List typeList = articleService.getArticleTypes(); model.addAttribute("articleType", typeList); model.addAttribute("typeId", id); model.addAttribute("labelId", 0); return ARTICLE_LIST_PATH; } /** * 文章列表【旧label】 */ @GetMapping("/info/label-{id}-1.html") public String toArticleLabel(@PathVariable("id") Integer id, final Model model) { List typeList = articleService.getArticleTypes(); model.addAttribute("articleType", typeList); model.addAttribute("typeId", 0); model.addAttribute("labelId", id); return ARTICLE_LIST_PATH; } /** * 文章搜索结果 */ @GetMapping("/info/search.html") public String toArticleSearch(final Model model) { List typeList = articleService.getArticleTypes(); model.addAttribute("articleType", typeList); model.addAttribute("typeId", 0); model.addAttribute("labelId", 0); return ARTICLE_LIST_PATH; } /** * 文章详情【旧】 */ @GetMapping("/info/detail-{id}-1.html") public String toArticleDetail(@PathVariable("id") Integer id, final Model model) { model.addAttribute("articleId", id); return ARTICLE_DETAIL_PATH; } /** * 获取文章热门标签 */ @GetMapping("/article/labels") @ResponseBody public JsonModel> getArticleLabels() { return articleService.getArticleLabels(); } /** * 获取文章推荐 */ @GetMapping("/article/recommend") @ResponseBody public JsonModel> getArticleRecommended(Integer typeId, @RequestParam(value = "pageNum", defaultValue = "1") int pageNum, @RequestParam(value = "pageSize", defaultValue = "3") int pageSize) { return articleService.getArticleRecommended(typeId, pageNum, pageSize); } /** * 获取文章广告 */ @GetMapping("/article/ads") @ResponseBody public JsonModel> getLastestInfoAds() { return articleService.getLastestInfoAds(); } /** * 点击标签 */ @GetMapping("/article/label/click") @ResponseBody public JsonModel clickArticleLabel(Integer id){ return articleService.clickArticleLabel(id); } /** * 点击广告 */ @GetMapping("/article/ad/click") @ResponseBody public JsonModel clickArticleAd(Integer id){ return articleService.clickArticleAd(id); } }