Skip to content

Commit

Permalink
[modify] api 명세서와 맞도록 Response 수정 (#429)
Browse files Browse the repository at this point in the history
  • Loading branch information
kseysh committed Nov 10, 2024
1 parent c7d28fa commit 2f35cd6
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -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<CalendarResponse> getAllCurrentGenerationCalendar();
}
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -24,16 +24,14 @@ public class CalendarServiceImpl implements CalendarService {

@Override
@Transactional
public AllCalendarResponse getAllCurrentGenerationCalendar() {
public List<CalendarResponse> getAllCurrentGenerationCalendar() {

Optional<CachedAllCalendarResponse> 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() {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -22,7 +23,7 @@ public class CalendarController {
@ApiResponse(responseCode = "500", description = "server error", content = @Content)
})
@GetMapping("/all")
public ResponseEntity<AllCalendarResponse> getAllCalendar() {
public ResponseEntity<List<CalendarResponse>> getAllCalendar() {
return ResponseEntity.ok(
calendarService.getAllCurrentGenerationCalendar()
);
Expand Down

0 comments on commit 2f35cd6

Please sign in to comment.