-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* feat: 상위 입찰 발생 시 기존 마지막 입찰자에게 알림 전송하는 기능 추가 * feat: 레포지토리에서 경매 조회 시 마지막 입찰과 경매 대표이미지를 함께 조회하는 기능 추가 * refactor: 경매 이미지 경로 계산 부분 유틸로 분리 * test: 이미지 url 처리 관련 테스트 추가 * rename: 잘못된 변수명 수정 및 return문 개행 추가 * style: todo 추가
- Loading branch information
1 parent
3a697eb
commit 43485e0
Showing
16 changed files
with
568 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
...com/ddang/ddang/auction/infrastructure/persistence/QuerydslAuctionAndImageRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.ddang.ddang.auction.infrastructure.persistence; | ||
|
||
import com.ddang.ddang.auction.infrastructure.persistence.dto.AuctionAndImageDto; | ||
|
||
import java.util.Optional; | ||
|
||
public interface QuerydslAuctionAndImageRepository { | ||
|
||
Optional<AuctionAndImageDto> findDtoByAuctionId(final Long auctionId); | ||
} |
46 changes: 46 additions & 0 deletions
46
...ddang/ddang/auction/infrastructure/persistence/QuerydslAuctionAndImageRepositoryImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.ddang.ddang.auction.infrastructure.persistence; | ||
|
||
import com.ddang.ddang.auction.infrastructure.persistence.dto.AuctionAndImageDto; | ||
import com.ddang.ddang.auction.infrastructure.persistence.dto.AuctionAndImageQueryProjectionDto; | ||
import com.ddang.ddang.auction.infrastructure.persistence.dto.QAuctionAndImageQueryProjectionDto; | ||
import com.querydsl.jpa.JPAExpressions; | ||
import com.querydsl.jpa.impl.JPAQueryFactory; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import java.util.Optional; | ||
|
||
import static com.ddang.ddang.auction.domain.QAuction.auction; | ||
import static com.ddang.ddang.bid.domain.QBid.bid; | ||
import static com.ddang.ddang.image.domain.QAuctionImage.auctionImage; | ||
|
||
@Repository | ||
@RequiredArgsConstructor | ||
public class QuerydslAuctionAndImageRepositoryImpl implements QuerydslAuctionAndImageRepository { | ||
|
||
private final JPAQueryFactory queryFactory; | ||
|
||
@Override | ||
public Optional<AuctionAndImageDto> findDtoByAuctionId(final Long auctionId) { | ||
final AuctionAndImageQueryProjectionDto auctionAndImageQueryProjectionDto = | ||
queryFactory.select(new QAuctionAndImageQueryProjectionDto(auction, auctionImage)) | ||
.from(auction) | ||
.leftJoin(auction.lastBid, bid).fetchJoin() | ||
.leftJoin(bid.bidder).fetchJoin() | ||
.leftJoin(auctionImage).on(auctionImage.id.eq( | ||
JPAExpressions | ||
.select(auctionImage.id.min()) | ||
.from(auctionImage) | ||
.where(auctionImage.auction.id.eq(auction.id)) | ||
.groupBy(auctionImage.auction.id) | ||
)).fetchJoin() | ||
.where(auction.id.eq(auctionId)) | ||
.fetchOne(); | ||
|
||
if (auctionAndImageQueryProjectionDto == null) { | ||
return Optional.empty(); | ||
} | ||
|
||
return Optional.of(auctionAndImageQueryProjectionDto.toDto()); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
.../main/java/com/ddang/ddang/auction/infrastructure/persistence/dto/AuctionAndImageDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.ddang.ddang.auction.infrastructure.persistence.dto; | ||
|
||
import com.ddang.ddang.auction.domain.Auction; | ||
import com.ddang.ddang.image.domain.AuctionImage; | ||
|
||
public record AuctionAndImageDto(Auction auction, AuctionImage auctionImage) { | ||
} |
17 changes: 17 additions & 0 deletions
17
...ddang/ddang/auction/infrastructure/persistence/dto/AuctionAndImageQueryProjectionDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.ddang.ddang.auction.infrastructure.persistence.dto; | ||
|
||
import com.ddang.ddang.auction.domain.Auction; | ||
import com.ddang.ddang.image.domain.AuctionImage; | ||
import com.querydsl.core.annotations.QueryProjection; | ||
|
||
public record AuctionAndImageQueryProjectionDto(Auction auction, AuctionImage auctionImage) { | ||
|
||
@QueryProjection | ||
public AuctionAndImageQueryProjectionDto { | ||
} | ||
|
||
// TODO: 2023/09/22 dto이름 정해지면 명확한 dto이름으로 바꾸기 | ||
public AuctionAndImageDto toDto() { | ||
return new AuctionAndImageDto(this.auction, this.auctionImage); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.