123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- 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<BaseLink> 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<BaseLink> 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<BaseLink> 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<List<BaseLink>> getArticleLabels() {
- return articleService.getArticleLabels();
- }
- /**
- * 获取文章推荐
- */
- @GetMapping("/article/recommend")
- @ResponseBody
- public JsonModel<PageInfo<ImageLink>> 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<List<ImageLink>> 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);
- }
- }
|