-
Notifications
You must be signed in to change notification settings - Fork 4
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
상위 입찰자 발생 시 기존 마지막 입찰자에게 알림을 전송하는 기능 추가 #438
Merged
Merged
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
fa2e12c
feat: 상위 입찰 발생 시 기존 마지막 입찰자에게 알림 전송하는 기능 추가
kwonyj1022 eab6a27
feat: 레포지토리에서 경매 조회 시 마지막 입찰과 경매 대표이미지를 함께 조회하는 기능 추가
kwonyj1022 3af0287
ci: 브랜치 최신화
kwonyj1022 48a1066
refactor: 경매 이미지 경로 계산 부분 유틸로 분리
kwonyj1022 ac374ed
test: 이미지 url 처리 관련 테스트 추가
kwonyj1022 e586607
rename: 잘못된 변수명 수정 및 return문 개행 추가
kwonyj1022 9ccd624
style: todo 추가
kwonyj1022 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) { | ||
} |
16 changes: 16 additions & 0 deletions
16
...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,16 @@ | ||
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 { | ||
} | ||
|
||
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
82 changes: 82 additions & 0 deletions
82
...g/ddang/auction/infrastructure/persistence/QuerydslAuctionAndImageRepositoryImplTest.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,82 @@ | ||
package com.ddang.ddang.auction.infrastructure.persistence; | ||
|
||
import com.ddang.ddang.auction.domain.Auction; | ||
import com.ddang.ddang.auction.domain.BidUnit; | ||
import com.ddang.ddang.auction.domain.Price; | ||
import com.ddang.ddang.auction.infrastructure.persistence.dto.AuctionAndImageDto; | ||
import com.ddang.ddang.configuration.JpaConfiguration; | ||
import com.ddang.ddang.configuration.QuerydslConfiguration; | ||
import com.ddang.ddang.image.domain.AuctionImage; | ||
import com.ddang.ddang.image.domain.ProfileImage; | ||
import com.ddang.ddang.image.infrastructure.persistence.JpaAuctionImageRepository; | ||
import com.ddang.ddang.user.domain.User; | ||
import com.ddang.ddang.user.infrastructure.persistence.JpaUserRepository; | ||
import jakarta.persistence.EntityManager; | ||
import jakarta.persistence.PersistenceContext; | ||
import org.junit.jupiter.api.DisplayNameGeneration; | ||
import org.junit.jupiter.api.DisplayNameGenerator; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; | ||
import org.springframework.context.annotation.Import; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
@DataJpaTest | ||
@DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class) | ||
@SuppressWarnings("NonAsciiCharacters") | ||
@Import({JpaConfiguration.class, QuerydslConfiguration.class}) | ||
class QuerydslAuctionAndImageRepositoryImplTest { | ||
|
||
@PersistenceContext | ||
EntityManager em; | ||
|
||
@Autowired | ||
JpaAuctionRepository auctionRepository; | ||
|
||
@Autowired | ||
JpaAuctionImageRepository auctionImageRepository; | ||
|
||
@Autowired | ||
JpaUserRepository userRepository; | ||
|
||
@Test | ||
void 경매와_경매_대표이미지를_조회한다() { | ||
// given | ||
final Auction auction = Auction.builder() | ||
.title("경매 상품 1") | ||
.description("이것은 경매 상품 1 입니다.") | ||
.bidUnit(new BidUnit(1_000)) | ||
.startPrice(new Price(1_000)) | ||
.closingTime(LocalDateTime.now()) | ||
.build(); | ||
final AuctionImage auctionImage = new AuctionImage("upload.png", "store.png"); | ||
auctionImageRepository.save(auctionImage); | ||
auction.addAuctionImages(List.of(auctionImage)); | ||
|
||
final User user = User.builder() | ||
.name("사용자") | ||
.profileImage(new ProfileImage("upload.png", "store.png")) | ||
.reliability(4.7d) | ||
.oauthId("12345") | ||
.build(); | ||
|
||
auctionRepository.save(auction); | ||
userRepository.save(user); | ||
|
||
final AuctionAndImageDto expect = new AuctionAndImageDto(auction, auction.getAuctionImages().get(0)); | ||
|
||
em.flush(); | ||
em.clear(); | ||
|
||
// when | ||
final Optional<AuctionAndImageDto> actual = auctionRepository.findDtoByAuctionId(auction.getId()); | ||
|
||
// then | ||
assertThat(actual).contains(expect); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
다른 dto로 변경하는 코드니까
toAuctionAndImageDto
로 변경해야 할 것 같아요!