Ejemplo n.º 1
0
  @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";
  }
Ejemplo n.º 2
0
 // 商品下架
 @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";
 }
Ejemplo n.º 3
0
 @RequestMapping(value = "/provider/products/{id}", method = RequestMethod.PUT, params = "edit")
 public String editProcess(
     @PathVariable("id") Long id,
     @Valid @ModelAttribute("product") Product product,
     BindingResult request,
     Model uiModel) {
   Product oldProduct = productService.findOne(id);
   if (oldProduct == null) {
     throw new ProductNotFoundException();
   }
   product = productService.updateProduct(product, oldProduct);
   uiModel.addAttribute("product", product);
   return USERPRODUCTSEDITOK;
 }
Ejemplo n.º 4
0
 @RequestMapping(value = "/provider/products/{id}", method = RequestMethod.GET, params = "edit")
 public String edit(Model uiModel, @PathVariable("id") Long id) {
   Provider user = (Provider) userContext.getCurrentUser();
   Product product = productService.findOneByUser(user, id);
   uiModel.addAttribute("product", product);
   return USERPRODUCTSEDIT;
 }
Ejemplo n.º 5
0
 @RequestMapping(value = "/provider/count", method = RequestMethod.GET)
 public String findCount(
     Model uiModel,
     @SecurityUser SiteUser user,
     @RequestParam(value = "page", defaultValue = "1") int page,
     @RequestParam(value = "size", defaultValue = "15") int size) {
   Page<Product> products =
       productService.findByUsers(
           new Provider(user.getId()),
           new PageRequest(page - 1, size, Direction.DESC, "createdTime"));
   uiModel.addAttribute("products", products);
   return "user/provider/count";
 }