package com.yc.education.controller;

import com.yc.education.model.NewsType;
import com.yc.education.model.ServiceSupport;
import com.yc.education.model.SuccessCase;
import com.yc.education.service.INewsTypeService;
import com.yc.education.service.IServiceSupportService;
import com.yc.education.service.ISuccessCaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import java.util.List;

/**
 * 服务支持控制层
 * @author Hickey
 * @create 2019-07-29 10:39
 */
@Controller
public class ServiceController {

    @Autowired
    private IServiceSupportService iService;

    @Autowired
    private ISuccessCaseService iSuccessCaseService;

    @Autowired
    private INewsTypeService  iNewsTypeService;

    @RequestMapping("service.html")
    public ModelAndView  serviceSupport(Integer id){

        ModelAndView mav  =  new ModelAndView();

        NewsType findId =  iNewsTypeService.listIdByWeight();//查询类别中权重最大的类别id,传给新闻中心界面
        mav.addObject("findId",findId);

        List<ServiceSupport>   allService  =  iService.listAllService();//查询所有服务
        mav.addObject("allService",allService);

        List<SuccessCase> listCaseByState  =  iSuccessCaseService.findCaseByState();//根据案例状态 查询要推荐的案例
        mav.addObject("listCaseByState",listCaseByState);

        ServiceSupport  serviceSupport  = iService.selectByKey(id);//根据服务支持id查其内容
        mav.addObject("serviceSupport",serviceSupport);


        return  mav;
    }
}
