package com.yc.education.controller.admin;

import org.springframework.stereotype.Controller;

/**
 * huangpan
 * 2019/10/9
 * energy
 */
@Controller
public class ProductController {
  /*  @Autowired
    ProductService productService;

    @Autowired
    ProductclassifyService productclassifyService;

    *//*查询所有*//*
    @RequestMapping("admin/product-list.html")
    public ModelAndView selAllProduct(@RequestParam(value = "pageNum",defaultValue = "1") Integer pageNum ,
                                      @RequestParam(value = "pageSize",defaultValue = "10") Integer pageSize, Integer produtId, HttpSession session){
        ModelAndView modelAndView=new ModelAndView();
        List<Product> products = productService.selAllProduct(produtId, pageNum, pageSize);
        modelAndView.addObject("pageInfo", new PageInfo<>(products));
        session.removeAttribute("proId");
        session.setAttribute("proId", produtId);
        System.out.println(produtId+"====================lwh");
       *//* modelAndView.addObject("proId", id);*//*
        return modelAndView;
    }
    *//*修改信息*//*
    @RequestMapping("admin/productById.html")
    public ModelAndView selProductById(Integer id){
        ModelAndView modelAndView=new ModelAndView("admin/product-update");
        Product product = productService.selProductById(id);
        modelAndView.addObject("product", product);
        return modelAndView;
    }
    *//*执行修改*//*
    @RequestMapping("admin/product-update.html")
    public ModelAndView updateProduct(Product product,HttpSession session){
        product.setCfpid(Integer.parseInt(session.getAttribute("proId").toString()));
        System.out.println(product.getCfpid()+"cfpid+lwh");
        productService.updateNotNull(product);
        return new ModelAndView("redirect:product-list.html?produtId="+product.getCfpid());
    }
    *//*新增信息*//*
    @RequestMapping("admin/product-add.html")
    public ModelAndView addProduct(Integer produtId) {
        ModelAndView modelAndView=new ModelAndView();
        modelAndView.addObject("produtId", produtId);
        return  modelAndView;
    }
    *//*执行新增*//*
    @RequestMapping("admin/product-save.html")
    public ModelAndView saveProduct(Product product){
        Productclassify productclassify=new Productclassify();
        productclassify.setPfid(product.getCfpid());
        productclassify.setCats(2);
        productclassifyService.save(productclassify);
        int pclassifyById = productclassifyService.getPclassifyById();
        product.setId(pclassifyById);
       int proCount= productService.save(product);
        if(proCount<1)
            productclassifyService.deletePclassifyById(pclassifyById);
        return new ModelAndView("redirect:product-list.html?produtId="+product.getCfpid());
    }
    *//*删除*//*
    @RequestMapping("admin/delproductById.html")
    @ResponseBody
    public void delProductById(@RequestParam( value = "id")Integer id){
        productService.deleteProductById(id);
        productclassifyService.deletePclassifyById(id);
    }*/
}
