Skip to content

Commit

Permalink
๐Ÿž BugFix/#134 - 3.1 ๊ฐ€๊ฒŒ ๋ฆฌ์ŠคํŠธ ์กฐํšŒ event join ์ œ๊ฑฐ (#132)
Browse files Browse the repository at this point in the history
* โ™ป๏ธ refactor/#133 : 5.2 ์˜จ๊ธฐ ์šฐํŽธํ•จ created date ์†์„ฑ ์ถ”๊ฐ€ (#131)

Signed-off-by: EunJiJung <[email protected]>

* ๐Ÿž bugfix/#134 : 3.1 ๊ฐ€๊ฒŒ ๋ฆฌ์ŠคํŠธ ์กฐํšŒ event join ์ œ๊ฑฐ

Signed-off-by: EunJiJung <[email protected]>

---------

Signed-off-by: EunJiJung <[email protected]>
  • Loading branch information
bianbbc87 authored Nov 23, 2024
1 parent 769e3dd commit 5a1c2f6
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,8 @@ public ReadStoreOverviewsResponseDto execute(
// title null ์ฒ˜๋ฆฌ
title = storeService.convertToTitle(title);

Page<Store> storesPage = storeRepository.findStoresByEarliestEventOrdered(title, onjungTagsList, pageable);
Page<Store> storesPage = storeRepository.findStores(title, onjungTagsList, pageable);

/*
// ์ƒ์ ์ด ์—†์„ ๊ฒฝ์šฐ
if (storeList.isEmpty()) {
return new ReadStoreOverviewsResponseDto(false, List.of());
}
*/
// total onjung count๋ณ„ ์ •๋ ฌ
List<ReadStoreOverviewsResponseDto.StoreOverviewDto> storeOverviewDtos = storesPage.stream()
.map(store -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,12 @@ public interface StoreRepository extends JpaRepository <Store, Long> {
Optional<Store> findWithOnjungTagsById(Long id);

@Query("SELECT s FROM Store s " +
"LEFT JOIN s.events e ON e.endDate = ( " +
" SELECT MIN(e1.endDate) FROM Event e1 " +
" WHERE e1.store.id = s.id AND e1.endDate > CURRENT_DATE" +
") " +
"LEFT JOIN s.onjungTags tag " +
"WHERE (:title IS NULL OR s.title LIKE %:title%) " +
"AND (:onjungTags IS NULL OR tag IN :onjungTags) " +
"GROUP BY s.id " +
"ORDER BY MIN(e.endDate) ASC")
Page<Store> findStoresByEarliestEventOrdered(
"ORDER BY s.id ASC") // ์ •๋ ฌ ๊ธฐ์ค€์„ ID๋กœ ์œ ์ง€ํ•˜๊ฑฐ๋‚˜ ์›ํ•˜๋Š” ๊ธฐ์ค€์œผ๋กœ ์ˆ˜์ •
Page<Store> findStores(
@Param("title") String title,
@Param("onjungTags") List<EOnjungTag> onjungTags,
Pageable pageable
Expand Down
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

0 comments on commit 5a1c2f6

Please sign in to comment.