ApplicationController.java 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package cn.seecoder.paas.web.controller.api;
  2. import cn.seecoder.paas.service.ApplicationService;
  3. import cn.seecoder.paas.service.model.vo.ApplicationVO;
  4. import cn.seecoder.paas.util.ServiceException;
  5. import cn.seecoder.paas.web.model.Response;
  6. import org.springframework.beans.factory.annotation.Autowired;
  7. import org.springframework.web.bind.annotation.*;
  8. @RestController
  9. @RequestMapping("/api/application")
  10. public class ApplicationController {
  11. private final ApplicationService applicationService;
  12. @Autowired
  13. public ApplicationController(ApplicationService applicationService) {
  14. this.applicationService = applicationService;
  15. }
  16. @PostMapping("")
  17. public Response create(@RequestBody ApplicationVO vo) throws ServiceException {
  18. return Response.buildSuccess(applicationService.createOrUpdate(vo));
  19. }
  20. @PutMapping("")
  21. public Response update(@RequestBody ApplicationVO vo) throws ServiceException {
  22. return Response.buildSuccess(applicationService.createOrUpdate(vo));
  23. }
  24. @GetMapping("")
  25. public Response getAll() {
  26. return Response.buildSuccess(applicationService.getAll());
  27. }
  28. @GetMapping("/{id}")
  29. public Response get(@PathVariable("id") Integer id) throws ServiceException {
  30. return Response.buildSuccess(applicationService.getDetailById(id));
  31. }
  32. @DeleteMapping("/{id}")
  33. public Response delete(@PathVariable("id") Integer id) {
  34. applicationService.delete(id);
  35. return Response.buildSuccess(null);
  36. }
  37. }