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 : 마이페이지 내 예매목록조회 슬라이스 적용 #278

Merged
merged 3 commits into from
Feb 3, 2023
Merged
Changes from 1 commit
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
Prev Previous commit
refactor : sliceutil 적용
  • Loading branch information
ImNM committed Feb 3, 2023
commit ed15c3954b9e19c9462ee22d36c7c8394df60bae
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@
import static band.gosrock.domain.domains.order.domain.QOrder.order;
import static band.gosrock.domain.domains.user.domain.QUser.user;

import band.gosrock.domain.common.util.SliceUtil;
import band.gosrock.domain.domains.order.domain.Order;
import band.gosrock.domain.domains.order.repository.condition.FindEventOrdersCondition;
import band.gosrock.domain.domains.order.repository.condition.FindMyPageOrderCondition;
@@ -18,7 +19,6 @@
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Slice;
import org.springframework.data.domain.SliceImpl;
import org.springframework.data.support.PageableExecutionUtils;

@RequiredArgsConstructor
@@ -28,8 +28,6 @@ public class OrderCustomRepositoryImpl implements OrderCustomRepository {

@Override
public Slice<Order> findMyOrders(FindMyPageOrderCondition condition, Pageable pageable) {
// OrderSpecifier[] orderBy = QueryDslUtil.getOrderSpecifiers(Order.class, pageable);
// 오류남
List<Order> orders =
queryFactory
.selectFrom(order)
@@ -38,20 +36,12 @@ public Slice<Order> findMyOrders(FindMyPageOrderCondition condition, Pageable pa
.where(
eqUserId(condition.getUserId()),
openingState(condition.getShowing()))
.orderBy(order.id.desc()) // 여기서 적용하면 오류 남
.orderBy(order.id.desc())
.offset(pageable.getOffset())
.limit(pageable.getPageSize() + 1)
.fetch();

return new SliceImpl<>(orders, pageable, hasNext(orders, pageable));
}

private Boolean hasNext(List<Order> orders, Pageable pageable) {
if (orders.size() > pageable.getPageSize()) {
orders.remove(pageable.getPageSize());
return Boolean.TRUE;
}
return Boolean.FALSE;
return SliceUtil.valueOf(orders, pageable);
}

@Override