EventController.java 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package cn.cslg.pas.controller;
  2. import cn.cslg.pas.common.core.base.Constants;
  3. import cn.cslg.pas.common.model.dto.EventAddNewDTO;
  4. import cn.cslg.pas.common.model.dto.EventQueryPageDTO;
  5. import cn.cslg.pas.common.utils.Response;
  6. import cn.cslg.pas.exception.XiaoShiException;
  7. import cn.cslg.pas.service.IEventService;
  8. import io.swagger.v3.oas.annotations.Operation;
  9. import io.swagger.v3.oas.annotations.tags.Tag;
  10. import lombok.RequiredArgsConstructor;
  11. import lombok.extern.slf4j.Slf4j;
  12. import org.springframework.web.bind.annotation.PostMapping;
  13. import org.springframework.web.bind.annotation.RequestBody;
  14. import org.springframework.web.bind.annotation.RequestMapping;
  15. import org.springframework.web.bind.annotation.RestController;
  16. /**
  17. * 事件的Controller层
  18. *
  19. * @Author chenyu
  20. * @Date 2023/4/2
  21. */
  22. @Tag(name = "事件的管理模块")
  23. @RequiredArgsConstructor
  24. @Slf4j
  25. @RequestMapping(Constants.API_VERSION_V2 + "/event")
  26. @RestController
  27. public class EventController {
  28. private final IEventService eventService;
  29. @Operation(summary = "新增事件")
  30. @PostMapping("/addNew")
  31. public String addNew(@RequestBody EventAddNewDTO eventAddNewDTO) {
  32. log.info("开始处理【新增事件】的请求,请求参数为:{}", eventAddNewDTO);
  33. try {
  34. eventService.addNew(eventAddNewDTO);
  35. } catch (XiaoShiException e) {
  36. return Response.error(e.getMessage());
  37. }
  38. return Response.success("新增事件完成");
  39. }
  40. @Operation(summary = "查询事件")
  41. @PostMapping("/query")
  42. public String query(@RequestBody EventQueryPageDTO eventQueryPageDTO) {
  43. log.info("开始处理【分页查询事件】的业务,参数为:{}", eventQueryPageDTO);
  44. return eventService.query(eventQueryPageDTO);
  45. }
  46. }