diff --git a/server/src/main/java/server/haengdong/presentation/ActionController.java b/server/src/main/java/server/haengdong/presentation/ActionController.java index fbde65a24..657cb567e 100644 --- a/server/src/main/java/server/haengdong/presentation/ActionController.java +++ b/server/src/main/java/server/haengdong/presentation/ActionController.java @@ -16,8 +16,8 @@ public class ActionController { private final ActionService actionService; - @GetMapping("/api/events/{token}/actions/reports") - public ResponseEntity getMemberBillReports(@PathVariable("token") String token) { + @GetMapping("/api/events/{eventId}/actions/reports") + public ResponseEntity getMemberBillReports(@PathVariable("eventId") String token) { List memberBillReports = actionService.getMemberBillReports(token); return ResponseEntity.ok() diff --git a/server/src/main/java/server/haengdong/presentation/BillActionController.java b/server/src/main/java/server/haengdong/presentation/BillActionController.java index 139d6a470..fcdacb270 100644 --- a/server/src/main/java/server/haengdong/presentation/BillActionController.java +++ b/server/src/main/java/server/haengdong/presentation/BillActionController.java @@ -16,9 +16,9 @@ public class BillActionController { private final BillActionService billActionService; - @PostMapping("/api/events/{token}/actions/bills") + @PostMapping("/api/events/{eventId}/actions/bills") public ResponseEntity saveAllBillAction( - @PathVariable String token, + @PathVariable("eventId") String token, @RequestBody @Valid BillActionsSaveRequest request ) { billActionService.saveAllBillAction(token, request.toAppRequests()); diff --git a/server/src/main/java/server/haengdong/presentation/EventController.java b/server/src/main/java/server/haengdong/presentation/EventController.java index 538ca9c1e..263bc35aa 100644 --- a/server/src/main/java/server/haengdong/presentation/EventController.java +++ b/server/src/main/java/server/haengdong/presentation/EventController.java @@ -1,6 +1,5 @@ package server.haengdong.presentation; -import java.net.URI; import lombok.RequiredArgsConstructor; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; @@ -9,9 +8,9 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RestController; import server.haengdong.application.EventService; -import server.haengdong.application.response.EventAppResponse; import server.haengdong.presentation.request.EventSaveRequest; import server.haengdong.presentation.response.EventDetailResponse; +import server.haengdong.presentation.response.EventResponse; @RequiredArgsConstructor @RestController @@ -20,16 +19,14 @@ public class EventController { private final EventService eventService; @PostMapping("/api/events") - public ResponseEntity saveEvent(@RequestBody EventSaveRequest request) { - EventAppResponse eventAppResponse = eventService.saveEvent(request.toAppRequest()); + public ResponseEntity saveEvent(@RequestBody EventSaveRequest request) { + EventResponse eventResponse = EventResponse.of(eventService.saveEvent(request.toAppRequest())); - return ResponseEntity.ok() - .location(URI.create("events/" + eventAppResponse.token())) - .build(); + return ResponseEntity.ok(eventResponse); } - @GetMapping("/api/events/{token}") - public ResponseEntity findEvent(@PathVariable("token") String token) { + @GetMapping("/api/events/{eventId}") + public ResponseEntity findEvent(@PathVariable("eventId") String token) { EventDetailResponse eventDetailResponse = EventDetailResponse.of(eventService.findEvent(token)); return ResponseEntity.ok(eventDetailResponse); diff --git a/server/src/main/java/server/haengdong/presentation/MemberActionController.java b/server/src/main/java/server/haengdong/presentation/MemberActionController.java index cd45e3237..c12370d86 100644 --- a/server/src/main/java/server/haengdong/presentation/MemberActionController.java +++ b/server/src/main/java/server/haengdong/presentation/MemberActionController.java @@ -19,9 +19,9 @@ public class MemberActionController { private final MemberActionService memberActionService; - @PostMapping("/api/events/{token}/actions/members") + @PostMapping("/api/events/{eventId}/actions/members") public ResponseEntity saveMemberAction( - @PathVariable("token") String token, + @PathVariable("eventId") String token, @RequestBody MemberActionsSaveRequest request ) { memberActionService.saveMemberAction(token, request.toAppRequest()); @@ -29,8 +29,8 @@ public ResponseEntity saveMemberAction( return ResponseEntity.ok().build(); } - @GetMapping("/api/events/{token}/members/current") - public ResponseEntity getCurrentMembers(@PathVariable("token") String token) { + @GetMapping("/api/events/{eventId}/members/current") + public ResponseEntity getCurrentMembers(@PathVariable("eventId") String token) { List currentMembers = memberActionService.getCurrentMembers(token); return ResponseEntity.ok() diff --git a/server/src/main/java/server/haengdong/presentation/response/EventResponse.java b/server/src/main/java/server/haengdong/presentation/response/EventResponse.java new file mode 100644 index 000000000..506f5e814 --- /dev/null +++ b/server/src/main/java/server/haengdong/presentation/response/EventResponse.java @@ -0,0 +1,10 @@ +package server.haengdong.presentation.response; + +import server.haengdong.application.response.EventAppResponse; + +public record EventResponse(String eventId) { + + public static EventResponse of(EventAppResponse eventAppResponse) { + return new EventResponse(eventAppResponse.token()); + } +} diff --git a/server/src/test/java/server/haengdong/presentation/EventControllerTest.java b/server/src/test/java/server/haengdong/presentation/EventControllerTest.java index c50431696..55a48630f 100644 --- a/server/src/test/java/server/haengdong/presentation/EventControllerTest.java +++ b/server/src/test/java/server/haengdong/presentation/EventControllerTest.java @@ -16,7 +16,6 @@ import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.http.MediaType; import org.springframework.test.web.servlet.MockMvc; -import org.springframework.test.web.servlet.result.MockMvcResultMatchers; import server.haengdong.application.EventService; import server.haengdong.application.request.EventAppRequest; import server.haengdong.application.response.EventAppResponse; @@ -49,7 +48,7 @@ void saveEvent() throws Exception { .content(requestBody)) .andDo(print()) .andExpect(status().isOk()) - .andExpect(MockMvcResultMatchers.redirectedUrl("events/" + token)); + .andExpect(jsonPath("$.eventId").value("TOKEN")); } @DisplayName("토큰으로 행사를 조회한다.")