金币系统后端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
1.6 KiB

  1. package com.example.demo.controller;
  2. import com.example.demo.domain.work.One;
  3. import com.example.demo.domain.work.Three;
  4. import com.example.demo.domain.work.Two;
  5. import com.example.demo.sevice.OneService;
  6. import lombok.RequiredArgsConstructor;
  7. import lombok.extern.slf4j.Slf4j;
  8. import org.springframework.web.bind.annotation.*;
  9. import java.util.List;
  10. @RestController
  11. @RequestMapping("/One")
  12. @RequiredArgsConstructor
  13. @Slf4j
  14. @CrossOrigin
  15. public class OneController {
  16. private final OneService oneService;
  17. // 定义一个DTO类来封装请求参数
  18. public static class RequestParams {
  19. private String token;
  20. private List<String> areas;
  21. // Getter和Setter方法
  22. public String getToken() {
  23. return token;
  24. }
  25. public void setToken(String token) {
  26. this.token = token;
  27. }
  28. public List<String> getAreas() {
  29. return areas;
  30. }
  31. public void setAreas(List<String> areas) {
  32. this.areas = areas;
  33. }
  34. }
  35. @PostMapping("/getOne")
  36. public One getOne(@RequestBody RequestParams requestParams) throws Exception {
  37. return oneService.getOne(requestParams.getToken(), requestParams.getAreas());
  38. }
  39. @PostMapping("/getTwo")
  40. public Two getTwo(@RequestBody RequestParams requestParams) throws Exception {
  41. return oneService.getTwo(requestParams.getToken(), requestParams.getAreas());
  42. }
  43. @PostMapping("/getThree")
  44. public Three getThree(@RequestBody RequestParams requestParams) throws Exception {
  45. return oneService.getThree(requestParams.getToken(), requestParams.getAreas());
  46. }
  47. }