Skip to content

Commit

Permalink
feat: 행사 url을 헤더가 아닌 바디로 전달
Browse files Browse the repository at this point in the history
  • Loading branch information
3Juhwan committed Jul 24, 2024
1 parent 3143c61 commit bb8bcf1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
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,12 +19,10 @@ 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/{eventId}")
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 url) {

public static EventResponse of(EventAppResponse eventAppResponse) {
return new EventResponse(eventAppResponse.token());
}
}

0 comments on commit bb8bcf1

Please sign in to comment.