1
0

ProductController.java 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. package com.seecoder.BlueWhale.Controller;
  2. import com.seecoder.BlueWhale.Service.ProductService;
  3. import com.seecoder.BlueWhale.VO.ProductVO;
  4. import com.seecoder.BlueWhale.VO.ResultVO;
  5. import java.util.List;
  6. import org.springframework.beans.factory.annotation.Autowired;
  7. import org.springframework.web.bind.annotation.GetMapping;
  8. import org.springframework.web.bind.annotation.PathVariable;
  9. import org.springframework.web.bind.annotation.PostMapping;
  10. import org.springframework.web.bind.annotation.RequestBody;
  11. import org.springframework.web.bind.annotation.RequestMapping;
  12. import org.springframework.web.bind.annotation.RequestParam;
  13. import org.springframework.web.bind.annotation.RestController;
  14. @RestController
  15. @RequestMapping("/api/product")
  16. public class ProductController {
  17. @Autowired
  18. ProductService productService;
  19. @PostMapping("/create")
  20. public ResultVO<Boolean> create(@RequestBody ProductVO productVO){
  21. return ResultVO.buildSuccess(productService.create(productVO));
  22. }
  23. @PostMapping("/stock")
  24. public ResultVO<Boolean> addStock(@RequestParam("id") Integer id,@RequestParam("number") Integer number){
  25. return ResultVO.buildSuccess(productService.addStock(id,number));
  26. }
  27. @GetMapping("/all")
  28. public ResultVO<List<ProductVO>> getAllProducts(@RequestParam("storeId") Integer storeId){
  29. return ResultVO.buildSuccess(productService.getAllProducts(storeId));
  30. }
  31. }