Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

πŸ”¨ Refactor/#133 : 5.2 온기 μš°νŽΈν•¨ created date 속성 μΆ”κ°€ #131

Merged
merged 1 commit into from
Nov 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/main/java/com/daon/onjung/core/utility/DateTimeUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class DateTimeUtil {
public static final DateTimeFormatter ISODateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
public static final DateTimeFormatter ISOTimeFormatter = DateTimeFormatter.ofPattern("HH:mm");
public static final DateTimeFormatter KORDateFormatter = DateTimeFormatter.ofPattern("yyyyλ…„ MMμ›” dd일"); // μƒˆλ‘œμš΄ 포맷터 μΆ”κ°€
public static final DateTimeFormatter SHORTKORDateFormatter = DateTimeFormatter.ofPattern("yyλ…„ MMμ›” dd일");
public static final DateTimeFormatter KORYearMonthDateFormatter = DateTimeFormatter.ofPattern("yyyyλ…„ MMμ›”"); // μƒˆλ‘œμš΄ 포맷터 μΆ”κ°€
public static final DateTimeFormatter DotSeparatedDateFormatter = DateTimeFormatter.ofPattern("yyyy.MM.dd");
public static final DateTimeFormatter CustomDateFormatter = DateTimeFormatter.ofPattern("yyyy.MM.dd (EEE)", Locale.KOREAN);
Expand Down Expand Up @@ -120,6 +121,16 @@ public static String convertLocalDateToKORString(LocalDateTime date) {
return date.format(KORDateFormatter);
}

/**
* LocalDateTime을 짧은 ν•œκ΅­μ–΄ λ‚ μ§œ ν˜•μ‹μœΌλ‘œ λ³€ν™˜ (yyλ…„ MMμ›” dd일)
*
* @param date LocalDateTime
* @return String
*/
public static String convertLocalDateTimeToSHORTKORString(LocalDateTime date) {
return date.format(SHORTKORDateFormatter);
}

/**
* String(ν•œκ΅­μ–΄ λ‚ μ§œ ν˜•μ‹, yyyyλ…„ MMμ›” dd일)을 LocalDate둜 λ³€ν™˜
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ public static class EventDto {
@JsonProperty("store_info")
private final StoreInfoDto storeInfo;

@NotNull(message = "created_date은 null일 수 μ—†μŠ΅λ‹ˆλ‹€.")
@JsonProperty("created_date")
private final String createdDate;

@NotNull(message = "onjung_type은 null일 수 μ—†μŠ΅λ‹ˆλ‹€.")
@JsonProperty("onjung_type")
private final EOnjungType onjungType;
Expand All @@ -70,6 +74,7 @@ public static class EventDto {
@Builder
public EventDto(
StoreInfoDto storeInfo,
String createdDate,
EOnjungType onjungType,
EStatus status,
String eventPeriod,
Expand All @@ -78,6 +83,7 @@ public EventDto(
String reportDate
) {
this.storeInfo = storeInfo;
this.createdDate = createdDate;
this.onjungType = onjungType;
this.status = status;
this.eventPeriod = eventPeriod;
Expand All @@ -88,6 +94,7 @@ public EventDto(

public static EventDto fromEntity(
StoreInfoDto storeInfo,
String createdDate,
EOnjungType onjungType,
EStatus status,
String eventPeriod,
Expand All @@ -98,6 +105,7 @@ public static EventDto fromEntity(

return EventDto.builder()
.storeInfo(storeInfo)
.createdDate(createdDate)
.onjungType(onjungType)
.status(status)
.eventPeriod(eventPeriod)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public ReadOnjungEventOverviewResponseDto execute(
donation.getStore().getTitle(),
donation.getStore().getName()
),
DateTimeUtil.convertLocalDateTimeToSHORTKORString(donation.getCreatedAt()),
EOnjungType.fromString("DONATION"),
event.getStatus(),
DateTimeUtil.convertLocalDatesToDotSeparatedDatePeriod(event.getStartDate(), event.getEndDate()),
Expand All @@ -97,6 +98,7 @@ public ReadOnjungEventOverviewResponseDto execute(
receipt.getStore().getTitle(),
receipt.getStore().getName()
),
DateTimeUtil.convertLocalDateTimeToSHORTKORString(receipt.getCreatedAt()),
EOnjungType.fromString("RECEIPT"),
EStatus.COMPLETED,
DateTimeUtil.convertLocalDateToDotSeparatedDateTime(receipt.getCreatedAt().toLocalDate()),
Expand All @@ -112,6 +114,7 @@ public ReadOnjungEventOverviewResponseDto execute(
share.getStore().getTitle(),
share.getStore().getName()
),
DateTimeUtil.convertLocalDateTimeToSHORTKORString(share.getCreatedAt().atTime(0, 0)),
EOnjungType.fromString("SHARE"),
EStatus.COMPLETED,
DateTimeUtil.convertLocalDateToDotSeparatedDateTime(share.getCreatedAt()),
Expand Down
Loading