From 3143c615449e85b16762dc54ce4c0cdfcb1937f6 Mon Sep 17 00:00:00 2001 From: 3juhwan <13selfesteem91@naver.com> Date: Wed, 24 Jul 2024 18:54:18 +0900 Subject: [PATCH 1/4] =?UTF-8?q?feat:=20=ED=96=89=EC=82=AC=20url=20?= =?UTF-8?q?=EB=AA=85=EC=84=B8=EB=A5=BC=20token=EC=97=90=EC=84=9C=20eventId?= =?UTF-8?q?=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/haengdong/presentation/ActionController.java | 4 ++-- .../haengdong/presentation/BillActionController.java | 4 ++-- .../server/haengdong/presentation/EventController.java | 4 ++-- .../haengdong/presentation/MemberActionController.java | 8 ++++---- 4 files changed, 10 insertions(+), 10 deletions(-) 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..777c8a20c 100644 --- a/server/src/main/java/server/haengdong/presentation/EventController.java +++ b/server/src/main/java/server/haengdong/presentation/EventController.java @@ -28,8 +28,8 @@ public ResponseEntity saveEvent(@RequestBody EventSaveRequest request) { .build(); } - @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() From bb8bcf14cc31e1bf6d7fbcb6264076d6204cd0c8 Mon Sep 17 00:00:00 2001 From: 3juhwan <13selfesteem91@naver.com> Date: Wed, 24 Jul 2024 18:55:00 +0900 Subject: [PATCH 2/4] =?UTF-8?q?feat:=20=ED=96=89=EC=82=AC=20url=EC=9D=84?= =?UTF-8?q?=20=ED=97=A4=EB=8D=94=EA=B0=80=20=EC=95=84=EB=8B=8C=20=EB=B0=94?= =?UTF-8?q?=EB=94=94=EB=A1=9C=20=EC=A0=84=EB=8B=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../haengdong/presentation/EventController.java | 11 ++++------- .../presentation/response/EventResponse.java | 10 ++++++++++ 2 files changed, 14 insertions(+), 7 deletions(-) create mode 100644 server/src/main/java/server/haengdong/presentation/response/EventResponse.java diff --git a/server/src/main/java/server/haengdong/presentation/EventController.java b/server/src/main/java/server/haengdong/presentation/EventController.java index 777c8a20c..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,12 +19,10 @@ 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/{eventId}") 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..5ddd418dc --- /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 url) { + + public static EventResponse of(EventAppResponse eventAppResponse) { + return new EventResponse(eventAppResponse.token()); + } +} From 809c19a645e03ab39f9e444059035c32003e76ec Mon Sep 17 00:00:00 2001 From: 3juhwan <13selfesteem91@naver.com> Date: Wed, 24 Jul 2024 19:19:55 +0900 Subject: [PATCH 3/4] =?UTF-8?q?test:=20=ED=96=89=EC=82=AC=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1=20=EC=BB=A8=ED=8A=B8=EB=A1=A4=EB=9F=AC=20=ED=85=8C?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/haengdong/presentation/EventControllerTest.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/server/src/test/java/server/haengdong/presentation/EventControllerTest.java b/server/src/test/java/server/haengdong/presentation/EventControllerTest.java index c50431696..1c9a02e42 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("$.url").value("TOKEN")); } @DisplayName("토큰으로 행사를 조회한다.") From 9efb22217c9c3672ffdf90ed1b1d0b7527640ef9 Mon Sep 17 00:00:00 2001 From: 3juhwan <13selfesteem91@naver.com> Date: Wed, 24 Jul 2024 19:23:38 +0900 Subject: [PATCH 4/4] =?UTF-8?q?feat:=20=ED=96=89=EC=82=AC=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1=20=EC=9D=91=EB=8B=B5=20dto=EC=97=90=20=ED=95=84?= =?UTF-8?q?=EB=93=9C=EB=AA=85=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/haengdong/presentation/response/EventResponse.java | 2 +- .../java/server/haengdong/presentation/EventControllerTest.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/server/src/main/java/server/haengdong/presentation/response/EventResponse.java b/server/src/main/java/server/haengdong/presentation/response/EventResponse.java index 5ddd418dc..506f5e814 100644 --- a/server/src/main/java/server/haengdong/presentation/response/EventResponse.java +++ b/server/src/main/java/server/haengdong/presentation/response/EventResponse.java @@ -2,7 +2,7 @@ import server.haengdong.application.response.EventAppResponse; -public record EventResponse(String url) { +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 1c9a02e42..55a48630f 100644 --- a/server/src/test/java/server/haengdong/presentation/EventControllerTest.java +++ b/server/src/test/java/server/haengdong/presentation/EventControllerTest.java @@ -48,7 +48,7 @@ void saveEvent() throws Exception { .content(requestBody)) .andDo(print()) .andExpect(status().isOk()) - .andExpect(jsonPath("$.url").value("TOKEN")); + .andExpect(jsonPath("$.eventId").value("TOKEN")); } @DisplayName("토큰으로 행사를 조회한다.")