Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BE] api 명세에서 행사 url을 표현하는 용어와 전달 방식 수정 #98

Merged
merged 4 commits into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ public class ActionController {

private final ActionService actionService;

@GetMapping("/api/events/{token}/actions/reports")
public ResponseEntity<MemberBillReportsResponse> getMemberBillReports(@PathVariable("token") String token) {
@GetMapping("/api/events/{eventId}/actions/reports")
public ResponseEntity<MemberBillReportsResponse> getMemberBillReports(@PathVariable("eventId") String token) {
List<MemberBillReportAppResponse> memberBillReports = actionService.getMemberBillReports(token);

return ResponseEntity.ok()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Void> saveAllBillAction(
@PathVariable String token,
@PathVariable("eventId") String token,
@RequestBody @Valid BillActionsSaveRequest request
) {
billActionService.saveAllBillAction(token, request.toAppRequests());
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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
Expand All @@ -20,16 +19,14 @@ public class EventController {
private final EventService eventService;

@PostMapping("/api/events")
public ResponseEntity<Void> saveEvent(@RequestBody EventSaveRequest request) {
EventAppResponse eventAppResponse = eventService.saveEvent(request.toAppRequest());
public ResponseEntity<EventResponse> 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<EventDetailResponse> findEvent(@PathVariable("token") String token) {
@GetMapping("/api/events/{eventId}")
public ResponseEntity<EventDetailResponse> findEvent(@PathVariable("eventId") String token) {
EventDetailResponse eventDetailResponse = EventDetailResponse.of(eventService.findEvent(token));

return ResponseEntity.ok(eventDetailResponse);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@ public class MemberActionController {

private final MemberActionService memberActionService;

@PostMapping("/api/events/{token}/actions/members")
@PostMapping("/api/events/{eventId}/actions/members")
public ResponseEntity<Void> saveMemberAction(
@PathVariable("token") String token,
@PathVariable("eventId") String token,
@RequestBody MemberActionsSaveRequest request
) {
memberActionService.saveMemberAction(token, request.toAppRequest());

return ResponseEntity.ok().build();
}

@GetMapping("/api/events/{token}/members/current")
public ResponseEntity<CurrentMembersResponse> getCurrentMembers(@PathVariable("token") String token) {
@GetMapping("/api/events/{eventId}/members/current")
public ResponseEntity<CurrentMembersResponse> getCurrentMembers(@PathVariable("eventId") String token) {
List<CurrentMemberAppResponse> currentMembers = memberActionService.getCurrentMembers(token);

return ResponseEntity.ok()
Expand Down
Original file line number Diff line number Diff line change
@@ -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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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("토큰으로 행사를 조회한다.")
Expand Down
Loading