Skip to content

Commit

Permalink
refactor [#105] 날짜 매핑 방법 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
ch1hyun committed Jan 18, 2025
1 parent dd39674 commit d7c3889
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
) {
Expand All @@ -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()
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<CreateFestivalStageRequest> festivalStages
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,23 @@
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,
String festivalPosterBgPath,
String festivalInfoImgPath,
String festivalReservationBgPath,
String festivalLogoPath,
@DateTimeFormat(pattern = "yyyy.MM.dd")
LocalDate reserveAt,
String reservationUrl,
String reservationOffice,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<CreateFestivalArtistRequest> festivalArtists
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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,
Expand All @@ -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(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@
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,
String posterUrl,
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,
Expand All @@ -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(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

import java.util.List;

public record UserFavoriteResponse(List<UserFavoriteListResponse> artists) {
public record UserFavoriteResponse(
List<UserFavoriteListResponse> artists
) {
public static UserFavoriteResponse from(final List<UserFavoriteArtistListDTO> artistListDTO) {
return new UserFavoriteResponse(
artistListDTO.stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/org/sopt/confeti/global/util/DateConvertor.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit d7c3889

Please sign in to comment.