package com.yc.education.controller.admin;

import org.springframework.stereotype.Controller;

/**
 * huangpan
 * 2019/10/9
 * energy
 */
@Controller
public class ProductclassifyController {
  /*  @Autowired
    ProductclassifyService productclassifyService;

    *//*查询分类*//*
    @RequestMapping("admin/pclassify-list.html")
    public ModelAndView selAllPclassify(@RequestParam(value = "pageNum",defaultValue = "1") Integer pageNum ,
                                        @RequestParam(value = "pageSize",defaultValue = "10") Integer pageSize, String pName, Integer pid ,Integer casts,HttpSession session){
        ModelAndView modelAndView=new ModelAndView();
        List<Productclassify> productclassifies = productclassifyService.selAllPclassify(pid, pName, pageNum, pageSize);
        for (Productclassify item:productclassifies
             ) {
            int couts=productclassifyService.countPclassify(item.getId());
            item.setMuns(couts);
        }
        session.removeAttribute("tfId");
        session.setAttribute("ptfId", pid);
        session.setAttribute("casts", casts);
        modelAndView.addObject("pageInfo", new PageInfo<>(productclassifies));
        modelAndView.addObject("pName", pName);
        return modelAndView;
    }
    *//*修改信息*//*
    @RequestMapping("admin/pclassifyById.html")
    public  ModelAndView selPclassifyById(Integer id){
        ModelAndView modelAndView =new ModelAndView("admin/pclassify-update");
        Productclassify productclassify = productclassifyService.selectPclassifyById(id);
        modelAndView.addObject("productclassify", productclassify);
        return  modelAndView;
    }
    *//*执行修改*//*
    @RequestMapping("admin/pclassify-update.html")
    public ModelAndView updatePclassify(Productclassify productclassify, HttpServletRequest request, HttpServletResponse response)throws  Exception{
        String rootPath = request.getSession().getServletContext().getRealPath("/");
        String contextPath = request.getSession().getServletContext().getContextPath();
        BaseState state = (BaseState) new ActionEnter(request, rootPath, contextPath, "img").invoke(ActionMap.UPLOAD_FILE);
        String url = state.getInfo("url");
        if (url!=null&& !url.equals("")){
            productclassify.setSurfaceplot(url);
        }
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String commentdatemin = df.format(new Date());
          productclassify.setDatechanged(commentdatemin);
         productclassifyService.updateNotNull(productclassify);
         return   new ModelAndView("redirect:pclassify-list.html?pid="+productclassify.getPfid()+"&&casts="+productclassify.getCats());
    }
   *//* *//**//*新增信息*//**//*
    @RequestMapping("admin/pclassify-add.html")
    public ModelAndView pclassifyAdd(Integer cast){
        ModelAndView modelAndView=new ModelAndView();
        modelAndView.addObject("castDt", cast);
        return modelAndView;
    }*//*
    *//*新增信息*//*
    @RequestMapping("admin/pclassify-add.html")
    public ModelAndView pclassifyAdd(Integer pid,Integer cast){
        ModelAndView modelAndView=new ModelAndView();
        modelAndView.addObject("pid", pid);
        modelAndView.addObject("castDt", cast);
        return modelAndView;
    }

    *//*执行新增*//*
    @RequestMapping("admin/pclassify-save.html")
    public ModelAndView savePclassify(Productclassify productclassify, HttpServletRequest request, HttpServletResponse response) {
        String rootPath = request.getSession().getServletContext().getRealPath("/");
        String contextPath = request.getSession().getServletContext().getContextPath();
        BaseState state = (BaseState) new ActionEnter(request, rootPath, contextPath, "img").invoke(ActionMap.UPLOAD_FILE);
        String url = state.getInfo("url");
        if (url!=null&& !url.equals("")){
            productclassify.setSurfaceplot(url);
        }
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String commentdatemin = df.format(new Date());
        productclassify.setDatechanged(commentdatemin);
        productclassifyService.save(productclassify);
        return   new ModelAndView("redirect:pclassify-list.html?pid="+productclassify.getPfid()+"&&casts="+productclassify.getCats());
    }
    *//*执行删除*//*
    @RequestMapping("admin/delPclassifyById.html")
    @ResponseBody
    public boolean delPclassifyById(@RequestParam( value = "id")Integer id ){
        int i = productclassifyService.countPclassify(id);
        System.err.println(i);
        if (i>=1){
        return false;
        }else{
            productclassifyService.deletePclassifyById(id);
            return true;
        }
    }
    *//*跳转*//*
    @RequestMapping("admin/pclassifyt-list.html")
    public ModelAndView getPralssifty(Integer pid){
        Productclassify productclassify = productclassifyService.selectPclassifyById(pid);
        return   new ModelAndView("redirect:pclassify-list.html?pid="+productclassify.getPfid()+"&&casts="+productclassify.getCats());
    }*/
}
