From bd6a2dd1e81fcc121976d541034b74ee178a0483 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=85=B8=EA=B2=BD=EB=AF=BC?= Date: Tue, 7 Mar 2023 11:39:25 +0900 Subject: [PATCH] =?UTF-8?q?fix=20:=20=EA=B3=B5=EC=97=B0=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C=20=EA=B8=B0=ED=9A=8D=20=EB=B3=80=EA=B2=BD=20=EB=B0=98?= =?UTF-8?q?=EC=98=81=20(#528)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/EventCustomRepositoryImpl.java | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/DuDoong-Domain/src/main/java/band/gosrock/domain/domains/event/repository/EventCustomRepositoryImpl.java b/DuDoong-Domain/src/main/java/band/gosrock/domain/domains/event/repository/EventCustomRepositoryImpl.java index 76b5ef60..4af39640 100644 --- a/DuDoong-Domain/src/main/java/band/gosrock/domain/domains/event/repository/EventCustomRepositoryImpl.java +++ b/DuDoong-Domain/src/main/java/band/gosrock/domain/domains/event/repository/EventCustomRepositoryImpl.java @@ -29,7 +29,7 @@ public Slice querySliceEventsByHostIdIn(List hostIds, Pageable page queryFactory .selectFrom(event) .where(hostIdIn(hostIds)) - .orderBy(event.id.desc()) + .orderBy(statusDesc(), createdAtDesc()) .offset(pageable.getOffset()) .limit(pageable.getPageSize() + 1) .fetch(); @@ -41,8 +41,8 @@ public Slice querySliceEventsByStatus(EventStatus status, Pageable pageab List events = queryFactory .selectFrom(event) - .where(eqStatusOpen()) - .orderBy(createdAtDesc()) + .where(statusEq(status)) + .orderBy(statusDesc(), startAtAsc()) .offset(pageable.getOffset()) .limit(pageable.getPageSize() + 1) .fetch(); @@ -54,8 +54,8 @@ public Slice querySliceEventsByKeyword(String keyword, Pageable pageable) List events = queryFactory .selectFrom(event) - .where(eqStatusOpen().and(nameContains(keyword))) - .orderBy(createdAtDesc()) + .where(nameContains(keyword)) + .orderBy(statusDesc(), startAtAsc()) .offset(pageable.getOffset()) .limit(pageable.getPageSize() + 1) .fetch(); @@ -75,6 +75,10 @@ private BooleanExpression eqStatusOpen() { return event.status.eq(OPEN); } + private BooleanExpression statusEq(EventStatus status) { + return event.status.eq(status); + } + private BooleanExpression notEqClosed() { return event.status.eq(CLOSED).not(); } @@ -87,6 +91,14 @@ private OrderSpecifier createdAtDesc() { return event.createdAt.desc(); } + private OrderSpecifier startAtAsc() { + return event.eventBasic.startAt.asc(); + } + + private OrderSpecifier statusDesc() { + return event.status.desc(); + } + private BooleanExpression endAtBefore(LocalDateTime time) { DateTemplate eventEndAtTemplate = Expressions.dateTemplate(