package com.yc.education.controller.user;

import com.yc.education.model.Banners;
import com.yc.education.model.Classify01;
import com.yc.education.model.Designs;
import com.yc.education.model.News;
import com.yc.education.service.BannersService;
import com.yc.education.service.Classify01Service;
import com.yc.education.service.DesignsService;
import com.yc.education.service.NewsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.*;

@Controller
public class INewsWapController {

    @Autowired
    private NewsService newsService;

    @Autowired
    private Classify01Service classify01Service;

    @Autowired
    private DesignsService designsService;

    @Autowired
    private BannersService bannersService;

    /*首页跳转*/
    @RequestMapping("index_wap.html")
    public String index(Model model){
        List<Banners> list02 = bannersService.findAllBanners();
        model.addAttribute("list02",list02);
        return "hsawap/index_wap";
    }

    /*前端查询*/
    @RequestMapping("news_wap.html")
    public ModelAndView selNews(){
        ModelAndView modelAndView=new ModelAndView("hsawap/news_wap");
        List<News> news = newsService.selNews();
        modelAndView.addObject("news",news);
        modelAndView.addObject("type",3 );
        Map<String,String> map = new HashMap<>();
        map.put("a","汉思动态");
        map.put("b","HSa News");
        modelAndView.addObject("type_sss",map);
        return modelAndView;
    }


    /*查询详情信息*/
    @RequestMapping("new_wap.html")
    public ModelAndView selNew(Integer id){
        ModelAndView modelAndView=new ModelAndView("hsawap/new_wap");
        News newsById = newsService.getNewsById(id);
        modelAndView.addObject("newsById", newsById);
        modelAndView.addObject("type",3 );
        Map<String,String> map = new HashMap<>();
        map.put("a","汉思动态");
        map.put("b","HSa News");
        modelAndView.addObject("type_sss",map);
        return modelAndView;
    }

    //公用部分
    @RequestMapping("footer_wap.html")
    public String footer(Model model){
        List<Classify01> list01 = classify01Service.findAllClass01();
        List<Designs> list02 = designsService.findDesignsAll();
        model.addAttribute("list01",list01);
        model.addAttribute("list02",list02);
        return "hsawap/footer_wap";}
}
