-
Notifications
You must be signed in to change notification settings - Fork 5
[FEATURE] : [경매 종료가 임박한 진행중인 경매 목록 조회] #37
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
Changes from all commits
b3f344c
3581808
1edfd44
f3f95cc
066a43d
2499cc3
a70040e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,10 +5,12 @@ | |
| import com.tasksprints.auction.domain.auction.model.AuctionCategory; | ||
| import com.tasksprints.auction.domain.auction.repository.support.AuctionCriteriaRepository; | ||
| import com.tasksprints.auction.domain.product.model.ProductCategory; | ||
| import com.tasksprints.auction.domain.auction.model.AuctionStatus; | ||
| import org.springframework.data.jpa.repository.JpaRepository; | ||
| import org.springframework.data.jpa.repository.Query; | ||
| import org.springframework.data.repository.query.Param; | ||
|
|
||
| import java.time.LocalDateTime; | ||
| import java.util.List; | ||
| import java.util.Optional; | ||
|
|
||
|
|
@@ -24,5 +26,6 @@ public interface AuctionRepository extends JpaRepository<Auction, Long>, Auction | |
| List<Auction> findAuctionsByAuctionCategory(AuctionCategory auctionCategory); | ||
|
|
||
| List<Auction> findAuctionByProduct_Category(ProductCategory productCategory); | ||
| List<Auction> findAuctionsByEndTimeBetweenAndAuctionStatusOrderByEndTimeAsc(LocalDateTime now, LocalDateTime next24Hours, AuctionStatus auctionStatus); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 얘도 어떻게보면, 필터 계열로 쓰일 수 있는 것이라고 생각이 듭니다. 기존 함수에서 인자 값을 추가 해주는 것은 어떨까라는 생각이 들어서 조금 아쉽습니다!! |
||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,11 +2,20 @@ | |
|
|
||
| import com.tasksprints.auction.domain.auction.model.Auction; | ||
| import com.tasksprints.auction.domain.auction.model.AuctionCategory; | ||
| import com.tasksprints.auction.domain.auction.model.AuctionStatus; | ||
| import com.tasksprints.auction.domain.product.model.ProductCategory; | ||
|
|
||
|
|
||
| import java.time.Duration; | ||
| import java.time.LocalDateTime; | ||
| import java.util.List; | ||
|
|
||
| public interface AuctionCriteriaRepository { | ||
| public List<Auction> getAuctionsByFilters(ProductCategory productCategory, | ||
| AuctionCategory category); | ||
| AuctionCategory category, | ||
| LocalDateTime now, | ||
| LocalDateTime endTime, | ||
| AuctionStatus status); | ||
| //삭제해야 함 | ||
| public List<Auction> getAuctionsEndWith24Hours(LocalDateTime now, LocalDateTime next24Hours, AuctionStatus auctionStatus); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 기존에 있던 것을 활용해서 되었을 것 같습니다. 인자가 많다면, 묶어서 Condition 이라는 DTO 를 통해서 연결 하면 더 좋을 듯 합니다. |
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,17 @@ | ||
| package com.tasksprints.auction.domain.auction.repository.support; | ||
|
|
||
| import com.querydsl.core.types.dsl.BooleanExpression; | ||
| import com.querydsl.jpa.impl.JPAQueryFactory; | ||
| import com.tasksprints.auction.domain.auction.model.Auction; | ||
| import com.tasksprints.auction.domain.auction.model.AuctionCategory; | ||
| import com.tasksprints.auction.domain.auction.model.AuctionStatus; | ||
| import com.tasksprints.auction.domain.auction.model.QAuction; | ||
| import com.tasksprints.auction.domain.product.model.ProductCategory; | ||
| import com.tasksprints.auction.domain.product.model.QProduct; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.stereotype.Repository; | ||
|
|
||
| import java.time.LocalDateTime; | ||
| import java.util.List; | ||
|
|
||
| @RequiredArgsConstructor | ||
|
|
@@ -17,16 +20,39 @@ public class AuctionCriteriaRepositoryImpl implements AuctionCriteriaRepository | |
| private final JPAQueryFactory queryFactory; | ||
|
|
||
| public List<Auction> getAuctionsByFilters(ProductCategory productCategory, | ||
| AuctionCategory category | ||
| AuctionCategory category, | ||
| LocalDateTime now, | ||
| LocalDateTime endTime, | ||
| AuctionStatus status | ||
| ) { | ||
| QAuction auction = QAuction.auction; | ||
| QProduct product = QProduct.product; | ||
| return queryFactory.selectFrom(auction) | ||
| .leftJoin(auction.product, product) // Auction과 Product 조인 | ||
| .where(category != null ? auction.auctionCategory.eq(category) : null) | ||
| .where(productCategory != null ? product.category.eq(productCategory) : null) // ProductCategory 필터 | ||
| .where((now != null && endTime != null) ? auction.endTime.between(now, endTime) : null) | ||
| .where(status != null ? auction.auctionStatus.eq(status) : null) | ||
| // orderBy는 성능 이슈로 일단 보류 | ||
| // .orderBy(auction.endTime.asc()) | ||
| .fetch(); | ||
| } | ||
|
|
||
|
|
||
| @Deprecated | ||
| @Override | ||
| public List<Auction> getAuctionsEndWith24Hours(LocalDateTime now, LocalDateTime next24Hours, AuctionStatus auctionStatus) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 기존에 사용하는 함수의 역할과 크게 차이가 나지 않는다고 생각합니다. |
||
| QAuction auction = QAuction.auction; | ||
|
|
||
| BooleanExpression endTimeBetween = auction.endTime.between(now, next24Hours); | ||
| BooleanExpression statusEquals = auction.auctionStatus.eq(auctionStatus); | ||
|
|
||
| return queryFactory | ||
| .selectFrom(auction) | ||
| .where(endTimeBetween.and(statusEquals)) | ||
| .orderBy(auction.endTime.asc()) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 넵 노력하겠습니다 |
||
| .fetch(); | ||
| } | ||
|
|
||
|
|
||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.