StoreController.java 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. package com.seecoder.BlueWhale.controller;
  2. import java.util.List;
  3. import org.springframework.beans.factory.annotation.Autowired;
  4. import org.springframework.web.bind.annotation.GetMapping;
  5. import org.springframework.web.bind.annotation.PathVariable;
  6. import org.springframework.web.bind.annotation.PostMapping;
  7. import org.springframework.web.bind.annotation.RequestBody;
  8. import org.springframework.web.bind.annotation.RequestMapping;
  9. import org.springframework.web.bind.annotation.RestController;
  10. import com.seecoder.BlueWhale.service.StoreService;
  11. import com.seecoder.BlueWhale.vo.ResultVO;
  12. import com.seecoder.BlueWhale.vo.StoreVO;
  13. @RestController
  14. @RequestMapping("/api/stores")
  15. public class StoreController {
  16. @Autowired
  17. StoreService storeService;
  18. @PostMapping()
  19. public ResultVO<Boolean> create(@RequestBody StoreVO storeVO){
  20. return ResultVO.buildSuccess(storeService.create(storeVO));
  21. }
  22. @GetMapping("/{id}")
  23. public ResultVO<StoreVO> getStore(@PathVariable(value = "id") Integer id){
  24. return ResultVO.buildSuccess(storeService.getStore(id));
  25. }
  26. @GetMapping
  27. public ResultVO<List<StoreVO>> getAllStores(){
  28. return ResultVO.buildSuccess(storeService.getAllStores());
  29. }
  30. }