From d7c3889280929d7c4ace1247c350185e9423f624 Mon Sep 17 00:00:00 2001 From: chyun Date: Sat, 18 Jan 2025 22:53:59 +0900 Subject: [PATCH] =?UTF-8?q?refactor=20[#105]=20=EB=82=A0=EC=A7=9C=20?= =?UTF-8?q?=EB=A7=A4=ED=95=91=20=EB=B0=A9=EB=B2=95=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/response/SearchArtistSingleResponse.java | 5 +++-- .../dto/request/CreateFestivalDateRequest.java | 3 +++ .../dto/request/CreateFestivalRequest.java | 5 +++++ .../dto/request/CreateFestivalTimeRequest.java | 3 +++ .../dto/response/ConcertDetailInfoResponse.java | 13 +++++++------ .../dto/response/FestivalDetailInfoResponse.java | 13 +++++++------ .../api/user/dto/response/UserFavoriteResponse.java | 4 +++- .../api/user/dto/response/UserInfoResponse.java | 6 +++++- .../org/sopt/confeti/global/util/DateConvertor.java | 12 ++++++++++++ 9 files changed, 48 insertions(+), 16 deletions(-) diff --git a/src/main/java/org/sopt/confeti/api/artist/dto/response/SearchArtistSingleResponse.java b/src/main/java/org/sopt/confeti/api/artist/dto/response/SearchArtistSingleResponse.java index 9ab6e7f..b53d258 100644 --- a/src/main/java/org/sopt/confeti/api/artist/dto/response/SearchArtistSingleResponse.java +++ b/src/main/java/org/sopt/confeti/api/artist/dto/response/SearchArtistSingleResponse.java @@ -2,12 +2,13 @@ import java.time.LocalDate; import org.sopt.confeti.api.artist.facade.dto.response.SearchArtistDTO; +import org.sopt.confeti.global.util.DateConvertor; public record SearchArtistSingleResponse( String artistId, String name, String profileUrl, - LocalDate latestReleaseAt, + String latestReleaseAt, boolean isFavorite, boolean isMultipleArtists ) { @@ -16,7 +17,7 @@ public static SearchArtistSingleResponse from(final SearchArtistDTO searchArtist searchArtistDTO.artistId(), searchArtistDTO.name(), searchArtistDTO.profileUrl(), - searchArtistDTO.latestReleaseAt(), + DateConvertor.convert(searchArtistDTO.latestReleaseAt()), searchArtistDTO.isFavorite(), searchArtistDTO.isMultipleArtists() ); diff --git a/src/main/java/org/sopt/confeti/api/performance/dto/request/CreateFestivalDateRequest.java b/src/main/java/org/sopt/confeti/api/performance/dto/request/CreateFestivalDateRequest.java index a9b77d8..141b7ac 100644 --- a/src/main/java/org/sopt/confeti/api/performance/dto/request/CreateFestivalDateRequest.java +++ b/src/main/java/org/sopt/confeti/api/performance/dto/request/CreateFestivalDateRequest.java @@ -3,9 +3,12 @@ import java.time.LocalDate; import java.time.LocalTime; import java.util.List; +import org.springframework.format.annotation.DateTimeFormat; public record CreateFestivalDateRequest( + @DateTimeFormat(pattern = "yyyy.MM.dd") LocalDate festivalAt, + @DateTimeFormat(pattern = "HH:mm:ss") LocalTime ticketOpenAt, List festivalStages ) { diff --git a/src/main/java/org/sopt/confeti/api/performance/dto/request/CreateFestivalRequest.java b/src/main/java/org/sopt/confeti/api/performance/dto/request/CreateFestivalRequest.java index e60c364..13968e2 100644 --- a/src/main/java/org/sopt/confeti/api/performance/dto/request/CreateFestivalRequest.java +++ b/src/main/java/org/sopt/confeti/api/performance/dto/request/CreateFestivalRequest.java @@ -3,11 +3,15 @@ import java.time.LocalDate; import java.time.LocalDateTime; import java.util.List; +import org.sopt.confeti.global.util.DateConvertor; +import org.springframework.format.annotation.DateTimeFormat; public record CreateFestivalRequest( String festivalTitle, String festivalSubtitle, + @DateTimeFormat(pattern = "yyyy.MM.dd") LocalDate festivalStartAt, + @DateTimeFormat(pattern = "yyyy.MM.dd") LocalDate festivalEndAt, String festivalArea, String festivalPosterPath, @@ -15,6 +19,7 @@ public record CreateFestivalRequest( String festivalInfoImgPath, String festivalReservationBgPath, String festivalLogoPath, + @DateTimeFormat(pattern = "yyyy.MM.dd") LocalDate reserveAt, String reservationUrl, String reservationOffice, diff --git a/src/main/java/org/sopt/confeti/api/performance/dto/request/CreateFestivalTimeRequest.java b/src/main/java/org/sopt/confeti/api/performance/dto/request/CreateFestivalTimeRequest.java index 59f5fbc..76340ad 100644 --- a/src/main/java/org/sopt/confeti/api/performance/dto/request/CreateFestivalTimeRequest.java +++ b/src/main/java/org/sopt/confeti/api/performance/dto/request/CreateFestivalTimeRequest.java @@ -3,9 +3,12 @@ import java.time.LocalDate; import java.time.LocalTime; import java.util.List; +import org.springframework.format.annotation.DateTimeFormat; public record CreateFestivalTimeRequest( + @DateTimeFormat(pattern = "HH:mm:ss") LocalTime startAt, + @DateTimeFormat(pattern = "HH:mm:ss") LocalTime endAt, List festivalArtists ) { diff --git a/src/main/java/org/sopt/confeti/api/performance/dto/response/ConcertDetailInfoResponse.java b/src/main/java/org/sopt/confeti/api/performance/dto/response/ConcertDetailInfoResponse.java index e6da7a9..4743bb3 100644 --- a/src/main/java/org/sopt/confeti/api/performance/dto/response/ConcertDetailInfoResponse.java +++ b/src/main/java/org/sopt/confeti/api/performance/dto/response/ConcertDetailInfoResponse.java @@ -3,6 +3,7 @@ import java.time.LocalDate; import java.time.LocalDateTime; import org.sopt.confeti.api.performance.facade.dto.response.ConcertDetailDTO; +import org.sopt.confeti.global.util.DateConvertor; import org.sopt.confeti.global.util.S3FileHandler; public record ConcertDetailInfoResponse( @@ -11,10 +12,10 @@ public record ConcertDetailInfoResponse( String posterBgUrl, String title, String subtitle, - LocalDate startAt, - LocalDate endAt, + String startAt, + String endAt, String area, - LocalDateTime reserveAt, + String reserveAt, String reservationUrl, String time, String ageRating, @@ -29,10 +30,10 @@ public static ConcertDetailInfoResponse of(final ConcertDetailDTO concertDetailD s3FileHandler.getFileUrl(concertDetailDTO.posterBgPath()), concertDetailDTO.title(), concertDetailDTO.subtitle(), - concertDetailDTO.startAt(), - concertDetailDTO.endAt(), + DateConvertor.convert(concertDetailDTO.startAt()), + DateConvertor.convert(concertDetailDTO.endAt()), concertDetailDTO.area(), - concertDetailDTO.reserveAt(), + DateConvertor.convert(concertDetailDTO.reserveAt()), concertDetailDTO.reservationUrl(), concertDetailDTO.time(), concertDetailDTO.ageRating(), diff --git a/src/main/java/org/sopt/confeti/api/performance/dto/response/FestivalDetailInfoResponse.java b/src/main/java/org/sopt/confeti/api/performance/dto/response/FestivalDetailInfoResponse.java index 28b220a..8331584 100644 --- a/src/main/java/org/sopt/confeti/api/performance/dto/response/FestivalDetailInfoResponse.java +++ b/src/main/java/org/sopt/confeti/api/performance/dto/response/FestivalDetailInfoResponse.java @@ -3,6 +3,7 @@ import java.time.LocalDate; import java.time.LocalDateTime; import org.sopt.confeti.api.performance.facade.dto.response.FestivalDetailDTO; +import org.sopt.confeti.global.util.DateConvertor; public record FestivalDetailInfoResponse( long festivalId, @@ -10,10 +11,10 @@ public record FestivalDetailInfoResponse( String posterBgUrl, String title, String subtitle, - LocalDate startAt, - LocalDate endAt, + String startAt, + String endAt, String area, - LocalDate reserveAt, + String reserveAt, String reservationUrl, String time, String ageRating, @@ -29,10 +30,10 @@ public static FestivalDetailInfoResponse from(final FestivalDetailDTO festival) festival.festivalPosterBgUrl(), festival.festivalTitle(), festival.festivalSubtitle(), - festival.festivalStartAt(), - festival.festivalEndAt(), + DateConvertor.convert(festival.festivalStartAt()), + DateConvertor.convert(festival.festivalEndAt()), festival.festivalArea(), - festival.reserveAt(), + DateConvertor.convert(festival.reserveAt()), festival.reservationUrl(), festival.time(), festival.ageRating(), diff --git a/src/main/java/org/sopt/confeti/api/user/dto/response/UserFavoriteResponse.java b/src/main/java/org/sopt/confeti/api/user/dto/response/UserFavoriteResponse.java index ad4cc54..1cafe8a 100644 --- a/src/main/java/org/sopt/confeti/api/user/dto/response/UserFavoriteResponse.java +++ b/src/main/java/org/sopt/confeti/api/user/dto/response/UserFavoriteResponse.java @@ -4,7 +4,9 @@ import java.util.List; -public record UserFavoriteResponse(List artists) { +public record UserFavoriteResponse( + List artists +) { public static UserFavoriteResponse from(final List artistListDTO) { return new UserFavoriteResponse( artistListDTO.stream() diff --git a/src/main/java/org/sopt/confeti/api/user/dto/response/UserInfoResponse.java b/src/main/java/org/sopt/confeti/api/user/dto/response/UserInfoResponse.java index 4ae8b5d..7c87db1 100644 --- a/src/main/java/org/sopt/confeti/api/user/dto/response/UserInfoResponse.java +++ b/src/main/java/org/sopt/confeti/api/user/dto/response/UserInfoResponse.java @@ -2,7 +2,11 @@ import org.sopt.confeti.api.user.facade.dto.response.UserInfoDTO; -public record UserInfoResponse (Long userId, String profileUrl, String username){ +public record UserInfoResponse ( + Long userId, + String profileUrl, + String username +) { public static UserInfoResponse from (UserInfoDTO userInfoDTO) { return new UserInfoResponse(userInfoDTO.userId(), userInfoDTO.profileUrl(), userInfoDTO.username()); } diff --git a/src/main/java/org/sopt/confeti/global/util/DateConvertor.java b/src/main/java/org/sopt/confeti/global/util/DateConvertor.java index b02ef70..b8a3297 100644 --- a/src/main/java/org/sopt/confeti/global/util/DateConvertor.java +++ b/src/main/java/org/sopt/confeti/global/util/DateConvertor.java @@ -13,14 +13,26 @@ public class DateConvertor { private static final DateTimeFormatter localDateTimeFormat = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss"); public static String convert(final LocalDate localDate) { + if (localDate == null) { + return null; + } + return localDate.format(localDateFormat); } public static String convert(final LocalTime localTime) { + if (localTime == null) { + return null; + } + return localTime.format(localTimeFormat); } public static String convert(final LocalDateTime localDateTime) { + if (localDateTime == null) { + return null; + } + return localDateTime.format(localDateTimeFormat); }