From 2f35cd6a946c749c4600472d81f041e210be8f0a Mon Sep 17 00:00:00 2001 From: kseysh Date: Mon, 11 Nov 2024 00:40:07 +0900 Subject: [PATCH] =?UTF-8?q?[modify]=20api=20=EB=AA=85=EC=84=B8=EC=84=9C?= =?UTF-8?q?=EC=99=80=20=EB=A7=9E=EB=8F=84=EB=A1=9D=20Response=20=EC=88=98?= =?UTF-8?q?=EC=A0=95=20(#429)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/application/calendar/CalendarService.java | 5 +++-- .../application/calendar/CalendarServiceImpl.java | 14 ++++++-------- .../presentation/calendar/AllCalendarResponse.java | 7 ------- .../presentation/calendar/CalendarController.java | 3 ++- 4 files changed, 11 insertions(+), 18 deletions(-) delete mode 100644 src/main/java/org/sopt/app/presentation/calendar/AllCalendarResponse.java diff --git a/src/main/java/org/sopt/app/application/calendar/CalendarService.java b/src/main/java/org/sopt/app/application/calendar/CalendarService.java index 2214a940..a5072d06 100644 --- a/src/main/java/org/sopt/app/application/calendar/CalendarService.java +++ b/src/main/java/org/sopt/app/application/calendar/CalendarService.java @@ -1,7 +1,8 @@ package org.sopt.app.application.calendar; -import org.sopt.app.presentation.calendar.AllCalendarResponse; +import java.util.List; +import org.sopt.app.presentation.calendar.CalendarResponse; public interface CalendarService { - AllCalendarResponse getAllCurrentGenerationCalendar(); + List getAllCurrentGenerationCalendar(); } diff --git a/src/main/java/org/sopt/app/application/calendar/CalendarServiceImpl.java b/src/main/java/org/sopt/app/application/calendar/CalendarServiceImpl.java index 4abbc6b9..e10c1467 100644 --- a/src/main/java/org/sopt/app/application/calendar/CalendarServiceImpl.java +++ b/src/main/java/org/sopt/app/application/calendar/CalendarServiceImpl.java @@ -1,12 +1,12 @@ package org.sopt.app.application.calendar; +import java.util.List; import java.util.Optional; import lombok.RequiredArgsConstructor; import org.sopt.app.domain.cache.CachedAllCalendarResponse; import org.sopt.app.domain.cache.Calendars; import org.sopt.app.interfaces.postgres.CalendarRepository; import org.sopt.app.interfaces.postgres.redis.CachedCalendarRepository; -import org.sopt.app.presentation.calendar.AllCalendarResponse; import org.sopt.app.presentation.calendar.CalendarResponse; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; @@ -24,16 +24,14 @@ public class CalendarServiceImpl implements CalendarService { @Override @Transactional - public AllCalendarResponse getAllCurrentGenerationCalendar() { + public List getAllCurrentGenerationCalendar() { Optional cachedCalendar = cachedCalendarRepository.findById(currentGeneration); - return new AllCalendarResponse( - cachedCalendar.orElseGet(this::cacheAllCalendarResponse) - .getCalendars().calendars().stream() - .map(CalendarResponse::of) - .toList() - ); + return cachedCalendar.orElseGet(this::cacheAllCalendarResponse) + .getCalendars().calendars().stream() + .map(CalendarResponse::of) + .toList(); } private CachedAllCalendarResponse cacheAllCalendarResponse() { diff --git a/src/main/java/org/sopt/app/presentation/calendar/AllCalendarResponse.java b/src/main/java/org/sopt/app/presentation/calendar/AllCalendarResponse.java deleted file mode 100644 index 29acd8ff..00000000 --- a/src/main/java/org/sopt/app/presentation/calendar/AllCalendarResponse.java +++ /dev/null @@ -1,7 +0,0 @@ -package org.sopt.app.presentation.calendar; - -import java.util.List; - -public record AllCalendarResponse( - List calendars -) { } diff --git a/src/main/java/org/sopt/app/presentation/calendar/CalendarController.java b/src/main/java/org/sopt/app/presentation/calendar/CalendarController.java index 44c9a721..70ea29f7 100644 --- a/src/main/java/org/sopt/app/presentation/calendar/CalendarController.java +++ b/src/main/java/org/sopt/app/presentation/calendar/CalendarController.java @@ -4,6 +4,7 @@ import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponses; +import java.util.List; import lombok.RequiredArgsConstructor; import org.sopt.app.application.calendar.CalendarService; import org.springframework.http.ResponseEntity; @@ -22,7 +23,7 @@ public class CalendarController { @ApiResponse(responseCode = "500", description = "server error", content = @Content) }) @GetMapping("/all") - public ResponseEntity getAllCalendar() { + public ResponseEntity> getAllCalendar() { return ResponseEntity.ok( calendarService.getAllCurrentGenerationCalendar() );