package com.yc.education.controller.admin;/**
 * huangpan
 * 2019/10/14
 * energy
 */

import com.yc.education.model.Contactclassify;
import com.yc.education.service.ContactclassifyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

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

/**
 *@ClassName ContactClassifyController
 *@Description TODO
 *@Author QuZhangJing
 *@Date 2019/10/14 18:37
 *@Version 1.0
 */
@Controller
@RequestMapping("/admin/")
public class ContactClassifyController {
    @Autowired
    ContactclassifyService contactclassifyService;

    /*查询所有*/
    @RequestMapping("cClassify-list.html")
    public ModelAndView getCclassify(){
        ModelAndView modelAndView=new ModelAndView();
        List<Contactclassify> cclassify = contactclassifyService.getCclassify();
        modelAndView.addObject("cclassify", cclassify);
        return modelAndView;

    }
    /*查看单条信息*/
    @RequestMapping("cClassifyById.html")
    public ModelAndView getCclassifyById(Integer id){
        ModelAndView modelAndView=new ModelAndView("admin/cClassify-update");
       /* Contactus contactclassifyById = contactclassifyService.getContactclassifyById(id);*/
        Contactclassify contactclassifyById = contactclassifyService.getContactclassifyById(id);
        modelAndView.addObject("contactclassifyById", contactclassifyById);
        return modelAndView;
    }
    /*执行修改*/
    @RequestMapping("cClassify-update.html")
    public void updateCclassify(Contactclassify contactclassify, HttpServletResponse response)throws  Exception{
        contactclassifyService.updateNotNull(contactclassify);
        response.sendRedirect("cClassify-list.html");
    }

    /*跳转新增*/
    @RequestMapping("cClassify-add.html")
    public ModelAndView cClassifyAdd(){return new ModelAndView();}

    /*执行新增*/
    @RequestMapping("cClassify-save.html")
    public void saveCclassify(Contactclassify contactclassify, HttpServletResponse response)throws  Exception{
        contactclassifyService.save(contactclassify);
        response.sendRedirect("cClassify-list.html");
    }
    /*执行删除*/
    @RequestMapping("delCclassify.html")
    @ResponseBody
    public void delCclassify(Integer id){
        contactclassifyService.delContactclassifyById(id);
    }
}
