Skip to content

Commit

Permalink
Merge pull request KCS-final#75 from KCS-final/feat/auctionList-12
Browse files Browse the repository at this point in the history
refactor: ItemRepository - 거래방법 특정방법 및 전체 같이 조회되는 로직
  • Loading branch information
InhongLee95 authored May 24, 2024
2 parents cfc25bf + aadb6d8 commit 837b7c3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public record ProgressItemsDto(
String thumbnail,
int startPrice,
int currentPrice,
int buyNowPrice,
boolean isAuctionComplete
) {
public static ProgressItemsDto fromProgressEntity(AuctionProgressItem progressItem) {
Expand All @@ -26,7 +27,8 @@ public static ProgressItemsDto fromProgressEntity(AuctionProgressItem progressIt
.tradingMethod(progressItem.getItem().getTradingMethod().getTradingMethod())
.thumbnail(progressItem.getThumbnail())
.startPrice(progressItem.getStartPrice())
.currentPrice(progressItem.getMaxPrice())
.currentPrice((progressItem.getMaxPersonNickName() != null)?progressItem.getMaxPrice():0)
.buyNowPrice(progressItem.getBuyNowPrice())
.isAuctionComplete(progressItem.getItem().isAuctionComplete())
.build();
}
Expand All @@ -39,7 +41,8 @@ public static ProgressItemsDto fromCompletionEntity(AuctionCompleteItem complete
.tradingMethod(completeItem.getItem().getTradingMethod().getTradingMethod())
.thumbnail(completeItem.getThumbnail())
.startPrice(completeItem.getStartPrice())
.currentPrice(completeItem.getMaxPrice())
.currentPrice((completeItem.getMaxPersonNickName() != null)?completeItem.getMaxPrice():0)
.buyNowPrice(completeItem.getBuyNowPrice())
.isAuctionComplete(completeItem.getItem().isAuctionComplete())
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public interface ItemRepository extends JpaRepository<Item, Long> {
"JOIN FETCH item.tradingMethod method " +
"JOIN FETCH item.region region " +
"WHERE (:category IS NULL OR category.category = :category) " +
"AND (:method IS NULL OR method.tradingMethod = :method) " +
"AND (:method IS NULL OR method.tradingMethod = :method OR method.tradingMethod = 3) " +
"AND (:region IS NULL OR region.region = :region) " +
"ORDER BY item.itemId DESC")
Slice<AuctionProgressItem> findByProgressItemWithLocationAndMethodAndRegion(
Expand All @@ -55,7 +55,7 @@ Slice<AuctionProgressItem> findByProgressItemWithLocationAndMethodAndRegion(
"JOIN FETCH item.tradingMethod method " +
"JOIN FETCH item.region region " +
"WHERE (:category IS NULL OR category.category = :category) " +
"AND (:method IS NULL OR method.tradingMethod = :method) " +
"AND (:method IS NULL OR method.tradingMethod = :method OR method.tradingMethod = 3) " +
"AND (:region IS NULL OR region.region = :region) " +
"ORDER BY item.itemId DESC")
Slice<AuctionCompleteItem> findByCompleteItemWithLocationAndMethodAndRegion(
Expand Down

0 comments on commit 837b7c3

Please sign in to comment.