@RequestMapping(value = "/provider/products/{status}", method = RequestMethod.GET) public String productLists( Model uiModel, @RequestParam(value = "page", defaultValue = "1") int page, @RequestParam(value = "size", defaultValue = "15") int size, @SecurityUser SiteUser user, @PathVariable("status") String status) { System.out.println("user" + user.getId()); Page<Product> products = null; if (status.equals(OriginalEnum.ALL.toString().toUpperCase())) { System.out.println("1"); products = productService.findByUsers( new Provider(user.getId()), new PageRequest(page - 1, size, Direction.DESC, "createdTime")); } else { System.out.println("2"); products = productService.findByUsers( new Provider(user.getId()), new PageRequest(page - 1, size, Direction.DESC, "createdTime"), OriginalEnum.fromString(status)); } uiModel.addAttribute("lists", products); uiModel.addAttribute("status", OriginalEnum.fromString(status)); return "user/provider/maintain"; }
// 商品下架 @RequestMapping(value = "/provider/products/{id}/{status}", method = RequestMethod.PUT) public String offProduct( @PathVariable("id") Long id, @PathVariable("status") String status, @SecurityUser SiteUser user, Model uiModel) { Product product = productService.findOneByUser(new Provider(user.getId()), id); if (product == null) throw new ProductNotFoundException(); product.setOriginal(OriginalEnum.valueOf(status)); product = productService.saveOne(product); uiModel.addAttribute("product", product); return "user/provider/maintaintd"; }