From a1e5f0f11784b3f5fcced89f6bd890eb25735dda Mon Sep 17 00:00:00 2001 From: bbbang105 <2018111366@dgu.ac.kr> Date: Sat, 2 Nov 2024 21:10:46 +0900 Subject: [PATCH 1/2] =?UTF-8?q?#103=20[refactor]=20:=20=EB=B6=88=ED=95=84?= =?UTF-8?q?=EC=9A=94=ED=95=9C=20=ED=98=95=EB=B3=80=ED=99=98=EC=9D=84=20?= =?UTF-8?q?=EC=A0=9C=EA=B1=B0=ED=95=9C=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../event/response/GetUserParticipatedEventsResponse.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/side/onetime/dto/event/response/GetUserParticipatedEventsResponse.java b/src/main/java/side/onetime/dto/event/response/GetUserParticipatedEventsResponse.java index 25a9acc..85e0a33 100644 --- a/src/main/java/side/onetime/dto/event/response/GetUserParticipatedEventsResponse.java +++ b/src/main/java/side/onetime/dto/event/response/GetUserParticipatedEventsResponse.java @@ -6,6 +6,7 @@ import side.onetime.domain.Event; import side.onetime.domain.EventParticipation; import side.onetime.domain.enums.Category; +import side.onetime.domain.enums.EventStatus; import java.util.List; import java.util.UUID; @@ -18,7 +19,7 @@ public record GetUserParticipatedEventsResponse( String title, String createdDate, int participantCount, - String eventStatus, + EventStatus eventStatus, List mostPossibleTimes ) { public static GetUserParticipatedEventsResponse of(Event event, EventParticipation eventParticipation, int participantCount, List mostPossibleTimes) { @@ -28,7 +29,7 @@ public static GetUserParticipatedEventsResponse of(Event event, EventParticipati event.getTitle(), String.valueOf(event.getCreatedDate()), participantCount, - String.valueOf(eventParticipation.getEventStatus()), + eventParticipation.getEventStatus(), mostPossibleTimes ); } From 2815d90f57f24ab5f5f91d23a8ec088c8d05683e Mon Sep 17 00:00:00 2001 From: bbbang105 <2018111366@dgu.ac.kr> Date: Sat, 2 Nov 2024 21:11:28 +0900 Subject: [PATCH 2/2] =?UTF-8?q?#103=20[feat]=20:=20=EB=A1=9C=EA=B7=B8?= =?UTF-8?q?=EC=9D=B8=20=EC=9C=A0=EC=A0=80=20=EB=8C=80=EC=83=81,=20?= =?UTF-8?q?=EC=9D=B4=EB=B2=A4=ED=8A=B8=20=EC=A1=B0=ED=9A=8C=20=EC=8B=9C=20?= =?UTF-8?q?=EC=9D=B4=EB=B2=A4=ED=8A=B8=20=EC=B0=B8=EC=97=AC=20=EC=83=81?= =?UTF-8?q?=ED=83=9C=EB=8F=84=20=EB=B0=98=ED=99=98=ED=95=98=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../side/onetime/controller/EventController.java | 5 ++++- .../onetime/dto/event/response/GetEventResponse.java | 9 ++++++--- src/main/java/side/onetime/service/EventService.java | 12 ++++++++++-- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/main/java/side/onetime/controller/EventController.java b/src/main/java/side/onetime/controller/EventController.java index 85ee4ff..b5f709a 100644 --- a/src/main/java/side/onetime/controller/EventController.java +++ b/src/main/java/side/onetime/controller/EventController.java @@ -37,9 +37,12 @@ public ResponseEntity> createEvent( // 이벤트 조회 API @GetMapping("/{event_id}") public ResponseEntity> getEvent( + @RequestHeader(value = "Authorization", required = false) String authorizationHeader, @PathVariable("event_id") String eventId) { - GetEventResponse getEventResponse = eventService.getEvent(eventId); + GetEventResponse getEventResponse = eventService.getEvent(eventId, authorizationHeader); + + return ApiResponse.onSuccess(SuccessStatus._GET_EVENT, getEventResponse); } diff --git a/src/main/java/side/onetime/dto/event/response/GetEventResponse.java b/src/main/java/side/onetime/dto/event/response/GetEventResponse.java index 81a32e1..dda27c0 100644 --- a/src/main/java/side/onetime/dto/event/response/GetEventResponse.java +++ b/src/main/java/side/onetime/dto/event/response/GetEventResponse.java @@ -5,6 +5,7 @@ import com.fasterxml.jackson.databind.annotation.JsonNaming; import side.onetime.domain.Event; import side.onetime.domain.enums.Category; +import side.onetime.domain.enums.EventStatus; import java.util.List; @@ -15,15 +16,17 @@ public record GetEventResponse( String startTime, String endTime, Category category, - List ranges + List ranges, + EventStatus eventStatus ) { - public static GetEventResponse of(Event event, List ranges) { + public static GetEventResponse of(Event event, List ranges, EventStatus eventStatus) { return new GetEventResponse( event.getTitle(), event.getStartTime(), event.getEndTime(), event.getCategory(), - ranges + ranges, + eventStatus ); } } \ No newline at end of file diff --git a/src/main/java/side/onetime/service/EventService.java b/src/main/java/side/onetime/service/EventService.java index c004c12..7606562 100644 --- a/src/main/java/side/onetime/service/EventService.java +++ b/src/main/java/side/onetime/service/EventService.java @@ -115,7 +115,7 @@ protected void createAndSaveDaySchedules(Event event, List ranges, Strin // 이벤트 조회 메서드 @Transactional(readOnly = true) - public GetEventResponse getEvent(String eventId) { + public GetEventResponse getEvent(String eventId, String authorizationHeader) { Event event = eventRepository.findByEventId(UUID.fromString(eventId)) .orElseThrow(() -> new CustomException(EventErrorStatus._NOT_FOUND_EVENT)); @@ -126,7 +126,15 @@ public GetEventResponse getEvent(String eventId) { ? DateUtil.getSortedDateRanges(schedules.stream().map(Schedule::getDate).toList(), "yyyy.MM.dd") : DateUtil.getSortedDayRanges(schedules.stream().map(Schedule::getDay).toList()); - return GetEventResponse.of(event, ranges); + EventStatus eventStatus = null; + if (authorizationHeader != null) { + User user = jwtUtil.getUserFromHeader(authorizationHeader); + EventParticipation eventParticipation = eventParticipationRepository.findByUserAndEvent(user, event) + .orElseThrow(() -> new CustomException(EventParticipationErrorStatus._NOT_FOUND_EVENT_PARTICIPATION)); + eventStatus = eventParticipation.getEventStatus(); + } + + return GetEventResponse.of(event, ranges, eventStatus); } // 참여자 조회 메서드