package com.jeesite.modules.cmsfront.web;

import com.jeesite.common.web.BaseController;
import com.jeesite.modules.cms.entity.Category;
import com.jeesite.modules.cms.entity.Site;
import com.jeesite.modules.cms.service.ArticleService;
import com.jeesite.modules.cms.service.CategoryService;
import com.jeesite.modules.cms.service.CommentService;
import com.jeesite.modules.cms.utils.CmsUtils;
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.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@Controller
@RequestMapping(value = "${adminPath}/news")
public class CmsPortalController extends BaseController {


    @Autowired
    private CategoryService categoryService;
    @Autowired
    private ArticleService articleService;
    @Autowired
    private CommentService commentService;


    /**
     * 站点首页
     */
    @GetMapping("/index")
    public String index( @RequestParam(required = false, defaultValue = "1") Integer pageNo,
                        @RequestParam(required = false, defaultValue = "30") Integer pageSize, Model model,
                        HttpServletRequest request) {

        Category category = CmsUtils.getCategory("hbjmdx");
        // 获取站点信息
        Site site = CmsUtils.getSite(category.getSite().getId());

        // 当前栏目的子栏目列表
        List<Category> categoryList = null;
        //获取到栏目列表
        Category categoryParam = new Category();
        categoryParam.setSite(new Site(site.getSiteCode()));
        categoryParam.setParentCode(category.getCategoryCode());
        categoryList = categoryService.findList(categoryParam);
        model.addAttribute("site", site);
        model.addAttribute("categoryList", categoryList);
        return "modules/jmdxmh/zxzx/zxzx";
    }





}
