From f1fff594e55294e1b52270d6911683b1001cbe17 Mon Sep 17 00:00:00 2001 From: kwonyj1022 Date: Thu, 19 Oct 2023 00:43:40 +0900 Subject: [PATCH 01/15] =?UTF-8?q?refactor:=20=EC=9D=B4=EB=AF=B8=EC=A7=80?= =?UTF-8?q?=20=EC=83=81=EB=8C=80=20url=20=EA=B8=B0=EB=B0=98=EC=9C=BC?= =?UTF-8?q?=EB=A1=9C=20url=EC=9D=84=20=EA=B3=84=EC=82=B0=ED=95=98=EB=8A=94?= =?UTF-8?q?=20=EB=A9=94=EC=84=9C=EB=93=9C=20=ED=8C=8C=EB=9D=BC=EB=AF=B8?= =?UTF-8?q?=ED=84=B0=EB=A1=9C=20=EC=9D=B4=EB=AF=B8=EC=A7=80=20id=20?= =?UTF-8?q?=EB=8C=80=EC=8B=A0=20=EC=9D=B4=EB=AF=B8=EC=A7=80=20=EC=9D=B4?= =?UTF-8?q?=EB=A6=84=EC=9D=84=20=EB=B0=9B=EB=8F=84=EB=A1=9D=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/dto/CreateInfoAuctionDto.java | 5 ++-- .../application/dto/ReadAuctionDto.java | 15 +++++------ .../dto/response/AuctionDetailResponse.java | 4 +-- .../dto/response/CreateAuctionResponse.java | 6 ++--- .../dto/response/ReadAuctionResponse.java | 2 +- .../ReadUserInAuctionQuestionResponse.java | 2 +- .../dto/response/SellerResponse.java | 2 +- .../ddang/bid/application/dto/ReadBidDto.java | 6 ++--- .../dto/response/ReadBidResponse.java | 2 +- .../dto/ReadAuctionInChatRoomDto.java | 5 ++-- .../dto/ReadUserInChatRoomDto.java | 6 ++--- .../ReadAuctionInChatRoomResponse.java | 2 +- .../dto/response/ReadChatPartnerResponse.java | 2 +- .../application/util/ImageIdProcessor.java | 26 ------------------- .../util/ImageStoreNameProcessor.java | 26 +++++++++++++++++++ .../ddang/image/domain/ProfileImage.java | 2 -- .../presentation/util/ImageUrlCalculator.java | 10 +++---- .../qna/application/dto/ReadUserInQnaDto.java | 5 ++-- .../application/dto/ReadReporterDto.java | 6 ++--- .../application/dto/ReadUserInReportDto.java | 6 ++--- .../application/dto/ReadUserInReviewDto.java | 5 ++-- .../response/ReadUserInReviewResponse.java | 2 +- .../user/application/dto/ReadUserDto.java | 6 ++--- .../presentation/dto/ReadUserResponse.java | 2 +- .../dto/response/AuctionDetailResponse.java | 4 +-- .../response/ReadAuctionDetailResponse.java | 2 +- .../dto/response/ReadAuctionResponse.java | 4 +-- .../dto/response/ReadUserResponse.java | 2 +- .../fixture/AuctionControllerFixture.java | 19 +++++++------- .../AuctionQuestionControllerFixture.java | 4 +-- .../AuctionReviewControllerFixture.java | 4 +-- .../fixture/BidControllerFixture.java | 4 +-- .../fixture/ChatRoomControllerFixture.java | 10 +++---- ....java => ImageStoreNameProcessorTest.java} | 18 ++++++------- .../util/fixture/ImageIdProcessorFixture.java | 8 +++--- .../util/ImageUrlCalculatorTest.java | 12 ++++----- .../fixture/ImageUrlCalculatorFixture.java | 9 ++++++- .../fixture/ReportControllerFixture.java | 25 +++++++++--------- .../fixture/ReviewControllerFixture.java | 12 ++++----- .../user/application/UserServiceTest.java | 2 +- .../fixture/UserAuctionControllerFixture.java | 8 +++--- .../fixture/UserControllerFixture.java | 6 ++--- 42 files changed, 159 insertions(+), 149 deletions(-) delete mode 100644 backend/ddang/src/main/java/com/ddang/ddang/image/application/util/ImageIdProcessor.java create mode 100644 backend/ddang/src/main/java/com/ddang/ddang/image/application/util/ImageStoreNameProcessor.java rename backend/ddang/src/test/java/com/ddang/ddang/image/application/util/{ImageIdProcessorTest.java => ImageStoreNameProcessorTest.java} (61%) diff --git a/backend/ddang/src/main/java/com/ddang/ddang/auction/application/dto/CreateInfoAuctionDto.java b/backend/ddang/src/main/java/com/ddang/ddang/auction/application/dto/CreateInfoAuctionDto.java index a86d23dcf..f044074a1 100644 --- a/backend/ddang/src/main/java/com/ddang/ddang/auction/application/dto/CreateInfoAuctionDto.java +++ b/backend/ddang/src/main/java/com/ddang/ddang/auction/application/dto/CreateInfoAuctionDto.java @@ -1,11 +1,12 @@ package com.ddang.ddang.auction.application.dto; import com.ddang.ddang.auction.domain.Auction; +import com.ddang.ddang.image.application.util.ImageStoreNameProcessor; public record CreateInfoAuctionDto( Long id, String title, - Long auctionImageId, + String auctionStoreName, int startPrice ) { @@ -13,7 +14,7 @@ public static CreateInfoAuctionDto from(final Auction auction) { return new CreateInfoAuctionDto( auction.getId(), auction.getTitle(), - auction.getAuctionImages().get(0).getId(), + ImageStoreNameProcessor.process(auction.getAuctionImages().get(0)), auction.getStartPrice().getValue() ); } diff --git a/backend/ddang/src/main/java/com/ddang/ddang/auction/application/dto/ReadAuctionDto.java b/backend/ddang/src/main/java/com/ddang/ddang/auction/application/dto/ReadAuctionDto.java index d5be76317..e56decd82 100644 --- a/backend/ddang/src/main/java/com/ddang/ddang/auction/application/dto/ReadAuctionDto.java +++ b/backend/ddang/src/main/java/com/ddang/ddang/auction/application/dto/ReadAuctionDto.java @@ -3,8 +3,7 @@ import com.ddang.ddang.auction.domain.Auction; import com.ddang.ddang.auction.domain.AuctionStatus; import com.ddang.ddang.bid.domain.Bid; -import com.ddang.ddang.image.application.util.ImageIdProcessor; -import com.ddang.ddang.image.domain.AuctionImage; +import com.ddang.ddang.image.application.util.ImageStoreNameProcessor; import java.time.LocalDateTime; import java.util.List; @@ -20,12 +19,12 @@ public record ReadAuctionDto( LocalDateTime registerTime, LocalDateTime closingTime, List auctionRegions, - List auctionImageIds, + List auctionImageStoreNames, int auctioneerCount, String mainCategory, String subCategory, Long sellerId, - Long sellerProfileId, + String sellerProfileImageStoreName, String sellerName, double sellerReliability, boolean isSellerDeleted, @@ -45,12 +44,12 @@ public static ReadAuctionDto of(final Auction auction, final LocalDateTime targe auction.getCreatedTime(), auction.getClosingTime(), convertReadRegionsDto(auction), - convertImageIds(auction), + convertImageStoreNames(auction), auction.getAuctioneerCount(), auction.getSubCategory().getMainCategory().getName(), auction.getSubCategory().getName(), auction.getSeller().getId(), - ImageIdProcessor.process(auction.getSeller().getProfileImage()), + ImageStoreNameProcessor.process(auction.getSeller().getProfileImage()), auction.getSeller().getName(), auction.getSeller().getReliability().getValue(), auction.getSeller().isDeleted(), @@ -59,10 +58,10 @@ public static ReadAuctionDto of(final Auction auction, final LocalDateTime targe ); } - private static List convertImageIds(final Auction auction) { + private static List convertImageStoreNames(final Auction auction) { return auction.getAuctionImages() .stream() - .map(AuctionImage::getId) + .map(ImageStoreNameProcessor::process) .toList(); } diff --git a/backend/ddang/src/main/java/com/ddang/ddang/auction/presentation/dto/response/AuctionDetailResponse.java b/backend/ddang/src/main/java/com/ddang/ddang/auction/presentation/dto/response/AuctionDetailResponse.java index b4092b2e5..689c548e8 100644 --- a/backend/ddang/src/main/java/com/ddang/ddang/auction/presentation/dto/response/AuctionDetailResponse.java +++ b/backend/ddang/src/main/java/com/ddang/ddang/auction/presentation/dto/response/AuctionDetailResponse.java @@ -57,9 +57,9 @@ public static AuctionDetailResponse from(final ReadAuctionDto dto) { } private static List convertImageFullUrls(final ReadAuctionDto dto) { - return dto.auctionImageIds() + return dto.auctionImageStoreNames() .stream() - .map(id -> ImageUrlCalculator.calculateBy(ImageRelativeUrl.AUCTION, id)) + .map(imageStoreName -> ImageUrlCalculator.calculateBy(ImageRelativeUrl.AUCTION, imageStoreName)) .toList(); } diff --git a/backend/ddang/src/main/java/com/ddang/ddang/auction/presentation/dto/response/CreateAuctionResponse.java b/backend/ddang/src/main/java/com/ddang/ddang/auction/presentation/dto/response/CreateAuctionResponse.java index 2f3c0c9d2..19d4d087e 100644 --- a/backend/ddang/src/main/java/com/ddang/ddang/auction/presentation/dto/response/CreateAuctionResponse.java +++ b/backend/ddang/src/main/java/com/ddang/ddang/auction/presentation/dto/response/CreateAuctionResponse.java @@ -18,14 +18,14 @@ public static CreateAuctionResponse from(final CreateInfoAuctionDto dto) { return new CreateAuctionResponse( dto.id(), dto.title(), - convertAuctionImageUrl(dto.auctionImageId()), + convertAuctionImageUrl(dto.auctionStoreName()), dto.startPrice(), AuctionStatus.UNBIDDEN.name(), 0 ); } - private static String convertAuctionImageUrl(final Long id) { - return ImageUrlCalculator.calculateBy(ImageRelativeUrl.AUCTION, id); + private static String convertAuctionImageUrl(final String storeName) { + return ImageUrlCalculator.calculateBy(ImageRelativeUrl.AUCTION, storeName); } } diff --git a/backend/ddang/src/main/java/com/ddang/ddang/auction/presentation/dto/response/ReadAuctionResponse.java b/backend/ddang/src/main/java/com/ddang/ddang/auction/presentation/dto/response/ReadAuctionResponse.java index 4eee887ff..035e1cd63 100644 --- a/backend/ddang/src/main/java/com/ddang/ddang/auction/presentation/dto/response/ReadAuctionResponse.java +++ b/backend/ddang/src/main/java/com/ddang/ddang/auction/presentation/dto/response/ReadAuctionResponse.java @@ -17,7 +17,7 @@ public static ReadAuctionResponse from(final ReadAuctionDto dto) { return new ReadAuctionResponse( dto.id(), dto.title(), - ImageUrlCalculator.calculateBy(ImageRelativeUrl.AUCTION, dto.auctionImageIds().get(0)), + ImageUrlCalculator.calculateBy(ImageRelativeUrl.AUCTION, dto.auctionImageStoreNames().get(0)), processAuctionPrice(dto.startPrice(), dto.lastBidPrice()), dto.auctionStatus().name(), dto.auctioneerCount() diff --git a/backend/ddang/src/main/java/com/ddang/ddang/auction/presentation/dto/response/ReadUserInAuctionQuestionResponse.java b/backend/ddang/src/main/java/com/ddang/ddang/auction/presentation/dto/response/ReadUserInAuctionQuestionResponse.java index 336306eb2..e637071aa 100644 --- a/backend/ddang/src/main/java/com/ddang/ddang/auction/presentation/dto/response/ReadUserInAuctionQuestionResponse.java +++ b/backend/ddang/src/main/java/com/ddang/ddang/auction/presentation/dto/response/ReadUserInAuctionQuestionResponse.java @@ -11,7 +11,7 @@ public static ReadUserInAuctionQuestionResponse from(final ReadUserInQnaDto writ return new ReadUserInAuctionQuestionResponse( writerDto.id(), NameProcessor.process(writerDto.isDeleted(), writerDto.name()), - ImageUrlCalculator.calculateBy(ImageRelativeUrl.USER, writerDto.profileImageId()) + ImageUrlCalculator.calculateBy(ImageRelativeUrl.USER, writerDto.profileImageStoreName()) ); } } diff --git a/backend/ddang/src/main/java/com/ddang/ddang/auction/presentation/dto/response/SellerResponse.java b/backend/ddang/src/main/java/com/ddang/ddang/auction/presentation/dto/response/SellerResponse.java index 994fa91ac..c5043addd 100644 --- a/backend/ddang/src/main/java/com/ddang/ddang/auction/presentation/dto/response/SellerResponse.java +++ b/backend/ddang/src/main/java/com/ddang/ddang/auction/presentation/dto/response/SellerResponse.java @@ -17,7 +17,7 @@ public static SellerResponse from(final ReadAuctionDto auctionDto) { return new SellerResponse( auctionDto.sellerId(), - ImageUrlCalculator.calculateBy(ImageRelativeUrl.USER, auctionDto.sellerProfileId()), + ImageUrlCalculator.calculateBy(ImageRelativeUrl.USER, auctionDto.sellerProfileImageStoreName()), NameProcessor.process(auctionDto.isSellerDeleted(), auctionDto.sellerName()), floatReliability ); diff --git a/backend/ddang/src/main/java/com/ddang/ddang/bid/application/dto/ReadBidDto.java b/backend/ddang/src/main/java/com/ddang/ddang/bid/application/dto/ReadBidDto.java index d4cf89c82..ecb82854f 100644 --- a/backend/ddang/src/main/java/com/ddang/ddang/bid/application/dto/ReadBidDto.java +++ b/backend/ddang/src/main/java/com/ddang/ddang/bid/application/dto/ReadBidDto.java @@ -1,14 +1,14 @@ package com.ddang.ddang.bid.application.dto; import com.ddang.ddang.bid.domain.Bid; -import com.ddang.ddang.image.application.util.ImageIdProcessor; +import com.ddang.ddang.image.application.util.ImageStoreNameProcessor; import com.ddang.ddang.user.domain.User; import java.time.LocalDateTime; public record ReadBidDto( String name, - Long profileImageId, + String profileImageStoreName, boolean isDeletedUser, int price, LocalDateTime bidTime @@ -19,7 +19,7 @@ public static ReadBidDto from(final Bid bid) { return new ReadBidDto( bidder.getName(), - ImageIdProcessor.process(bidder.getProfileImage()), + ImageStoreNameProcessor.process(bidder.getProfileImage()), bidder.isDeleted(), bid.getPrice().getValue(), bid.getCreatedTime() diff --git a/backend/ddang/src/main/java/com/ddang/ddang/bid/presentation/dto/response/ReadBidResponse.java b/backend/ddang/src/main/java/com/ddang/ddang/bid/presentation/dto/response/ReadBidResponse.java index 6f75d741f..2edc112b9 100644 --- a/backend/ddang/src/main/java/com/ddang/ddang/bid/presentation/dto/response/ReadBidResponse.java +++ b/backend/ddang/src/main/java/com/ddang/ddang/bid/presentation/dto/response/ReadBidResponse.java @@ -23,7 +23,7 @@ public static ReadBidResponse from(final ReadBidDto dto) { final String name = NameProcessor.process(dto.isDeletedUser(), dto.name()); return new ReadBidResponse( name, - ImageUrlCalculator.calculateBy(ImageRelativeUrl.USER, dto.profileImageId()), + ImageUrlCalculator.calculateBy(ImageRelativeUrl.USER, dto.profileImageStoreName()), dto.price(), dto.bidTime() ); diff --git a/backend/ddang/src/main/java/com/ddang/ddang/chat/application/dto/ReadAuctionInChatRoomDto.java b/backend/ddang/src/main/java/com/ddang/ddang/chat/application/dto/ReadAuctionInChatRoomDto.java index 233215c83..b39489800 100644 --- a/backend/ddang/src/main/java/com/ddang/ddang/chat/application/dto/ReadAuctionInChatRoomDto.java +++ b/backend/ddang/src/main/java/com/ddang/ddang/chat/application/dto/ReadAuctionInChatRoomDto.java @@ -2,13 +2,14 @@ import com.ddang.ddang.auction.domain.Auction; import com.ddang.ddang.bid.domain.Bid; +import com.ddang.ddang.image.application.util.ImageStoreNameProcessor; import com.ddang.ddang.image.domain.AuctionImage; public record ReadAuctionInChatRoomDto( Long id, String title, Integer lastBidPrice, - Long thumbnailImageId + String thumbnailImageStoreName ) { public static ReadAuctionInChatRoomDto of(final Auction auction, final AuctionImage thumbnailImage) { @@ -16,7 +17,7 @@ public static ReadAuctionInChatRoomDto of(final Auction auction, final AuctionIm auction.getId(), auction.getTitle(), convertPrice(auction.getLastBid()), - thumbnailImage.getId() + ImageStoreNameProcessor.process(thumbnailImage) ); } diff --git a/backend/ddang/src/main/java/com/ddang/ddang/chat/application/dto/ReadUserInChatRoomDto.java b/backend/ddang/src/main/java/com/ddang/ddang/chat/application/dto/ReadUserInChatRoomDto.java index 604827146..40c76de30 100644 --- a/backend/ddang/src/main/java/com/ddang/ddang/chat/application/dto/ReadUserInChatRoomDto.java +++ b/backend/ddang/src/main/java/com/ddang/ddang/chat/application/dto/ReadUserInChatRoomDto.java @@ -1,15 +1,15 @@ package com.ddang.ddang.chat.application.dto; -import com.ddang.ddang.image.application.util.ImageIdProcessor; +import com.ddang.ddang.image.application.util.ImageStoreNameProcessor; import com.ddang.ddang.user.domain.User; -public record ReadUserInChatRoomDto(Long id, String name, Long profileImageId, double reliability, boolean isDeleted) { +public record ReadUserInChatRoomDto(Long id, String name, String profileImageStoreName, double reliability, boolean isDeleted) { public static ReadUserInChatRoomDto from(final User user) { return new ReadUserInChatRoomDto( user.getId(), user.getName(), - ImageIdProcessor.process(user.getProfileImage()), + ImageStoreNameProcessor.process(user.getProfileImage()), user.getReliability().getValue(), user.isDeleted() ); diff --git a/backend/ddang/src/main/java/com/ddang/ddang/chat/presentation/dto/response/ReadAuctionInChatRoomResponse.java b/backend/ddang/src/main/java/com/ddang/ddang/chat/presentation/dto/response/ReadAuctionInChatRoomResponse.java index be45b0034..3f5d27c00 100644 --- a/backend/ddang/src/main/java/com/ddang/ddang/chat/presentation/dto/response/ReadAuctionInChatRoomResponse.java +++ b/backend/ddang/src/main/java/com/ddang/ddang/chat/presentation/dto/response/ReadAuctionInChatRoomResponse.java @@ -7,7 +7,7 @@ public record ReadAuctionInChatRoomResponse(Long id, String title, String image, int price) { public static ReadAuctionInChatRoomResponse from(final ReadAuctionInChatRoomDto dto) { - final String thumbNailImageUrl = ImageUrlCalculator.calculateBy(ImageRelativeUrl.AUCTION, dto.thumbnailImageId()); + final String thumbNailImageUrl = ImageUrlCalculator.calculateBy(ImageRelativeUrl.AUCTION, dto.thumbnailImageStoreName()); return new ReadAuctionInChatRoomResponse(dto.id(), dto.title(), thumbNailImageUrl, dto.lastBidPrice()); } diff --git a/backend/ddang/src/main/java/com/ddang/ddang/chat/presentation/dto/response/ReadChatPartnerResponse.java b/backend/ddang/src/main/java/com/ddang/ddang/chat/presentation/dto/response/ReadChatPartnerResponse.java index 2a2daab62..95b540d68 100644 --- a/backend/ddang/src/main/java/com/ddang/ddang/chat/presentation/dto/response/ReadChatPartnerResponse.java +++ b/backend/ddang/src/main/java/com/ddang/ddang/chat/presentation/dto/response/ReadChatPartnerResponse.java @@ -13,7 +13,7 @@ public static ReadChatPartnerResponse from(final ReadUserInChatRoomDto dto) { return new ReadChatPartnerResponse( dto.id(), name, - ImageUrlCalculator.calculateBy(ImageRelativeUrl.USER, dto.profileImageId()) + ImageUrlCalculator.calculateBy(ImageRelativeUrl.USER, dto.profileImageStoreName()) ); } } diff --git a/backend/ddang/src/main/java/com/ddang/ddang/image/application/util/ImageIdProcessor.java b/backend/ddang/src/main/java/com/ddang/ddang/image/application/util/ImageIdProcessor.java deleted file mode 100644 index 4492fb6f2..000000000 --- a/backend/ddang/src/main/java/com/ddang/ddang/image/application/util/ImageIdProcessor.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.ddang.ddang.image.application.util; - -import com.ddang.ddang.image.domain.AuctionImage; -import com.ddang.ddang.image.domain.ProfileImage; - -public final class ImageIdProcessor { - - private ImageIdProcessor() { - } - - public static Long process(final ProfileImage profileImage) { - if (profileImage == null) { - return null; - } - - return profileImage.getId(); - } - - public static Long process(final AuctionImage auctionImage) { - if (auctionImage == null) { - return null; - } - - return auctionImage.getId(); - } -} diff --git a/backend/ddang/src/main/java/com/ddang/ddang/image/application/util/ImageStoreNameProcessor.java b/backend/ddang/src/main/java/com/ddang/ddang/image/application/util/ImageStoreNameProcessor.java new file mode 100644 index 000000000..1b59b36ea --- /dev/null +++ b/backend/ddang/src/main/java/com/ddang/ddang/image/application/util/ImageStoreNameProcessor.java @@ -0,0 +1,26 @@ +package com.ddang.ddang.image.application.util; + +import com.ddang.ddang.image.domain.AuctionImage; +import com.ddang.ddang.image.domain.ProfileImage; + +public final class ImageStoreNameProcessor { + + private ImageStoreNameProcessor() { + } + + public static String process(final ProfileImage profileImage) { + if (profileImage == null) { + return null; + } + + return profileImage.getImage().getStoreName(); + } + + public static String process(final AuctionImage auctionImage) { + if (auctionImage == null) { + return null; + } + + return auctionImage.getImage().getStoreName(); + } +} diff --git a/backend/ddang/src/main/java/com/ddang/ddang/image/domain/ProfileImage.java b/backend/ddang/src/main/java/com/ddang/ddang/image/domain/ProfileImage.java index d85c01c1e..e45936a8c 100644 --- a/backend/ddang/src/main/java/com/ddang/ddang/image/domain/ProfileImage.java +++ b/backend/ddang/src/main/java/com/ddang/ddang/image/domain/ProfileImage.java @@ -19,8 +19,6 @@ public class ProfileImage { public static final String DEFAULT_PROFILE_IMAGE_STORE_NAME = "default_profile_image.png"; - // TODO: 10/13/23 앞으로 id가 아닌 store name으로 진행하기로 했는데, 임시로 해둡니다. 추후 삭제해주시면 감사하겠습니다. - public static final String DEFAULT_PROFILE_IMAGE_ID = "1"; @Id @GeneratedValue(strategy = GenerationType.IDENTITY) diff --git a/backend/ddang/src/main/java/com/ddang/ddang/image/presentation/util/ImageUrlCalculator.java b/backend/ddang/src/main/java/com/ddang/ddang/image/presentation/util/ImageUrlCalculator.java index 374a03459..29860b0df 100644 --- a/backend/ddang/src/main/java/com/ddang/ddang/image/presentation/util/ImageUrlCalculator.java +++ b/backend/ddang/src/main/java/com/ddang/ddang/image/presentation/util/ImageUrlCalculator.java @@ -7,19 +7,19 @@ public final class ImageUrlCalculator { private ImageUrlCalculator() { } - public static String calculateBy(final ImageRelativeUrl imageRelativeUrl, final Long id) { + public static String calculateBy(final ImageRelativeUrl imageRelativeUrl, final String storeName) { final String absoluteUrl = imageRelativeUrl.calculateAbsoluteUrl(); - if (id == null && imageRelativeUrl == ImageRelativeUrl.USER) { - return absoluteUrl + ProfileImage.DEFAULT_PROFILE_IMAGE_ID; + if (storeName == null && imageRelativeUrl == ImageRelativeUrl.USER) { + return absoluteUrl + ProfileImage.DEFAULT_PROFILE_IMAGE_STORE_NAME; } - return absoluteUrl + id; + return absoluteUrl + storeName; } public static String calculateBy(final String imageAbsoluteUrl, final Long id) { if (id == null && imageAbsoluteUrl.contains(ImageRelativeUrl.USER.getValue())) { - return imageAbsoluteUrl + ProfileImage.DEFAULT_PROFILE_IMAGE_ID; + return imageAbsoluteUrl + ProfileImage.DEFAULT_PROFILE_IMAGE_STORE_NAME; } return imageAbsoluteUrl + id; diff --git a/backend/ddang/src/main/java/com/ddang/ddang/qna/application/dto/ReadUserInQnaDto.java b/backend/ddang/src/main/java/com/ddang/ddang/qna/application/dto/ReadUserInQnaDto.java index a75d44558..c3d73e9cf 100644 --- a/backend/ddang/src/main/java/com/ddang/ddang/qna/application/dto/ReadUserInQnaDto.java +++ b/backend/ddang/src/main/java/com/ddang/ddang/qna/application/dto/ReadUserInQnaDto.java @@ -1,11 +1,12 @@ package com.ddang.ddang.qna.application.dto; +import com.ddang.ddang.image.application.util.ImageStoreNameProcessor; import com.ddang.ddang.user.domain.User; public record ReadUserInQnaDto( Long id, String name, - Long profileImageId, + String profileImageStoreName, double reliability, String oauthId, boolean isDeleted @@ -14,7 +15,7 @@ public static ReadUserInQnaDto from(final User writer) { return new ReadUserInQnaDto( writer.getId(), writer.getName(), - writer.getProfileImage().getId(), + ImageStoreNameProcessor.process(writer.getProfileImage()), writer.getReliability().getValue(), writer.getOauthInformation().getOauthId(), writer.isDeleted() diff --git a/backend/ddang/src/main/java/com/ddang/ddang/report/application/dto/ReadReporterDto.java b/backend/ddang/src/main/java/com/ddang/ddang/report/application/dto/ReadReporterDto.java index 09e21af9e..5e5847b29 100644 --- a/backend/ddang/src/main/java/com/ddang/ddang/report/application/dto/ReadReporterDto.java +++ b/backend/ddang/src/main/java/com/ddang/ddang/report/application/dto/ReadReporterDto.java @@ -1,15 +1,15 @@ package com.ddang.ddang.report.application.dto; -import com.ddang.ddang.image.application.util.ImageIdProcessor; +import com.ddang.ddang.image.application.util.ImageStoreNameProcessor; import com.ddang.ddang.user.domain.User; -public record ReadReporterDto(Long id, String name, Long profileImageId, double reliability, boolean isDeleted) { +public record ReadReporterDto(Long id, String name, String profileImageStoreName, double reliability, boolean isDeleted) { public static ReadReporterDto from(final User reporter) { return new ReadReporterDto( reporter.getId(), reporter.getName(), - ImageIdProcessor.process(reporter.getProfileImage()), + ImageStoreNameProcessor.process(reporter.getProfileImage()), reporter.getReliability().getValue(), reporter.isDeleted() ); diff --git a/backend/ddang/src/main/java/com/ddang/ddang/report/application/dto/ReadUserInReportDto.java b/backend/ddang/src/main/java/com/ddang/ddang/report/application/dto/ReadUserInReportDto.java index cd4fbd220..119fe432a 100644 --- a/backend/ddang/src/main/java/com/ddang/ddang/report/application/dto/ReadUserInReportDto.java +++ b/backend/ddang/src/main/java/com/ddang/ddang/report/application/dto/ReadUserInReportDto.java @@ -1,12 +1,12 @@ package com.ddang.ddang.report.application.dto; -import com.ddang.ddang.image.application.util.ImageIdProcessor; +import com.ddang.ddang.image.application.util.ImageStoreNameProcessor; import com.ddang.ddang.user.domain.User; public record ReadUserInReportDto( Long id, String name, - Long profileImageId, + String profileImageStoreName, double reliability, String oauthId, boolean isSellerDeleted @@ -16,7 +16,7 @@ public static ReadUserInReportDto from(final User user) { return new ReadUserInReportDto( user.getId(), user.getName(), - ImageIdProcessor.process(user.getProfileImage()), + ImageStoreNameProcessor.process(user.getProfileImage()), user.getReliability().getValue(), user.getOauthInformation().getOauthId(), user.isDeleted() diff --git a/backend/ddang/src/main/java/com/ddang/ddang/review/application/dto/ReadUserInReviewDto.java b/backend/ddang/src/main/java/com/ddang/ddang/review/application/dto/ReadUserInReviewDto.java index bb0fa0927..25c446c0f 100644 --- a/backend/ddang/src/main/java/com/ddang/ddang/review/application/dto/ReadUserInReviewDto.java +++ b/backend/ddang/src/main/java/com/ddang/ddang/review/application/dto/ReadUserInReviewDto.java @@ -1,14 +1,15 @@ package com.ddang.ddang.review.application.dto; +import com.ddang.ddang.image.application.util.ImageStoreNameProcessor; import com.ddang.ddang.user.domain.User; -public record ReadUserInReviewDto(Long id, String name, Long profileImageId, double reliability, String oauthId) { +public record ReadUserInReviewDto(Long id, String name, String profileImageStoreName, double reliability, String oauthId) { public static ReadUserInReviewDto from(final User user) { return new ReadUserInReviewDto( user.getId(), user.getName(), - user.getProfileImage().getId(), + ImageStoreNameProcessor.process(user.getProfileImage()), user.getReliability().getValue(), user.getOauthInformation().getOauthId() ); diff --git a/backend/ddang/src/main/java/com/ddang/ddang/review/presentation/dto/response/ReadUserInReviewResponse.java b/backend/ddang/src/main/java/com/ddang/ddang/review/presentation/dto/response/ReadUserInReviewResponse.java index 328ed847c..720a923d0 100644 --- a/backend/ddang/src/main/java/com/ddang/ddang/review/presentation/dto/response/ReadUserInReviewResponse.java +++ b/backend/ddang/src/main/java/com/ddang/ddang/review/presentation/dto/response/ReadUserInReviewResponse.java @@ -10,7 +10,7 @@ public static ReadUserInReviewResponse from(final ReadUserInReviewDto userDto) { return new ReadUserInReviewResponse( userDto.id(), userDto.name(), - ImageUrlCalculator.calculateBy(ImageRelativeUrl.USER, userDto.profileImageId()) + ImageUrlCalculator.calculateBy(ImageRelativeUrl.USER, userDto.profileImageStoreName()) ); } } diff --git a/backend/ddang/src/main/java/com/ddang/ddang/user/application/dto/ReadUserDto.java b/backend/ddang/src/main/java/com/ddang/ddang/user/application/dto/ReadUserDto.java index 015310258..282c580eb 100644 --- a/backend/ddang/src/main/java/com/ddang/ddang/user/application/dto/ReadUserDto.java +++ b/backend/ddang/src/main/java/com/ddang/ddang/user/application/dto/ReadUserDto.java @@ -1,12 +1,12 @@ package com.ddang.ddang.user.application.dto; -import com.ddang.ddang.image.application.util.ImageIdProcessor; +import com.ddang.ddang.image.application.util.ImageStoreNameProcessor; import com.ddang.ddang.user.domain.User; public record ReadUserDto( Long id, String name, - Long profileImageId, + String profileImageStoreName, double reliability, String oauthId, boolean isDeleted @@ -16,7 +16,7 @@ public static ReadUserDto from(final User user) { return new ReadUserDto( user.getId(), user.getName(), - ImageIdProcessor.process(user.getProfileImage()), + ImageStoreNameProcessor.process(user.getProfileImage()), user.getReliability().getValue(), user.getOauthInformation().getOauthId(), user.isDeleted() diff --git a/backend/ddang/src/main/java/com/ddang/ddang/user/presentation/dto/ReadUserResponse.java b/backend/ddang/src/main/java/com/ddang/ddang/user/presentation/dto/ReadUserResponse.java index ccc8563ff..54d10acb2 100644 --- a/backend/ddang/src/main/java/com/ddang/ddang/user/presentation/dto/ReadUserResponse.java +++ b/backend/ddang/src/main/java/com/ddang/ddang/user/presentation/dto/ReadUserResponse.java @@ -9,7 +9,7 @@ public record ReadUserResponse(String name, String profileImage, Float reliabili public static ReadUserResponse from(final ReadUserDto readUserDto) { final String name = NameProcessor.process(readUserDto.isDeleted(), readUserDto.name()); - final String profileImageUrl = ImageUrlCalculator.calculateBy(ImageRelativeUrl.USER, readUserDto.profileImageId()); + final String profileImageUrl = ImageUrlCalculator.calculateBy(ImageRelativeUrl.USER, readUserDto.profileImageStoreName()); final Float floatReliability = Float.valueOf(String.valueOf(readUserDto.reliability())); diff --git a/backend/ddang/src/main/java/com/ddang/ddang/user/presentation/dto/response/AuctionDetailResponse.java b/backend/ddang/src/main/java/com/ddang/ddang/user/presentation/dto/response/AuctionDetailResponse.java index d7fa2befd..8b8b0d1e8 100644 --- a/backend/ddang/src/main/java/com/ddang/ddang/user/presentation/dto/response/AuctionDetailResponse.java +++ b/backend/ddang/src/main/java/com/ddang/ddang/user/presentation/dto/response/AuctionDetailResponse.java @@ -56,9 +56,9 @@ public static AuctionDetailResponse from(final ReadAuctionDto dto) { } private static List convertImageFullUrls(final ReadAuctionDto dto) { - return dto.auctionImageIds() + return dto.auctionImageStoreNames() .stream() - .map(id -> ImageUrlCalculator.calculateBy(ImageRelativeUrl.AUCTION, id)) + .map(storeName -> ImageUrlCalculator.calculateBy(ImageRelativeUrl.AUCTION, storeName)) .toList(); } diff --git a/backend/ddang/src/main/java/com/ddang/ddang/user/presentation/dto/response/ReadAuctionDetailResponse.java b/backend/ddang/src/main/java/com/ddang/ddang/user/presentation/dto/response/ReadAuctionDetailResponse.java index 2a5e68862..e07054359 100644 --- a/backend/ddang/src/main/java/com/ddang/ddang/user/presentation/dto/response/ReadAuctionDetailResponse.java +++ b/backend/ddang/src/main/java/com/ddang/ddang/user/presentation/dto/response/ReadAuctionDetailResponse.java @@ -17,7 +17,7 @@ public static ReadAuctionDetailResponse of( final AuthenticationUserInfo userInfo ) { final AuctionDetailResponse auctionDetailResponse = AuctionDetailResponse.from(dto.auctionDto()); - final String profileImageUrl = ImageUrlCalculator.calculateBy(ImageRelativeUrl.USER, dto.auctionDto().sellerId()); + final String profileImageUrl = ImageUrlCalculator.calculateBy(ImageRelativeUrl.USER, dto.auctionDto().sellerProfileImageStoreName()); final Float floatReliability = Float.valueOf(String.valueOf(dto.auctionDto().sellerReliability())); diff --git a/backend/ddang/src/main/java/com/ddang/ddang/user/presentation/dto/response/ReadAuctionResponse.java b/backend/ddang/src/main/java/com/ddang/ddang/user/presentation/dto/response/ReadAuctionResponse.java index 4db39f7f5..0cca8926d 100644 --- a/backend/ddang/src/main/java/com/ddang/ddang/user/presentation/dto/response/ReadAuctionResponse.java +++ b/backend/ddang/src/main/java/com/ddang/ddang/user/presentation/dto/response/ReadAuctionResponse.java @@ -25,9 +25,9 @@ public static ReadAuctionResponse from(final ReadAuctionDto dto) { } private static String calculateThumbnailImageUrl(final ReadAuctionDto dto) { - final Long thumbnailAuctionImage = dto.auctionImageIds().get(0); + final String thumbnailAuctionImageStoreName = dto.auctionImageStoreNames().get(0); - return ImageUrlCalculator.calculateBy(ImageRelativeUrl.AUCTION, thumbnailAuctionImage); + return ImageUrlCalculator.calculateBy(ImageRelativeUrl.AUCTION, thumbnailAuctionImageStoreName); } private static int processAuctionPrice(final Integer startPrice, final Integer lastBidPrice) { diff --git a/backend/ddang/src/main/java/com/ddang/ddang/user/presentation/dto/response/ReadUserResponse.java b/backend/ddang/src/main/java/com/ddang/ddang/user/presentation/dto/response/ReadUserResponse.java index 0c83b2e5a..1a14fbe74 100644 --- a/backend/ddang/src/main/java/com/ddang/ddang/user/presentation/dto/response/ReadUserResponse.java +++ b/backend/ddang/src/main/java/com/ddang/ddang/user/presentation/dto/response/ReadUserResponse.java @@ -12,7 +12,7 @@ public static ReadUserResponse from(final ReadUserDto readUserDto) { return new ReadUserResponse( NameProcessor.process(readUserDto.isDeleted(), readUserDto.name()), - ImageUrlCalculator.calculateBy(ImageRelativeUrl.USER, readUserDto.profileImageId()), + ImageUrlCalculator.calculateBy(ImageRelativeUrl.USER, readUserDto.profileImageStoreName()), floatReliability ); } diff --git a/backend/ddang/src/test/java/com/ddang/ddang/auction/presentation/fixture/AuctionControllerFixture.java b/backend/ddang/src/test/java/com/ddang/ddang/auction/presentation/fixture/AuctionControllerFixture.java index b92c77e17..d5951dfc4 100644 --- a/backend/ddang/src/test/java/com/ddang/ddang/auction/presentation/fixture/AuctionControllerFixture.java +++ b/backend/ddang/src/test/java/com/ddang/ddang/auction/presentation/fixture/AuctionControllerFixture.java @@ -11,12 +11,13 @@ import com.ddang.ddang.authentication.infrastructure.jwt.PrivateClaims; import com.ddang.ddang.configuration.CommonControllerSliceTest; import com.fasterxml.jackson.core.JsonProcessingException; -import java.time.LocalDateTime; -import java.util.List; import org.junit.jupiter.api.BeforeEach; import org.springframework.http.MediaType; import org.springframework.mock.web.MockMultipartFile; +import java.time.LocalDateTime; +import java.util.List; + @SuppressWarnings("NonAsciiCharacters") public class AuctionControllerFixture extends CommonControllerSliceTest { @@ -39,7 +40,7 @@ public class AuctionControllerFixture extends CommonControllerSliceTest { protected CreateInfoAuctionDto 경매_등록_결과_dto = new CreateInfoAuctionDto( 1L, "제목", - 1L, + "auction_image.png", 1_000 ); protected ReadChatRoomDto 쪽지방_dto = new ReadChatRoomDto(1L, true); @@ -148,12 +149,12 @@ void fixtureSetUp() throws JsonProcessingException { LocalDateTime.now(), LocalDateTime.now(), List.of(서울특별시_강서구_역삼동), - List.of(1L), + List.of("auction_image.png"), 2, "main", "sub", 1L, - 1L, + "profile_image.png", "판매자", 3.5d, false, @@ -172,12 +173,12 @@ void fixtureSetUp() throws JsonProcessingException { LocalDateTime.now(), LocalDateTime.now(), List.of(서울특별시_강서구_역삼동), - List.of(1L), + List.of("auction_image.png"), 2, "main", "sub", 1L, - 1L, + "profile_image.png", "판매자", 3.5d, false, @@ -196,12 +197,12 @@ void fixtureSetUp() throws JsonProcessingException { LocalDateTime.now(), LocalDateTime.now(), List.of(서울특별시_강서구_역삼동), - List.of(1L), + List.of("auction_image.png"), 2, "main", "sub", 1L, - 1L, + "profile_image.png", "판매자", 3.5d, false, diff --git a/backend/ddang/src/test/java/com/ddang/ddang/auction/presentation/fixture/AuctionQuestionControllerFixture.java b/backend/ddang/src/test/java/com/ddang/ddang/auction/presentation/fixture/AuctionQuestionControllerFixture.java index 588ae7036..538d8f08c 100644 --- a/backend/ddang/src/test/java/com/ddang/ddang/auction/presentation/fixture/AuctionQuestionControllerFixture.java +++ b/backend/ddang/src/test/java/com/ddang/ddang/auction/presentation/fixture/AuctionQuestionControllerFixture.java @@ -21,7 +21,7 @@ public class AuctionQuestionControllerFixture extends CommonControllerSliceTest protected ReadUserInQnaDto 질문자_정보_dto = new ReadUserInQnaDto( 1L, "질문자", - 1L, + "profile_image1.png", 4.5d, "12345", false @@ -29,7 +29,7 @@ public class AuctionQuestionControllerFixture extends CommonControllerSliceTest protected ReadUserInQnaDto 판매자_정보_dto = new ReadUserInQnaDto( 2L, "판매자", - 2L, + "profile_image2.png", 4.5d, "12346", false diff --git a/backend/ddang/src/test/java/com/ddang/ddang/auction/presentation/fixture/AuctionReviewControllerFixture.java b/backend/ddang/src/test/java/com/ddang/ddang/auction/presentation/fixture/AuctionReviewControllerFixture.java index b0fbbf4f8..142df2be0 100644 --- a/backend/ddang/src/test/java/com/ddang/ddang/auction/presentation/fixture/AuctionReviewControllerFixture.java +++ b/backend/ddang/src/test/java/com/ddang/ddang/auction/presentation/fixture/AuctionReviewControllerFixture.java @@ -15,8 +15,8 @@ public class AuctionReviewControllerFixture extends CommonControllerSliceTest { protected String 액세스_토큰 = "Bearer accessToken"; protected PrivateClaims 유효한_작성자_비공개_클레임 = new PrivateClaims(유효한_평가_작성자_아이디); protected Long 유효한_경매_아이디 = 1L; - protected Long 판매자_프로필_이미지_아이디 = 1L; - protected ReadUserInReviewDto 판매자 = new ReadUserInReviewDto(1L, "판매자", 판매자_프로필_이미지_아이디, 5.0d, "12347"); + protected String 판매자_프로필_이미지_저장_이름 = "profile_image.png"; + protected ReadUserInReviewDto 판매자 = new ReadUserInReviewDto(1L, "판매자", 판매자_프로필_이미지_저장_이름, 5.0d, "12347"); protected Long 구매자가_판매자에게_받은_평가_아이디 = 1L; protected ReadReviewDto 구매자가_판매자1에게_받은_평가 = new ReadReviewDto(구매자가_판매자에게_받은_평가_아이디, 판매자, "친절하다.", 5.0d, LocalDateTime.now()); diff --git a/backend/ddang/src/test/java/com/ddang/ddang/bid/presentation/fixture/BidControllerFixture.java b/backend/ddang/src/test/java/com/ddang/ddang/bid/presentation/fixture/BidControllerFixture.java index ad7939d84..d6b4ae39c 100644 --- a/backend/ddang/src/test/java/com/ddang/ddang/bid/presentation/fixture/BidControllerFixture.java +++ b/backend/ddang/src/test/java/com/ddang/ddang/bid/presentation/fixture/BidControllerFixture.java @@ -26,6 +26,6 @@ public class BidControllerFixture extends CommonControllerSliceTest { protected static CreateBidRequest 입찰액이_양수가_아닌_입찰_request1 = new CreateBidRequest(1L, -1); protected static CreateBidRequest 입찰액이_양수가_아닌_입찰_request2 = new CreateBidRequest(1L, 0); - protected ReadBidDto 입찰_정보_dto1 = new ReadBidDto("사용자1", 1L, false, 10_000, LocalDateTime.now()); - protected ReadBidDto 입찰_정보_dto2 = new ReadBidDto("사용자2", 2L, false, 12_000, LocalDateTime.now()); + protected ReadBidDto 입찰_정보_dto1 = new ReadBidDto("사용자1", "profile_image1.png", false, 10_000, LocalDateTime.now()); + protected ReadBidDto 입찰_정보_dto2 = new ReadBidDto("사용자2", "profile_image2.png", false, 12_000, LocalDateTime.now()); } diff --git a/backend/ddang/src/test/java/com/ddang/ddang/chat/presentation/fixture/ChatRoomControllerFixture.java b/backend/ddang/src/test/java/com/ddang/ddang/chat/presentation/fixture/ChatRoomControllerFixture.java index 8f7b5ddaa..7d8b7d540 100644 --- a/backend/ddang/src/test/java/com/ddang/ddang/chat/presentation/fixture/ChatRoomControllerFixture.java +++ b/backend/ddang/src/test/java/com/ddang/ddang/chat/presentation/fixture/ChatRoomControllerFixture.java @@ -18,11 +18,11 @@ public class ChatRoomControllerFixture extends CommonControllerSliceTest { private Long 탈퇴한_사용자_아이디 = 5L; protected PrivateClaims 사용자_ID_클레임 = new PrivateClaims(1L); - protected ReadUserInChatRoomDto 판매자 = new ReadUserInChatRoomDto(1L, "판매자", 1L, 5.0d, false); - private ReadUserInChatRoomDto 구매자1 = new ReadUserInChatRoomDto(2L, "구매자1", 2L, 5.0d, false); - private ReadUserInChatRoomDto 구매자2 = new ReadUserInChatRoomDto(3L, "구매자2", 3L, 5.0d, false); - private ReadAuctionInChatRoomDto 조회용_경매1 = new ReadAuctionInChatRoomDto(1L, "경매1", 10_000, 1L); - private ReadAuctionInChatRoomDto 조회용_경매2 = new ReadAuctionInChatRoomDto(2L, "경매2", 20_000, 1L); + protected ReadUserInChatRoomDto 판매자 = new ReadUserInChatRoomDto(1L, "판매자", "profile_image.png", 5.0d, false); + private ReadUserInChatRoomDto 구매자1 = new ReadUserInChatRoomDto(2L, "구매자1", "profile_image.png", 5.0d, false); + private ReadUserInChatRoomDto 구매자2 = new ReadUserInChatRoomDto(3L, "구매자2", "profile_image.png", 5.0d, false); + private ReadAuctionInChatRoomDto 조회용_경매1 = new ReadAuctionInChatRoomDto(1L, "경매1", 10_000, "auction_image.png"); + private ReadAuctionInChatRoomDto 조회용_경매2 = new ReadAuctionInChatRoomDto(2L, "경매2", 20_000, "auction_image.png"); protected ReadChatRoomWithLastMessageDto 조회용_채팅방1 = new ReadChatRoomWithLastMessageDto(1L, 조회용_경매1, 구매자1, new ReadLastMessageDto(1L, LocalDateTime.now(), 판매자, 구매자1, "메시지1"), true); protected ReadChatRoomWithLastMessageDto 조회용_채팅방2 = new ReadChatRoomWithLastMessageDto(2L, 조회용_경매2, 구매자2, new ReadLastMessageDto(1L, LocalDateTime.now(), 판매자, 구매자2, "메시지2"), true); protected CreateMessageRequest 메시지_생성_요청 = new CreateMessageRequest(1L, "메시지 내용"); diff --git a/backend/ddang/src/test/java/com/ddang/ddang/image/application/util/ImageIdProcessorTest.java b/backend/ddang/src/test/java/com/ddang/ddang/image/application/util/ImageStoreNameProcessorTest.java similarity index 61% rename from backend/ddang/src/test/java/com/ddang/ddang/image/application/util/ImageIdProcessorTest.java rename to backend/ddang/src/test/java/com/ddang/ddang/image/application/util/ImageStoreNameProcessorTest.java index a016206cd..271199c23 100644 --- a/backend/ddang/src/test/java/com/ddang/ddang/image/application/util/ImageIdProcessorTest.java +++ b/backend/ddang/src/test/java/com/ddang/ddang/image/application/util/ImageStoreNameProcessorTest.java @@ -10,24 +10,24 @@ @DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class) @SuppressWarnings("NonAsciiCharacters") -class ImageIdProcessorTest extends ImageIdProcessorFixture { +class ImageStoreNameProcessorTest extends ImageIdProcessorFixture { @Test void 경매_이미지가_null이_아니라면_경매_이미지_아이디를_반환한다() { // given - given(경매_이미지.getId()).willReturn(경매_이미지_아이디); + given(경매_이미지.getImage()).willReturn(경매_이미지_데이터_VO); // when - final Long actual = ImageIdProcessor.process(경매_이미지); + final String actual = ImageStoreNameProcessor.process(경매_이미지); // then - assertThat(actual).isEqualTo(경매_이미지_아이디); + assertThat(actual).isEqualTo(경매_이미지_저장_이름); } @Test void 경매_이미지가_null이면_경매_이미지_아이디를_null로_반환한다() { // when - final Long actual = ImageIdProcessor.process(null인_경매_이미지); + final String actual = ImageStoreNameProcessor.process(null인_경매_이미지); // then assertThat(actual).isNull(); @@ -36,19 +36,19 @@ class ImageIdProcessorTest extends ImageIdProcessorFixture { @Test void 프로필_이미지가_null이_아니라면_프로필_이미지_아이디를_반환한다() { // given - given(프로필_이미지.getId()).willReturn(프로필_이미지_아이디); + given(프로필_이미지.getImage()).willReturn(프로필_이미지_데이터_VO); // when - final Long actual = ImageIdProcessor.process(프로필_이미지); + final String actual = ImageStoreNameProcessor.process(프로필_이미지); // then - assertThat(actual).isEqualTo(프로필_이미지_아이디); + assertThat(actual).isEqualTo(프로필_이미지_저장_이름); } @Test void 프로필_이미지가_null이면_프로필_이미지_아이디를_null로_반환한다() { // when - final Long actual = ImageIdProcessor.process(null인_프로필_이미지); + final String actual = ImageStoreNameProcessor.process(null인_프로필_이미지); // then assertThat(actual).isNull(); diff --git a/backend/ddang/src/test/java/com/ddang/ddang/image/application/util/fixture/ImageIdProcessorFixture.java b/backend/ddang/src/test/java/com/ddang/ddang/image/application/util/fixture/ImageIdProcessorFixture.java index 3fa95dbd4..2da10ada3 100644 --- a/backend/ddang/src/test/java/com/ddang/ddang/image/application/util/fixture/ImageIdProcessorFixture.java +++ b/backend/ddang/src/test/java/com/ddang/ddang/image/application/util/fixture/ImageIdProcessorFixture.java @@ -1,6 +1,7 @@ package com.ddang.ddang.image.application.util.fixture; import com.ddang.ddang.image.domain.AuctionImage; +import com.ddang.ddang.image.domain.Image; import com.ddang.ddang.image.domain.ProfileImage; import static org.mockito.Mockito.mock; @@ -10,9 +11,10 @@ public class ImageIdProcessorFixture { protected AuctionImage 경매_이미지 = mock(AuctionImage.class); protected AuctionImage null인_경매_이미지 = null; - protected Long 경매_이미지_아이디 = 1L; - protected ProfileImage 프로필_이미지 = mock(ProfileImage.class); protected ProfileImage null인_프로필_이미지 = null; - protected Long 프로필_이미지_아이디 = 1L; + protected String 경매_이미지_저장_이름 = "auction_image.png"; + protected String 프로필_이미지_저장_이름 = "profile_image.png"; + protected Image 프로필_이미지_데이터_VO = new Image("upload.png", 프로필_이미지_저장_이름); + protected Image 경매_이미지_데이터_VO = new Image("upload.png", 경매_이미지_저장_이름); } diff --git a/backend/ddang/src/test/java/com/ddang/ddang/image/presentation/util/ImageUrlCalculatorTest.java b/backend/ddang/src/test/java/com/ddang/ddang/image/presentation/util/ImageUrlCalculatorTest.java index 491761182..6757db17e 100644 --- a/backend/ddang/src/test/java/com/ddang/ddang/image/presentation/util/ImageUrlCalculatorTest.java +++ b/backend/ddang/src/test/java/com/ddang/ddang/image/presentation/util/ImageUrlCalculatorTest.java @@ -16,28 +16,28 @@ class ImageUrlCalculatorTest extends ImageUrlCalculatorFixture { @Test void 프로필_사진의_상대_URL로_절대_경로를_계산한다() { // when - final String actual = ImageUrlCalculator.calculateBy(프로필_이미지_상대_URL, 프로필_이미지_아이디); + final String actual = ImageUrlCalculator.calculateBy(프로필_이미지_상대_URL, 프로필_이미지_저장_이름); // then - assertThat(actual).contains(프로필_이미지_전체_URL); + assertThat(actual).contains(프로필_이미지_저장_이름_기반_전체_URL); } @Test void 프로필_사진의_아이디가_null인_경우_기본_이미지의_상대_URL로_절대_경로를_계산한다() { // when - final String actual = ImageUrlCalculator.calculateBy(프로필_이미지_상대_URL, 프로필_이미지_아이디가_null); + final String actual = ImageUrlCalculator.calculateBy(프로필_이미지_상대_URL, 프로필_이미지_저장_이름이_null); // then - assertThat(actual).contains(프로필_기본_이미지_전체_URL); + assertThat(actual).contains(이미지_저장_이름_기반_프로필_기본_이미지_전체_URL); } @Test void 경매_대표_이미지의_상대_URL로_절대_경로를_계산한다() { // when - final String actual = ImageUrlCalculator.calculateBy(경매_이미지_상대_URL, 경매_이미지_아이디); + final String actual = ImageUrlCalculator.calculateBy(경매_이미지_상대_URL, 경매_이미지_저장_이름); // then - assertThat(actual).contains(경매_이미지_전체_URL); + assertThat(actual).contains(경매_이미지_저장_이름_기반_전체_URL); } @Test diff --git a/backend/ddang/src/test/java/com/ddang/ddang/image/presentation/util/fixture/ImageUrlCalculatorFixture.java b/backend/ddang/src/test/java/com/ddang/ddang/image/presentation/util/fixture/ImageUrlCalculatorFixture.java index abdeaf933..6904060a2 100644 --- a/backend/ddang/src/test/java/com/ddang/ddang/image/presentation/util/fixture/ImageUrlCalculatorFixture.java +++ b/backend/ddang/src/test/java/com/ddang/ddang/image/presentation/util/fixture/ImageUrlCalculatorFixture.java @@ -12,8 +12,15 @@ public class ImageUrlCalculatorFixture { protected Long 프로필_이미지_아이디 = 2L; protected Long 프로필_이미지_아이디가_null = null; protected String 프로필_이미지_전체_URL = 프로필_이미지_절대_URL + 프로필_이미지_아이디; - protected String 프로필_기본_이미지_전체_URL = 프로필_이미지_절대_URL + "1"; + protected String 프로필_기본_이미지_전체_URL = 프로필_이미지_절대_URL + "default_profile_image.png"; + protected String 프로필_이미지_저장_이름 = "profile_image_store_name.png"; + protected String 프로필_이미지_저장_이름이_null = null; + protected String 프로필_이미지_저장_이름_기반_전체_URL = 프로필_이미지_절대_URL + 프로필_이미지_저장_이름; + protected String 이미지_저장_이름_기반_프로필_기본_이미지_전체_URL = 프로필_이미지_절대_URL + "default_profile_image.png"; protected String 경매_이미지_절대_URL = "/auctions/images/"; protected Long 경매_이미지_아이디 = 1L; protected String 경매_이미지_전체_URL = 경매_이미지_절대_URL + 경매_이미지_아이디; + + protected String 경매_이미지_저장_이름 = "auction_image_store_name.png"; + protected String 경매_이미지_저장_이름_기반_전체_URL = 경매_이미지_절대_URL + 경매_이미지_저장_이름; } diff --git a/backend/ddang/src/test/java/com/ddang/ddang/report/presentation/fixture/ReportControllerFixture.java b/backend/ddang/src/test/java/com/ddang/ddang/report/presentation/fixture/ReportControllerFixture.java index ae67ccf80..c69f9dbf8 100644 --- a/backend/ddang/src/test/java/com/ddang/ddang/report/presentation/fixture/ReportControllerFixture.java +++ b/backend/ddang/src/test/java/com/ddang/ddang/report/presentation/fixture/ReportControllerFixture.java @@ -35,7 +35,7 @@ public class ReportControllerFixture extends CommonControllerSliceTest { protected CreateAuctionReportRequest 경매_아이디가_음수인_신고_request = new CreateAuctionReportRequest(-999L, "신고합니다"); protected static CreateAuctionReportRequest 신고_내용이_null인_경매_신고_request = new CreateAuctionReportRequest(1L, null); protected static CreateAuctionReportRequest 신고_내용이_빈값인_경매_신고_request = new CreateAuctionReportRequest(1L, ""); - private ReadUserInReportDto 판매자_정보_dto = new ReadUserInReportDto(1L, "판매자", 1L, 4.0d, "12345", false); + private ReadUserInReportDto 판매자_정보_dto = new ReadUserInReportDto(1L, "판매자", "profile_image.png", 4.0d, "12345", false); private ReadAuctionInReportDto 신고할_경매_정보_dto = new ReadAuctionInReportDto( 1L, 판매자_정보_dto, @@ -49,21 +49,21 @@ public class ReportControllerFixture extends CommonControllerSliceTest { ); protected ReadAuctionReportDto 경매_신고_dto1 = new ReadAuctionReportDto( 1L, - new ReadReporterDto(2L, "회원1", 2L, 5.0, false), + new ReadReporterDto(2L, "회원1", "profile_image.png", 5.0, false), LocalDateTime.now(), 신고할_경매_정보_dto, "신고합니다." ); protected ReadAuctionReportDto 경매_신고_dto2 = new ReadAuctionReportDto( 2L, - new ReadReporterDto(3L, "회원2", 3L, 5.0, false), + new ReadReporterDto(3L, "회원2", "profile_image.png", 5.0, false), LocalDateTime.now(), 신고할_경매_정보_dto, "신고합니다." ); protected ReadAuctionReportDto 경매_신고_dto3 = new ReadAuctionReportDto( 3L, - new ReadReporterDto(4L, "회원3", 4L, 5.0, false), + new ReadReporterDto(4L, "회원3", "profile_image.png", 5.0, false), LocalDateTime.now(), 신고할_경매_정보_dto, "신고합니다." @@ -86,8 +86,8 @@ public class ReportControllerFixture extends CommonControllerSliceTest { LocalDateTime.now().plusDays(2), 2 ); - private ReadUserInReportDto 구매자_정보_dto1 = new ReadUserInReportDto(2L, "구매자1", 2L, 4.0d, "12346", false); - private ReadReporterDto 신고자_정보_dto1 = new ReadReporterDto(2L, "구매자1", 2L, 4.0d, false); + private ReadUserInReportDto 구매자_정보_dto1 = new ReadUserInReportDto(2L, "구매자1", "profile_image.png", 4.0d, "12346", false); + private ReadReporterDto 신고자_정보_dto1 = new ReadReporterDto(2L, "구매자1", "profile_image.png", 4.0d, false); protected ReadChatRoomReportDto 채팅방_신고_dto1 = new ReadChatRoomReportDto( 1L, 신고자_정보_dto1, @@ -106,8 +106,8 @@ public class ReportControllerFixture extends CommonControllerSliceTest { LocalDateTime.now().plusDays(2), 2 ); - private ReadUserInReportDto 구매자_정보_dto2 = new ReadUserInReportDto(3L, "구매자2", 3L, 4.0d, "12347", false); - private ReadReporterDto 신고자_정보_dto2 = new ReadReporterDto(3L, "구매자2", 3L, 4.0d, false); + private ReadUserInReportDto 구매자_정보_dto2 = new ReadUserInReportDto(3L, "구매자2", "profile_image.png", 4.0d, "12347", false); + private ReadReporterDto 신고자_정보_dto2 = new ReadReporterDto(3L, "구매자2", "profile_image.png", 4.0d, false); protected ReadChatRoomReportDto 채팅방_신고_dto2 = new ReadChatRoomReportDto( 2L, 신고자_정보_dto2, @@ -126,8 +126,8 @@ public class ReportControllerFixture extends CommonControllerSliceTest { LocalDateTime.now().plusDays(2), 2 ); - private ReadUserInReportDto 구매자_정보_dto3 = new ReadUserInReportDto(3L, "구매자2", 3L, 4.0d, "12347", false); - private ReadReporterDto 신고자_정보_dto3 = new ReadReporterDto(3L, "구매자2", 3L, 4.0d, false); + private ReadUserInReportDto 구매자_정보_dto3 = new ReadUserInReportDto(3L, "구매자2", "profile_image.png", 4.0d, "12347", false); + private ReadReporterDto 신고자_정보_dto3 = new ReadReporterDto(3L, "구매자2", "profile_image.png", 4.0d, false); protected ReadChatRoomReportDto 채팅방_신고_dto3 = new ReadChatRoomReportDto( 3L, 신고자_정보_dto3, @@ -147,7 +147,7 @@ public class ReportControllerFixture extends CommonControllerSliceTest { protected static CreateQuestionReportRequest 신고_내용이_null인_질문_신고_request = new CreateQuestionReportRequest(1L, 1L, null); protected static CreateQuestionReportRequest 신고_내용이_빈값인_질문_신고_request = new CreateQuestionReportRequest(1L, 1L, ""); - private ReadUserInReportDto 질문자_dto = new ReadUserInReportDto(1L, "사용자", 1L, 5.0d, "12345", false); + private ReadUserInReportDto 질문자_dto = new ReadUserInReportDto(1L, "사용자", "profile_image.png", 5.0d, "12345", false); private ReadQuestionInReportDto 질문_dto1 = new ReadQuestionInReportDto(1L, 질문자_dto, "질문드립니다.", LocalDateTime.now()); private ReadQuestionInReportDto 질문_dto2 = new ReadQuestionInReportDto(2L, 질문자_dto, "질문드립니다.", LocalDateTime.now()); private ReadQuestionInReportDto 질문_dto3 = new ReadQuestionInReportDto(3L, 질문자_dto, "질문드립니다.", LocalDateTime.now()); @@ -165,12 +165,11 @@ public class ReportControllerFixture extends CommonControllerSliceTest { protected CreateAnswerReportRequest 답변_아이디가_음수인_질문_신고_request = new CreateAnswerReportRequest(1L, -1L, "신고합니다."); protected static CreateAnswerReportRequest 신고_내용이_null인_답변_신고_request = new CreateAnswerReportRequest(1L, 1L, null); protected static CreateAnswerReportRequest 신고_내용이_빈값인_답변_신고_request = new CreateAnswerReportRequest(1L, 1L, ""); - private ReadUserInReportDto 답변자_dto = new ReadUserInReportDto(1L, "사용자", 1L, 5.0d, "12345", false); + private ReadUserInReportDto 답변자_dto = new ReadUserInReportDto(1L, "사용자", "profile_image.png", 5.0d, "12345", false); private ReadAnswerInReportDto 답변_dto1 = new ReadAnswerInReportDto(1L, 답변자_dto, "답변드립니다.", LocalDateTime.now()); private ReadAnswerInReportDto 답변_dto2 = new ReadAnswerInReportDto(2L, 답변자_dto, "답변드립니다.", LocalDateTime.now()); private ReadAnswerInReportDto 답변_dto3 = new ReadAnswerInReportDto(3L, 답변자_dto, "답변드립니다.", LocalDateTime.now()); protected ReadAnswerReportDto 답변_신고_dto1 = new ReadAnswerReportDto(1L, 신고자_정보_dto1, LocalDateTime.now(), 답변_dto1, "신고합니다."); protected ReadAnswerReportDto 답변_신고_dto2 = new ReadAnswerReportDto(2L, 신고자_정보_dto1, LocalDateTime.now(), 답변_dto2, "신고합니다."); protected ReadAnswerReportDto 답변_신고_dto3 = new ReadAnswerReportDto(3L, 신고자_정보_dto1, LocalDateTime.now(), 답변_dto3, "신고합니다."); - } diff --git a/backend/ddang/src/test/java/com/ddang/ddang/review/presentation/fixture/ReviewControllerFixture.java b/backend/ddang/src/test/java/com/ddang/ddang/review/presentation/fixture/ReviewControllerFixture.java index d34dce198..89427b623 100644 --- a/backend/ddang/src/test/java/com/ddang/ddang/review/presentation/fixture/ReviewControllerFixture.java +++ b/backend/ddang/src/test/java/com/ddang/ddang/review/presentation/fixture/ReviewControllerFixture.java @@ -16,12 +16,12 @@ public class ReviewControllerFixture extends CommonControllerSliceTest { private Long 유효한_평가_대상_아이디 = 2L; private Long 유효한_경매_아이디 = 1L; private Long 사용자가_이미_평가한_경매_아이디 = 2L; - private Long 판매자1_프로필_이미지_아이디 = 1L; - private Long 판매자2_프로필_이미지_아이디 = 2L; - private Long 구매자_프로필_이미지_아이디 = 3L; - private ReadUserInReviewDto 판매자1 = new ReadUserInReviewDto(1L, "판매자1", 판매자1_프로필_이미지_아이디, 5.0d, "12347"); - private ReadUserInReviewDto 판매자2 = new ReadUserInReviewDto(2L, "판매자2", 판매자2_프로필_이미지_아이디, 5.0d, "12348"); - protected ReadUserInReviewDto 구매자 = new ReadUserInReviewDto(3L, "구매자", 구매자_프로필_이미지_아이디, 5.0d, "12349"); + private String 판매자1_프로필_이미지_저장_이름 = "profile_image1.png"; + private String 판매자2_프로필_이미지_저장_이름 = "profile_image2.png"; + private String 구매자_프로필_이미지_저장_이름 = "profile_image3.png"; + private ReadUserInReviewDto 판매자1 = new ReadUserInReviewDto(1L, "판매자1", 판매자1_프로필_이미지_저장_이름, 5.0d, "12347"); + private ReadUserInReviewDto 판매자2 = new ReadUserInReviewDto(2L, "판매자2", 판매자2_프로필_이미지_저장_이름, 5.0d, "12348"); + protected ReadUserInReviewDto 구매자 = new ReadUserInReviewDto(3L, "구매자", 구매자_프로필_이미지_저장_이름, 5.0d, "12349"); protected String 액세스_토큰 = "Bearer accessToken"; protected PrivateClaims 유효한_작성자_비공개_클레임 = new PrivateClaims(유효한_평가_작성자_아이디); protected CreateReviewRequest 사용자_평가_등록_요청 = diff --git a/backend/ddang/src/test/java/com/ddang/ddang/user/application/UserServiceTest.java b/backend/ddang/src/test/java/com/ddang/ddang/user/application/UserServiceTest.java index c68ffc576..11db5551e 100644 --- a/backend/ddang/src/test/java/com/ddang/ddang/user/application/UserServiceTest.java +++ b/backend/ddang/src/test/java/com/ddang/ddang/user/application/UserServiceTest.java @@ -36,7 +36,7 @@ class UserServiceTest extends UserServiceFixture { // then SoftAssertions.assertSoftly(softAssertions -> { softAssertions.assertThat(actual.name()).isEqualTo(사용자.getName()); - softAssertions.assertThat(actual.profileImageId()).isEqualTo(사용자.getProfileImage().getId()); + softAssertions.assertThat(actual.profileImageStoreName()).isEqualTo(사용자.getProfileImage().getImage().getStoreName()); softAssertions.assertThat(actual.reliability()).isEqualTo(사용자.getReliability().getValue()); }); } diff --git a/backend/ddang/src/test/java/com/ddang/ddang/user/presentation/fixture/UserAuctionControllerFixture.java b/backend/ddang/src/test/java/com/ddang/ddang/user/presentation/fixture/UserAuctionControllerFixture.java index eb2731dc4..75f1ceef6 100644 --- a/backend/ddang/src/test/java/com/ddang/ddang/user/presentation/fixture/UserAuctionControllerFixture.java +++ b/backend/ddang/src/test/java/com/ddang/ddang/user/presentation/fixture/UserAuctionControllerFixture.java @@ -35,12 +35,12 @@ public class UserAuctionControllerFixture extends CommonControllerSliceTest { LocalDateTime.now(), LocalDateTime.now(), List.of(직거래_지역_정보_dto), - List.of(1L), + List.of("auction_image.png"), 2, "main1", "sub1", 1L, - 1L, + "profile_image.png", "판매자", 3.5d, false, @@ -58,12 +58,12 @@ public class UserAuctionControllerFixture extends CommonControllerSliceTest { LocalDateTime.now(), LocalDateTime.now(), List.of(직거래_지역_정보_dto), - List.of(1L), + List.of("auction_image.png"), 2, "main2", "sub2", 1L, - 1L, + "profile_image.png", "판매자", 3.5d, false, diff --git a/backend/ddang/src/test/java/com/ddang/ddang/user/presentation/fixture/UserControllerFixture.java b/backend/ddang/src/test/java/com/ddang/ddang/user/presentation/fixture/UserControllerFixture.java index fa46afbd5..0976a80e1 100644 --- a/backend/ddang/src/test/java/com/ddang/ddang/user/presentation/fixture/UserControllerFixture.java +++ b/backend/ddang/src/test/java/com/ddang/ddang/user/presentation/fixture/UserControllerFixture.java @@ -17,10 +17,10 @@ public class UserControllerFixture extends CommonControllerSliceTest { protected PrivateClaims 존재하지_않는_사용자_ID_클레임 = new PrivateClaims(999L); protected String 탈퇴한_사용자_이름 = "알 수 없음"; - protected ReadUserDto 사용자_정보_조회_dto = new ReadUserDto(1L, "사용자1", 1L, 4.6d, "12345", false); - protected ReadUserDto 탈퇴한_사용자_정보_조회_dto = new ReadUserDto(1L, "사용자1", 1L, 4.6d, "12345", true); + protected ReadUserDto 사용자_정보_조회_dto = new ReadUserDto(1L, "사용자1", "profile_image.png", 4.6d, "12345", false); + protected ReadUserDto 탈퇴한_사용자_정보_조회_dto = new ReadUserDto(1L, "사용자1", "profile_image.png", 4.6d, "12345", true); protected UpdateUserRequest 수정할_이름_request = new UpdateUserRequest("updateName"); - protected ReadUserDto 수정후_사용자_정보_조회_dto = new ReadUserDto(1L, 수정할_이름_request.name(), 1L, 4.6d, "12345", false); + protected ReadUserDto 수정후_사용자_정보_조회_dto = new ReadUserDto(1L, 수정할_이름_request.name(), "profile_image.png", 4.6d, "12345", false); private String json = "{\"name\":\"" + 수정할_이름_request.name() + "\"}"; private byte[] jsonBytes = json.getBytes(StandardCharsets.UTF_8); protected MockMultipartFile 수정할_이름 = new MockMultipartFile( From 0c7b6486aec89ef7d6adeeb9bbf75c733987619d Mon Sep 17 00:00:00 2001 From: kwonyj1022 Date: Thu, 19 Oct 2023 00:47:48 +0900 Subject: [PATCH 02/15] =?UTF-8?q?refactor:=20=EC=9D=B4=EB=AF=B8=EC=A7=80?= =?UTF-8?q?=20=EC=A0=88=EB=8C=80=20url=20=EA=B8=B0=EB=B0=98=EC=9C=BC?= =?UTF-8?q?=EB=A1=9C=20url=EC=9D=84=20=EA=B3=84=EC=82=B0=ED=95=98=EB=8A=94?= =?UTF-8?q?=20=EB=A9=94=EC=84=9C=EB=93=9C=20=ED=8C=8C=EB=9D=BC=EB=AF=B8?= =?UTF-8?q?=ED=84=B0=EB=A1=9C=20=EC=9D=B4=EB=AF=B8=EC=A7=80=20id=20?= =?UTF-8?q?=EB=8C=80=EC=8B=A0=20=EC=9D=B4=EB=AF=B8=EC=A7=80=20=EC=9D=B4?= =?UTF-8?q?=EB=A6=84=EC=9D=84=20=EB=B0=9B=EB=8F=84=EB=A1=9D=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../image/presentation/util/ImageUrlCalculator.java | 6 +++--- .../application/NotificationEventListener.java | 9 +++++---- .../presentation/util/ImageUrlCalculatorTest.java | 10 +++++----- .../util/fixture/ImageUrlCalculatorFixture.java | 6 ------ 4 files changed, 13 insertions(+), 18 deletions(-) diff --git a/backend/ddang/src/main/java/com/ddang/ddang/image/presentation/util/ImageUrlCalculator.java b/backend/ddang/src/main/java/com/ddang/ddang/image/presentation/util/ImageUrlCalculator.java index 29860b0df..bc1019357 100644 --- a/backend/ddang/src/main/java/com/ddang/ddang/image/presentation/util/ImageUrlCalculator.java +++ b/backend/ddang/src/main/java/com/ddang/ddang/image/presentation/util/ImageUrlCalculator.java @@ -17,11 +17,11 @@ public static String calculateBy(final ImageRelativeUrl imageRelativeUrl, final return absoluteUrl + storeName; } - public static String calculateBy(final String imageAbsoluteUrl, final Long id) { - if (id == null && imageAbsoluteUrl.contains(ImageRelativeUrl.USER.getValue())) { + public static String calculateBy(final String imageAbsoluteUrl, final String storeName) { + if (storeName == null && imageAbsoluteUrl.contains(ImageRelativeUrl.USER.getValue())) { return imageAbsoluteUrl + ProfileImage.DEFAULT_PROFILE_IMAGE_STORE_NAME; } - return imageAbsoluteUrl + id; + return imageAbsoluteUrl + storeName; } } diff --git a/backend/ddang/src/main/java/com/ddang/ddang/notification/application/NotificationEventListener.java b/backend/ddang/src/main/java/com/ddang/ddang/notification/application/NotificationEventListener.java index 1a06f1125..2839f60cd 100644 --- a/backend/ddang/src/main/java/com/ddang/ddang/notification/application/NotificationEventListener.java +++ b/backend/ddang/src/main/java/com/ddang/ddang/notification/application/NotificationEventListener.java @@ -5,6 +5,7 @@ import com.ddang.ddang.bid.application.event.BidNotificationEvent; import com.ddang.ddang.chat.application.event.MessageNotificationEvent; import com.ddang.ddang.chat.domain.Message; +import com.ddang.ddang.image.application.util.ImageStoreNameProcessor; import com.ddang.ddang.image.domain.AuctionImage; import com.ddang.ddang.image.domain.ProfileImage; import com.ddang.ddang.image.presentation.util.ImageUrlCalculator; @@ -44,7 +45,7 @@ public void sendMessageNotification(final MessageNotificationEvent messageNotifi message.getWriter().getName(), message.getContents(), calculateRedirectUrl(MESSAGE_NOTIFICATION_REDIRECT_URI, message.getChatRoom().getId()), - ImageUrlCalculator.calculateBy(messageNotificationEvent.profileImageAbsoluteUrl(), profileImage.getId()) + ImageUrlCalculator.calculateBy(messageNotificationEvent.profileImageAbsoluteUrl(), ImageStoreNameProcessor.process(profileImage)) ); notificationService.send(createNotificationDto); } catch (final FirebaseMessagingException ex) { @@ -64,7 +65,7 @@ public void sendBidNotification(final BidNotificationEvent bidNotificationEvent) auction.getTitle(), BID_NOTIFICATION_MESSAGE_FORMAT, calculateRedirectUrl(AUCTION_DETAIL_URI, auction.getId()), - ImageUrlCalculator.calculateBy(bidDto.auctionImageAbsoluteUrl(), auctionImage.getId()) + ImageUrlCalculator.calculateBy(bidDto.auctionImageAbsoluteUrl(), ImageStoreNameProcessor.process(auctionImage)) ); notificationService.send(createNotificationDto); } catch (final FirebaseMessagingException ex) { @@ -84,7 +85,7 @@ public void sendQuestionNotification(final QuestionNotificationEvent questionNot auction.getTitle(), question.getContent(), calculateRedirectUrl(AUCTION_DETAIL_URI, auction.getId()), - ImageUrlCalculator.calculateBy(questionNotificationEvent.absoluteImageUrl(), auctionImage.getId()) + ImageUrlCalculator.calculateBy(questionNotificationEvent.absoluteImageUrl(), ImageStoreNameProcessor.process(auctionImage)) ); notificationService.send(createNotificationDto); } catch (final FirebaseMessagingException ex) { @@ -105,7 +106,7 @@ public void sendAnswerNotification(final AnswerNotificationEvent answerNotificat question.getContent(), answer.getContent(), calculateRedirectUrl(AUCTION_DETAIL_URI, auction.getId()), - ImageUrlCalculator.calculateBy(answerNotificationEvent.absoluteImageUrl(), auctionImage.getId()) + ImageUrlCalculator.calculateBy(answerNotificationEvent.absoluteImageUrl(), ImageStoreNameProcessor.process(auctionImage)) ); notificationService.send(createNotificationDto); } catch (final FirebaseMessagingException ex) { diff --git a/backend/ddang/src/test/java/com/ddang/ddang/image/presentation/util/ImageUrlCalculatorTest.java b/backend/ddang/src/test/java/com/ddang/ddang/image/presentation/util/ImageUrlCalculatorTest.java index 6757db17e..13f22b1f9 100644 --- a/backend/ddang/src/test/java/com/ddang/ddang/image/presentation/util/ImageUrlCalculatorTest.java +++ b/backend/ddang/src/test/java/com/ddang/ddang/image/presentation/util/ImageUrlCalculatorTest.java @@ -43,16 +43,16 @@ class ImageUrlCalculatorTest extends ImageUrlCalculatorFixture { @Test void 프로필_사진의_절대_URL로_절대_경로를_계산한다() { // when - final String actual = ImageUrlCalculator.calculateBy(프로필_이미지_절대_URL, 프로필_이미지_아이디); + final String actual = ImageUrlCalculator.calculateBy(프로필_이미지_절대_URL, 프로필_이미지_저장_이름); // then - assertThat(actual).isEqualTo(프로필_이미지_전체_URL); + assertThat(actual).isEqualTo(프로필_이미지_저장_이름_기반_전체_URL); } @Test void 프로필_사진의_아이디가_null인_경우_기본_이미지의_절대_URL로_절대_경로를_계산한다() { // when - final String actual = ImageUrlCalculator.calculateBy(프로필_이미지_절대_URL, 프로필_이미지_아이디가_null); + final String actual = ImageUrlCalculator.calculateBy(프로필_이미지_절대_URL, 프로필_이미지_저장_이름이_null); // then assertThat(actual).isEqualTo(프로필_기본_이미지_전체_URL); @@ -61,9 +61,9 @@ class ImageUrlCalculatorTest extends ImageUrlCalculatorFixture { @Test void 경매_대표_이미지의_절대_URL로_절대_경로를_계산한다() { // when - final String actual = ImageUrlCalculator.calculateBy(경매_이미지_절대_URL, 경매_이미지_아이디); + final String actual = ImageUrlCalculator.calculateBy(경매_이미지_절대_URL, 경매_이미지_저장_이름); // then - assertThat(actual).isEqualTo(경매_이미지_전체_URL); + assertThat(actual).isEqualTo(경매_이미지_저장_이름_기반_전체_URL); } } diff --git a/backend/ddang/src/test/java/com/ddang/ddang/image/presentation/util/fixture/ImageUrlCalculatorFixture.java b/backend/ddang/src/test/java/com/ddang/ddang/image/presentation/util/fixture/ImageUrlCalculatorFixture.java index 6904060a2..89db85cee 100644 --- a/backend/ddang/src/test/java/com/ddang/ddang/image/presentation/util/fixture/ImageUrlCalculatorFixture.java +++ b/backend/ddang/src/test/java/com/ddang/ddang/image/presentation/util/fixture/ImageUrlCalculatorFixture.java @@ -9,18 +9,12 @@ public class ImageUrlCalculatorFixture { protected ImageRelativeUrl 경매_이미지_상대_URL = ImageRelativeUrl.AUCTION; protected String 프로필_이미지_절대_URL = "/users/images/"; - protected Long 프로필_이미지_아이디 = 2L; - protected Long 프로필_이미지_아이디가_null = null; - protected String 프로필_이미지_전체_URL = 프로필_이미지_절대_URL + 프로필_이미지_아이디; protected String 프로필_기본_이미지_전체_URL = 프로필_이미지_절대_URL + "default_profile_image.png"; protected String 프로필_이미지_저장_이름 = "profile_image_store_name.png"; protected String 프로필_이미지_저장_이름이_null = null; protected String 프로필_이미지_저장_이름_기반_전체_URL = 프로필_이미지_절대_URL + 프로필_이미지_저장_이름; protected String 이미지_저장_이름_기반_프로필_기본_이미지_전체_URL = 프로필_이미지_절대_URL + "default_profile_image.png"; protected String 경매_이미지_절대_URL = "/auctions/images/"; - protected Long 경매_이미지_아이디 = 1L; - protected String 경매_이미지_전체_URL = 경매_이미지_절대_URL + 경매_이미지_아이디; - protected String 경매_이미지_저장_이름 = "auction_image_store_name.png"; protected String 경매_이미지_저장_이름_기반_전체_URL = 경매_이미지_절대_URL + 경매_이미지_저장_이름; } From 13759725f9543e9eca43b88c86edfa04c61cb948 Mon Sep 17 00:00:00 2001 From: kwonyj1022 Date: Thu, 19 Oct 2023 01:04:25 +0900 Subject: [PATCH 03/15] =?UTF-8?q?refactor:=20=EA=B2=BD=EB=A7=A4=20?= =?UTF-8?q?=EC=A1=B0=ED=9A=8C=20=EC=8B=9C=20=ED=8C=90=EB=A7=A4=EC=9E=90=20?= =?UTF-8?q?=ED=94=84=EB=A1=9C=ED=95=84=20=EC=9D=B4=EB=AF=B8=EC=A7=80=20?= =?UTF-8?q?=EC=A1=B0=ED=9A=8C=EB=A1=9C=20=EC=9D=B8=ED=95=9C=20n+1=20?= =?UTF-8?q?=EA=B0=9C=EC=84=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../infrastructure/persistence/JpaAuctionRepository.java | 3 ++- .../infrastructure/persistence/QuerydslAuctionRepository.java | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/backend/ddang/src/main/java/com/ddang/ddang/auction/infrastructure/persistence/JpaAuctionRepository.java b/backend/ddang/src/main/java/com/ddang/ddang/auction/infrastructure/persistence/JpaAuctionRepository.java index 8ccb8660f..b4a9271ee 100644 --- a/backend/ddang/src/main/java/com/ddang/ddang/auction/infrastructure/persistence/JpaAuctionRepository.java +++ b/backend/ddang/src/main/java/com/ddang/ddang/auction/infrastructure/persistence/JpaAuctionRepository.java @@ -19,7 +19,8 @@ public interface JpaAuctionRepository extends JpaRepository { LEFT JOIN FETCH a.lastBid JOIN FETCH a.subCategory sc JOIN FETCH sc.mainCategory - JOIN FETCH a.seller + JOIN FETCH a.seller seller + LEFT JOIN FETCH seller.profileImage WHERE a.deleted = false AND a.id = :id """) Optional findTotalAuctionById(final Long id); diff --git a/backend/ddang/src/main/java/com/ddang/ddang/auction/infrastructure/persistence/QuerydslAuctionRepository.java b/backend/ddang/src/main/java/com/ddang/ddang/auction/infrastructure/persistence/QuerydslAuctionRepository.java index 4ef4f2d15..b919e9f32 100644 --- a/backend/ddang/src/main/java/com/ddang/ddang/auction/infrastructure/persistence/QuerydslAuctionRepository.java +++ b/backend/ddang/src/main/java/com/ddang/ddang/auction/infrastructure/persistence/QuerydslAuctionRepository.java @@ -148,6 +148,7 @@ private List findAuctionsByIdsAndOrderSpecifiers( .join(auction.subCategory, category).fetchJoin() .join(category.mainCategory).fetchJoin() .join(auction.seller).fetchJoin() + .join(auction.seller.profileImage).fetchJoin() .where(auction.id.in(targetIds.toArray(Long[]::new))) .orderBy(orderSpecifiers.toArray(OrderSpecifier[]::new)) .fetch(); From fd9e440025783a51d841e3694e844acd36c58c24 Mon Sep 17 00:00:00 2001 From: kwonyj1022 Date: Thu, 19 Oct 2023 01:33:45 +0900 Subject: [PATCH 04/15] =?UTF-8?q?refactor:=20=EC=9E=85=EC=B0=B0=20?= =?UTF-8?q?=EB=AA=A9=EB=A1=9D=20=EC=A1=B0=ED=9A=8C=20=EC=8B=9C=20=EC=9E=85?= =?UTF-8?q?=EC=B0=B0=EC=9E=90=20=EC=A0=95=EB=B3=B4=20=EC=A1=B0=ED=9A=8C?= =?UTF-8?q?=EB=A1=9C=20=EC=9D=B8=ED=95=9C=20n+1=20=EA=B0=9C=EC=84=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bid/infrastructure/persistence/JpaBidRepository.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/backend/ddang/src/main/java/com/ddang/ddang/bid/infrastructure/persistence/JpaBidRepository.java b/backend/ddang/src/main/java/com/ddang/ddang/bid/infrastructure/persistence/JpaBidRepository.java index 9c3a2e690..bf5f9824d 100644 --- a/backend/ddang/src/main/java/com/ddang/ddang/bid/infrastructure/persistence/JpaBidRepository.java +++ b/backend/ddang/src/main/java/com/ddang/ddang/bid/infrastructure/persistence/JpaBidRepository.java @@ -10,6 +10,13 @@ public interface JpaBidRepository extends JpaRepository { + @Query(""" + SELECT bid + FROM Bid bid + JOIN FETCH bid.bidder bidder + LEFT JOIN FETCH bidder.profileImage + WHERE bid.auction.id = :auctionId ORDER BY bid.id ASC + """) List findAllByAuctionIdOrderByIdAsc(final Long auctionId); @Query("SELECT b FROM Bid b WHERE b.auction.id = :auctionId ORDER BY b.id DESC LIMIT 1") From 05b09e244af956916960c10063e3a6f125ccf823 Mon Sep 17 00:00:00 2001 From: kwonyj1022 Date: Thu, 19 Oct 2023 01:34:08 +0900 Subject: [PATCH 05/15] =?UTF-8?q?refactor:=20=EC=B1=84=ED=8C=85=EB=B0=A9?= =?UTF-8?q?=20=EA=B4=80=EB=A0=A8=20=EC=A1=B0=ED=9A=8C=20=EC=8B=9C=20?= =?UTF-8?q?=EC=B0=B8=EC=97=AC=EC=9E=90=20=ED=94=84=EB=A1=9C=ED=95=84=20?= =?UTF-8?q?=EC=9D=B4=EB=AF=B8=EC=A7=80=20=EC=A1=B0=ED=9A=8C=EB=A1=9C=20?= =?UTF-8?q?=EC=9D=B8=ED=95=9C=20n+1=20=EA=B0=9C=EC=84=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../persistence/QuerydslChatRoomAndImageRepository.java | 9 +++++---- .../QuerydslChatRoomAndMessageAndImageRepository.java | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/backend/ddang/src/main/java/com/ddang/ddang/chat/infrastructure/persistence/QuerydslChatRoomAndImageRepository.java b/backend/ddang/src/main/java/com/ddang/ddang/chat/infrastructure/persistence/QuerydslChatRoomAndImageRepository.java index cfdd83e9e..6c74526ed 100644 --- a/backend/ddang/src/main/java/com/ddang/ddang/chat/infrastructure/persistence/QuerydslChatRoomAndImageRepository.java +++ b/backend/ddang/src/main/java/com/ddang/ddang/chat/infrastructure/persistence/QuerydslChatRoomAndImageRepository.java @@ -25,9 +25,10 @@ public Optional findChatRoomById(final Long chatRoomId) { final ChatRoomAndImageQueryProjectionDto chatRoomAndImageQueryProjectionDto = queryFactory.select(new QChatRoomAndImageQueryProjectionDto(chatRoom, auctionImage)) .from(chatRoom) - .leftJoin(chatRoom.buyer).fetchJoin() - .leftJoin(chatRoom.auction, auction).fetchJoin() - .leftJoin(auction.seller).fetchJoin() + .join(chatRoom.buyer).fetchJoin() + .join(chatRoom.auction, auction).fetchJoin() + .join(auction.seller).fetchJoin() + .leftJoin(auction.seller.profileImage).fetchJoin() .leftJoin(auctionImage).on(auctionImage.id.eq( JPAExpressions .select(auctionImage.id.min()) @@ -35,7 +36,7 @@ public Optional findChatRoomById(final Long chatRoomId) { .where(auctionImage.auction.id.eq(auction.id)) .groupBy(auctionImage.auction.id) )).fetchJoin() - .leftJoin(auction.lastBid).fetchJoin() + .join(auction.lastBid).fetchJoin() .where(chatRoom.id.eq(chatRoomId)) .fetchOne(); diff --git a/backend/ddang/src/main/java/com/ddang/ddang/chat/infrastructure/persistence/QuerydslChatRoomAndMessageAndImageRepository.java b/backend/ddang/src/main/java/com/ddang/ddang/chat/infrastructure/persistence/QuerydslChatRoomAndMessageAndImageRepository.java index 07e7bc5f7..514c4574f 100644 --- a/backend/ddang/src/main/java/com/ddang/ddang/chat/infrastructure/persistence/QuerydslChatRoomAndMessageAndImageRepository.java +++ b/backend/ddang/src/main/java/com/ddang/ddang/chat/infrastructure/persistence/QuerydslChatRoomAndMessageAndImageRepository.java @@ -28,9 +28,10 @@ public List findAllChatRoomInfoByUserIdOrderByLas final List unsortedDtos = queryFactory.select(new QChatRoomAndMessageAndImageQueryProjectionDto(chatRoom, message, auctionImage)) .from(chatRoom) - .leftJoin(chatRoom.buyer).fetchJoin() - .leftJoin(chatRoom.auction, auction).fetchJoin() - .leftJoin(auction.seller).fetchJoin() + .join(chatRoom.buyer).fetchJoin() + .join(chatRoom.auction, auction).fetchJoin() + .join(auction.seller).fetchJoin() + .leftJoin(auction.seller.profileImage).fetchJoin() .leftJoin(auctionImage).on(auctionImage.id.eq( JPAExpressions .select(auctionImage.id.min()) @@ -38,7 +39,7 @@ public List findAllChatRoomInfoByUserIdOrderByLas .where(auctionImage.auction.id.eq(auction.id)) .groupBy(auctionImage.auction.id) )).fetchJoin() - .leftJoin(auction.lastBid).fetchJoin() + .join(auction.lastBid).fetchJoin() .leftJoin(message).on(message.id.eq( JPAExpressions .select(message.id.max()) From 69a134f762da448db240d63ebafb05096242a861 Mon Sep 17 00:00:00 2001 From: kwonyj1022 Date: Thu, 19 Oct 2023 01:38:49 +0900 Subject: [PATCH 06/15] =?UTF-8?q?refactor:=20qna=20=EA=B4=80=EB=A0=A8=20?= =?UTF-8?q?=EC=A1=B0=ED=9A=8C=20=EC=8B=9C=20=EC=82=AC=EC=9A=A9=EC=9E=90=20?= =?UTF-8?q?=ED=94=84=EB=A1=9C=ED=95=84=20=EC=9D=B4=EB=AF=B8=EC=A7=80=20?= =?UTF-8?q?=EC=A1=B0=ED=9A=8C=EB=A1=9C=20=EC=9D=B8=ED=95=9C=20n+1=20?= =?UTF-8?q?=EA=B0=9C=EC=84=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ddang/qna/infrastructure/JpaQuestionRepository.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/backend/ddang/src/main/java/com/ddang/ddang/qna/infrastructure/JpaQuestionRepository.java b/backend/ddang/src/main/java/com/ddang/ddang/qna/infrastructure/JpaQuestionRepository.java index 11de78514..ae6585356 100644 --- a/backend/ddang/src/main/java/com/ddang/ddang/qna/infrastructure/JpaQuestionRepository.java +++ b/backend/ddang/src/main/java/com/ddang/ddang/qna/infrastructure/JpaQuestionRepository.java @@ -14,10 +14,12 @@ public interface JpaQuestionRepository extends JpaRepository { @Query(""" SELECT q FROM Question q - JOIN FETCH q.writer + JOIN FETCH q.writer w + LEFT JOIN FETCH w.profileImage LEFT JOIN FETCH q.answer JOIN FETCH q.auction a - JOIN FETCH a.seller + JOIN FETCH a.seller s + JOIN FETCH s.profileImage WHERE q.deleted = false AND a.id = :auctionId """) List findAllByAuctionId(final Long auctionId); From a02c1d61c13de4e952a31510769fb7aa2143b7f2 Mon Sep 17 00:00:00 2001 From: kwonyj1022 Date: Thu, 19 Oct 2023 01:50:14 +0900 Subject: [PATCH 07/15] =?UTF-8?q?refactor:=20=EC=8B=A0=EA=B3=A0=20?= =?UTF-8?q?=EA=B4=80=EB=A0=A8=20=EC=A1=B0=ED=9A=8C=20=EC=8B=9C=20=EC=82=AC?= =?UTF-8?q?=EC=9A=A9=EC=9E=90=20=ED=94=84=EB=A1=9C=ED=95=84=20=EC=9D=B4?= =?UTF-8?q?=EB=AF=B8=EC=A7=80=20=EC=A1=B0=ED=9A=8C=EB=A1=9C=20=EC=9D=B8?= =?UTF-8?q?=ED=95=9C=20n+1=20=EA=B0=9C=EC=84=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../persistence/JpaAnswerReportRepository.java | 8 ++++---- .../persistence/JpaAuctionReportRepository.java | 6 ++++-- .../persistence/JpaChatRoomReportRepository.java | 9 ++++++--- .../persistence/JpaQuestionReportRepository.java | 7 +++++-- 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/backend/ddang/src/main/java/com/ddang/ddang/report/infrastructure/persistence/JpaAnswerReportRepository.java b/backend/ddang/src/main/java/com/ddang/ddang/report/infrastructure/persistence/JpaAnswerReportRepository.java index 2be18d491..b4614a8fa 100644 --- a/backend/ddang/src/main/java/com/ddang/ddang/report/infrastructure/persistence/JpaAnswerReportRepository.java +++ b/backend/ddang/src/main/java/com/ddang/ddang/report/infrastructure/persistence/JpaAnswerReportRepository.java @@ -13,11 +13,11 @@ public interface JpaAnswerReportRepository extends JpaRepository findAll(); diff --git a/backend/ddang/src/main/java/com/ddang/ddang/report/infrastructure/persistence/JpaAuctionReportRepository.java b/backend/ddang/src/main/java/com/ddang/ddang/report/infrastructure/persistence/JpaAuctionReportRepository.java index 5fa4e4186..dfff156f8 100644 --- a/backend/ddang/src/main/java/com/ddang/ddang/report/infrastructure/persistence/JpaAuctionReportRepository.java +++ b/backend/ddang/src/main/java/com/ddang/ddang/report/infrastructure/persistence/JpaAuctionReportRepository.java @@ -13,9 +13,11 @@ public interface JpaAuctionReportRepository extends JpaRepository findAll(); diff --git a/backend/ddang/src/main/java/com/ddang/ddang/report/infrastructure/persistence/JpaChatRoomReportRepository.java b/backend/ddang/src/main/java/com/ddang/ddang/report/infrastructure/persistence/JpaChatRoomReportRepository.java index c41258456..6f1bd65f4 100644 --- a/backend/ddang/src/main/java/com/ddang/ddang/report/infrastructure/persistence/JpaChatRoomReportRepository.java +++ b/backend/ddang/src/main/java/com/ddang/ddang/report/infrastructure/persistence/JpaChatRoomReportRepository.java @@ -13,11 +13,14 @@ public interface JpaChatRoomReportRepository extends JpaRepository findAll(); diff --git a/backend/ddang/src/main/java/com/ddang/ddang/report/infrastructure/persistence/JpaQuestionReportRepository.java b/backend/ddang/src/main/java/com/ddang/ddang/report/infrastructure/persistence/JpaQuestionReportRepository.java index deaf6e349..caad0fd2e 100644 --- a/backend/ddang/src/main/java/com/ddang/ddang/report/infrastructure/persistence/JpaQuestionReportRepository.java +++ b/backend/ddang/src/main/java/com/ddang/ddang/report/infrastructure/persistence/JpaQuestionReportRepository.java @@ -13,8 +13,11 @@ public interface JpaQuestionReportRepository extends JpaRepository findAll(); From c98c3a7e8d1e0f7cdd8c109a26eeb7b3a9f62b4f Mon Sep 17 00:00:00 2001 From: kwonyj1022 Date: Thu, 19 Oct 2023 01:51:56 +0900 Subject: [PATCH 08/15] =?UTF-8?q?refactor:=20=ED=8F=89=EA=B0=80=20?= =?UTF-8?q?=EA=B4=80=EB=A0=A8=20=EC=A1=B0=ED=9A=8C=20=EC=8B=9C=20=EC=82=AC?= =?UTF-8?q?=EC=9A=A9=EC=9E=90=20=ED=94=84=EB=A1=9C=ED=95=84=20=EC=9D=B4?= =?UTF-8?q?=EB=AF=B8=EC=A7=80=20=EC=A1=B0=ED=9A=8C=EB=A1=9C=20=EC=9D=B8?= =?UTF-8?q?=ED=95=9C=20n+1=20=EA=B0=9C=EC=84=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../review/infrastructure/persistence/JpaReviewRepository.java | 1 + 1 file changed, 1 insertion(+) diff --git a/backend/ddang/src/main/java/com/ddang/ddang/review/infrastructure/persistence/JpaReviewRepository.java b/backend/ddang/src/main/java/com/ddang/ddang/review/infrastructure/persistence/JpaReviewRepository.java index 5462534d6..c1be24a3d 100644 --- a/backend/ddang/src/main/java/com/ddang/ddang/review/infrastructure/persistence/JpaReviewRepository.java +++ b/backend/ddang/src/main/java/com/ddang/ddang/review/infrastructure/persistence/JpaReviewRepository.java @@ -14,6 +14,7 @@ public interface JpaReviewRepository extends JpaRepository { @Query(""" SELECT r FROM Review r JOIN FETCH r.writer w + LEFT JOIN FETCH w.profileImage JOIN FETCH r.target t WHERE t.id = :targetId ORDER BY r.id DESC From 7ad27b78841d1079f4aaea44501094187e8ddfd6 Mon Sep 17 00:00:00 2001 From: kwonyj1022 Date: Thu, 19 Oct 2023 01:57:23 +0900 Subject: [PATCH 09/15] =?UTF-8?q?refactor:=20=EC=82=AC=EC=9A=A9=EC=9E=90?= =?UTF-8?q?=20=EC=A0=95=EB=B3=B4=20=EC=A1=B0=ED=9A=8C=20=EC=8B=9C=20?= =?UTF-8?q?=EC=82=AC=EC=9A=A9=EC=9E=90=20=ED=94=84=EB=A1=9C=ED=95=84=20?= =?UTF-8?q?=EC=9D=B4=EB=AF=B8=EC=A7=80=20=EC=A1=B0=ED=9A=8C=EB=A1=9C=20?= =?UTF-8?q?=EC=9D=B8=ED=95=9C=20n+1=20=EA=B0=9C=EC=84=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ddang/user/application/UserService.java | 4 ++-- .../user/domain/repository/UserRepository.java | 1 + .../persistence/JpaUserRepository.java | 8 ++++++++ .../persistence/UserRepositoryImpl.java | 5 +++++ .../persistence/JpaUserRepositoryTest.java | 18 ++++++++++++++++++ .../persistence/UserRepositoryImplTest.java | 18 ++++++++++++++++++ 6 files changed, 52 insertions(+), 2 deletions(-) diff --git a/backend/ddang/src/main/java/com/ddang/ddang/user/application/UserService.java b/backend/ddang/src/main/java/com/ddang/ddang/user/application/UserService.java index c0cc24705..9b299d407 100644 --- a/backend/ddang/src/main/java/com/ddang/ddang/user/application/UserService.java +++ b/backend/ddang/src/main/java/com/ddang/ddang/user/application/UserService.java @@ -21,7 +21,7 @@ public class UserService { private final StoreImageProcessor imageProcessor; public ReadUserDto readById(final Long userId) { - final User user = userRepository.findById(userId) + final User user = userRepository.findByIdWithProfileImage(userId) .orElseThrow(() -> new UserNotFoundException("사용자 정보를 사용할 수 없습니다.")); return ReadUserDto.from(user); @@ -29,7 +29,7 @@ public ReadUserDto readById(final Long userId) { @Transactional public ReadUserDto updateById(final Long userId, final UpdateUserDto userDto) { - final User user = userRepository.findById(userId) + final User user = userRepository.findByIdWithProfileImage(userId) .orElseThrow(() -> new UserNotFoundException("사용자 정보를 사용할 수 없습니다.")); updateUserByRequest(userDto, user); diff --git a/backend/ddang/src/main/java/com/ddang/ddang/user/domain/repository/UserRepository.java b/backend/ddang/src/main/java/com/ddang/ddang/user/domain/repository/UserRepository.java index 6f1b7fdfc..8fb2f3561 100644 --- a/backend/ddang/src/main/java/com/ddang/ddang/user/domain/repository/UserRepository.java +++ b/backend/ddang/src/main/java/com/ddang/ddang/user/domain/repository/UserRepository.java @@ -9,6 +9,7 @@ public interface UserRepository { User save(final User user); Optional findById(final Long id); + Optional findByIdWithProfileImage(final Long id); boolean existsById(final Long id); diff --git a/backend/ddang/src/main/java/com/ddang/ddang/user/infrastructure/persistence/JpaUserRepository.java b/backend/ddang/src/main/java/com/ddang/ddang/user/infrastructure/persistence/JpaUserRepository.java index a703d934b..809eead49 100644 --- a/backend/ddang/src/main/java/com/ddang/ddang/user/infrastructure/persistence/JpaUserRepository.java +++ b/backend/ddang/src/main/java/com/ddang/ddang/user/infrastructure/persistence/JpaUserRepository.java @@ -15,6 +15,14 @@ public interface JpaUserRepository extends JpaRepository { """) Optional findById(final Long id); + @Query(""" + SELECT u + FROM User u + LEFT JOIN FETCH u.profileImage + WHERE u.deleted = false AND u.id = :id + """) + Optional findByIdWithProfileImage(final Long id); + @Query(""" SELECT u FROM User u diff --git a/backend/ddang/src/main/java/com/ddang/ddang/user/infrastructure/persistence/UserRepositoryImpl.java b/backend/ddang/src/main/java/com/ddang/ddang/user/infrastructure/persistence/UserRepositoryImpl.java index 5a5e3fac6..93ac01488 100644 --- a/backend/ddang/src/main/java/com/ddang/ddang/user/infrastructure/persistence/UserRepositoryImpl.java +++ b/backend/ddang/src/main/java/com/ddang/ddang/user/infrastructure/persistence/UserRepositoryImpl.java @@ -23,6 +23,11 @@ public Optional findById(final Long id) { return jpaUserRepository.findById(id); } + @Override + public Optional findByIdWithProfileImage(final Long id) { + return jpaUserRepository.findByIdWithProfileImage(id); + } + @Override public boolean existsById(final Long id) { return jpaUserRepository.existsById(id); diff --git a/backend/ddang/src/test/java/com/ddang/ddang/user/infrastructure/persistence/JpaUserRepositoryTest.java b/backend/ddang/src/test/java/com/ddang/ddang/user/infrastructure/persistence/JpaUserRepositoryTest.java index d907a04fd..7ce64a559 100644 --- a/backend/ddang/src/test/java/com/ddang/ddang/user/infrastructure/persistence/JpaUserRepositoryTest.java +++ b/backend/ddang/src/test/java/com/ddang/ddang/user/infrastructure/persistence/JpaUserRepositoryTest.java @@ -60,6 +60,24 @@ class JpaUserRepositoryTest extends JpaUserRepositoryFixture { assertThat(actual).isEmpty(); } + @Test + void 존재하는_사용자_아이디를_전달하면_해당_사용자를_Optional로_감싸_반환하고_프로필_이미지도_한번에_조회한다() { + // when + final Optional actual = userRepository.findByIdWithProfileImage(사용자.getId()); + + // then + assertThat(actual).contains(사용자); + } + + @Test + void 존재하지_않는_사용자_아이디를_전달하면_빈_Optional을_반환하고_프로필_이미지도_한번에_조회한다() { + // when + final Optional actual = userRepository.findByIdWithProfileImage(존재하지_않는_사용자_아이디); + + // then + assertThat(actual).isEmpty(); + } + @Test void 회원탈퇴한_사용자의_id를_전달하면_빈_Optional을_반환한다() { // when diff --git a/backend/ddang/src/test/java/com/ddang/ddang/user/infrastructure/persistence/UserRepositoryImplTest.java b/backend/ddang/src/test/java/com/ddang/ddang/user/infrastructure/persistence/UserRepositoryImplTest.java index 775126096..2e8e2c5df 100644 --- a/backend/ddang/src/test/java/com/ddang/ddang/user/infrastructure/persistence/UserRepositoryImplTest.java +++ b/backend/ddang/src/test/java/com/ddang/ddang/user/infrastructure/persistence/UserRepositoryImplTest.java @@ -66,6 +66,24 @@ void setUp(@Autowired final JpaUserRepository jpaUserRepository) { assertThat(actual).isEmpty(); } + @Test + void 존재하는_사용자_아이디를_전달하면_해당_사용자를_Optional로_감싸_반환하고_프로필_이미지도_한번에_조회한다() { + // when + final Optional actual = userRepository.findByIdWithProfileImage(사용자.getId()); + + // then + assertThat(actual).contains(사용자); + } + + @Test + void 존재하지_않는_사용자_아이디를_전달하면_빈_Optional을_반환하고_프로필_이미지도_한번에_조회한다() { + // when + final Optional actual = userRepository.findByIdWithProfileImage(존재하지_않는_사용자_아이디); + + // then + assertThat(actual).isEmpty(); + } + @Test void 회원탈퇴한_사용자의_id를_전달하면_빈_Optional을_반환한다() { // when From f6c2d4ed04821a1f504637acf9864eb0abd0071e Mon Sep 17 00:00:00 2001 From: kwonyj1022 Date: Thu, 19 Oct 2023 02:03:53 +0900 Subject: [PATCH 10/15] =?UTF-8?q?refactor:=20=EB=A9=94=EC=8B=9C=EC=A7=80?= =?UTF-8?q?=20=EC=95=8C=EB=A6=BC=20=EC=8B=9C=20=EC=9E=91=EC=84=B1=EC=9E=90?= =?UTF-8?q?=20=ED=94=84=EB=A1=9C=ED=95=84=20=EC=9D=B4=EB=AF=B8=EC=A7=80=20?= =?UTF-8?q?=EC=A1=B0=ED=9A=8C=EB=A1=9C=20=EC=9D=B8=ED=95=9C=20n+1=20?= =?UTF-8?q?=EA=B0=9C=EC=84=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/ddang/ddang/chat/application/MessageService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/ddang/src/main/java/com/ddang/ddang/chat/application/MessageService.java b/backend/ddang/src/main/java/com/ddang/ddang/chat/application/MessageService.java index 35493d0f5..ef9f3f88d 100644 --- a/backend/ddang/src/main/java/com/ddang/ddang/chat/application/MessageService.java +++ b/backend/ddang/src/main/java/com/ddang/ddang/chat/application/MessageService.java @@ -38,7 +38,7 @@ public Long create(final CreateMessageDto dto, final String profileImageAbsolute final ChatRoom chatRoom = chatRoomRepository.findById(dto.chatRoomId()) .orElseThrow(() -> new ChatRoomNotFoundException( "지정한 아이디에 대한 채팅방을 찾을 수 없습니다.")); - final User writer = userRepository.findById(dto.writerId()) + final User writer = userRepository.findByIdWithProfileImage(dto.writerId()) .orElseThrow(() -> new UserNotFoundException( "지정한 아이디에 대한 발신자를 찾을 수 없습니다.")); final User receiver = userRepository.findById(dto.receiverId()) From 5aa95a90c9bdf580648e5f85e71283440e3e9ab8 Mon Sep 17 00:00:00 2001 From: kwonyj1022 Date: Thu, 19 Oct 2023 03:02:36 +0900 Subject: [PATCH 11/15] =?UTF-8?q?feat:=20=EC=9D=B4=EB=AF=B8=EC=A7=80=20?= =?UTF-8?q?=EC=9D=B4=EB=A6=84=EC=9D=B4=20=ED=8F=AC=ED=95=A8=EB=90=9C=20url?= =?UTF-8?q?=EB=A1=9C=20=EC=A1=B0=ED=9A=8C=20=EC=8B=9C=20=EC=9D=B4=EB=AF=B8?= =?UTF-8?q?=EC=A7=80=20=ED=8C=8C=EC=9D=BC=EC=9D=84=20=EB=B0=98=ED=99=98?= =?UTF-8?q?=ED=95=98=EB=8A=94=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ddang/image/application/ImageService.java | 20 ++++-------- .../repository/AuctionImageRepository.java | 6 +--- .../repository/ProfileImageRepository.java | 8 +---- .../AuctionImageRepositoryImpl.java | 7 ++--- .../JpaAuctionImageRepository.java | 8 +++++ .../JpaProfileImageRepository.java | 10 +++--- .../ProfileImageRepositoryImpl.java | 12 ++----- .../image/presentation/ImageController.java | 15 ++++----- .../image/application/ImageServiceTest.java | 8 ++--- .../fixture/ImageServiceFixture.java | 4 +-- .../AuctionImageRepositoryImplTest.java | 18 +++++++---- .../JpaAuctionImageRepositoryTest.java | 23 +++++--------- .../JpaProfileImageRepositoryTest.java | 31 ++++--------------- .../ProfileImageRepositoryImplTest.java | 15 ++++----- .../AuctionImageRepositoryImplFixture.java | 13 ++------ .../JpaAuctionImageRepositoryFixture.java | 6 ++-- .../JpaProfileImageRepositoryFixture.java | 7 ++--- .../ProfileImageRepositoryImplFixture.java | 13 ++------ .../presentation/ImageControllerTest.java | 26 ++++++++-------- .../fixture/ImageControllerFixture.java | 8 ++--- 20 files changed, 100 insertions(+), 158 deletions(-) diff --git a/backend/ddang/src/main/java/com/ddang/ddang/image/application/ImageService.java b/backend/ddang/src/main/java/com/ddang/ddang/image/application/ImageService.java index 7b9f240e3..8b2a11c3a 100644 --- a/backend/ddang/src/main/java/com/ddang/ddang/image/application/ImageService.java +++ b/backend/ddang/src/main/java/com/ddang/ddang/image/application/ImageService.java @@ -1,7 +1,5 @@ package com.ddang.ddang.image.application; -import com.ddang.ddang.image.domain.AuctionImage; -import com.ddang.ddang.image.domain.ProfileImage; import com.ddang.ddang.image.domain.repository.AuctionImageRepository; import com.ddang.ddang.image.domain.repository.ProfileImageRepository; import lombok.RequiredArgsConstructor; @@ -25,28 +23,22 @@ public class ImageService { private final ProfileImageRepository profileImageRepository; private final AuctionImageRepository auctionImageRepository; - public Resource readProfileImage(final Long id) throws MalformedURLException { - final ProfileImage profileImage = profileImageRepository.findById(id) - .orElse(null); - - if (profileImage == null) { + public Resource readProfileImage(final String storeName) throws MalformedURLException { + if (!profileImageRepository.existsByStoreName(storeName)) { return null; } - final String fullPath = findFullPath(profileImage.getImage().getStoreName()); + final String fullPath = findFullPath(storeName); return new UrlResource(FILE_PROTOCOL_PREFIX + fullPath); } - public Resource readAuctionImage(final Long id) throws MalformedURLException { - final AuctionImage auctionImage = auctionImageRepository.findById(id) - .orElse(null); - - if (auctionImage == null) { + public Resource readAuctionImage(final String storeName) throws MalformedURLException { + if (!auctionImageRepository.existsByStoreName(storeName)) { return null; } - final String fullPath = findFullPath(auctionImage.getImage().getStoreName()); + final String fullPath = findFullPath(storeName); return new UrlResource(FILE_PROTOCOL_PREFIX + fullPath); } diff --git a/backend/ddang/src/main/java/com/ddang/ddang/image/domain/repository/AuctionImageRepository.java b/backend/ddang/src/main/java/com/ddang/ddang/image/domain/repository/AuctionImageRepository.java index 586bca166..8fb1333c1 100644 --- a/backend/ddang/src/main/java/com/ddang/ddang/image/domain/repository/AuctionImageRepository.java +++ b/backend/ddang/src/main/java/com/ddang/ddang/image/domain/repository/AuctionImageRepository.java @@ -1,10 +1,6 @@ package com.ddang.ddang.image.domain.repository; -import com.ddang.ddang.image.domain.AuctionImage; - -import java.util.Optional; - public interface AuctionImageRepository { - Optional findById(final Long id); + boolean existsByStoreName(final String storeName); } diff --git a/backend/ddang/src/main/java/com/ddang/ddang/image/domain/repository/ProfileImageRepository.java b/backend/ddang/src/main/java/com/ddang/ddang/image/domain/repository/ProfileImageRepository.java index b0491a5d6..5fde626b0 100644 --- a/backend/ddang/src/main/java/com/ddang/ddang/image/domain/repository/ProfileImageRepository.java +++ b/backend/ddang/src/main/java/com/ddang/ddang/image/domain/repository/ProfileImageRepository.java @@ -1,12 +1,6 @@ package com.ddang.ddang.image.domain.repository; -import com.ddang.ddang.image.domain.ProfileImage; - -import java.util.Optional; - public interface ProfileImageRepository { - Optional findById(final Long id); - - Optional findByStoreName(final String storeName); + boolean existsByStoreName(final String storeName); } diff --git a/backend/ddang/src/main/java/com/ddang/ddang/image/infrastructure/persistence/AuctionImageRepositoryImpl.java b/backend/ddang/src/main/java/com/ddang/ddang/image/infrastructure/persistence/AuctionImageRepositoryImpl.java index c24799bca..913ac97d2 100644 --- a/backend/ddang/src/main/java/com/ddang/ddang/image/infrastructure/persistence/AuctionImageRepositoryImpl.java +++ b/backend/ddang/src/main/java/com/ddang/ddang/image/infrastructure/persistence/AuctionImageRepositoryImpl.java @@ -1,12 +1,9 @@ package com.ddang.ddang.image.infrastructure.persistence; -import com.ddang.ddang.image.domain.AuctionImage; import com.ddang.ddang.image.domain.repository.AuctionImageRepository; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Repository; -import java.util.Optional; - @Repository @RequiredArgsConstructor public class AuctionImageRepositoryImpl implements AuctionImageRepository { @@ -14,7 +11,7 @@ public class AuctionImageRepositoryImpl implements AuctionImageRepository { private final JpaAuctionImageRepository jpaAuctionImageRepository; @Override - public Optional findById(final Long id) { - return jpaAuctionImageRepository.findById(id); + public boolean existsByStoreName(final String storeName) { + return jpaAuctionImageRepository.existsByStoreName(storeName); } } diff --git a/backend/ddang/src/main/java/com/ddang/ddang/image/infrastructure/persistence/JpaAuctionImageRepository.java b/backend/ddang/src/main/java/com/ddang/ddang/image/infrastructure/persistence/JpaAuctionImageRepository.java index 87f345983..fe0210243 100644 --- a/backend/ddang/src/main/java/com/ddang/ddang/image/infrastructure/persistence/JpaAuctionImageRepository.java +++ b/backend/ddang/src/main/java/com/ddang/ddang/image/infrastructure/persistence/JpaAuctionImageRepository.java @@ -2,6 +2,14 @@ import com.ddang.ddang.image.domain.AuctionImage; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; public interface JpaAuctionImageRepository extends JpaRepository { + + @Query(""" + SELECT COUNT(auction_image) > 0 + FROM AuctionImage auction_image + WHERE auction_image.image.storeName = :storeName + """) + boolean existsByStoreName(final String storeName); } diff --git a/backend/ddang/src/main/java/com/ddang/ddang/image/infrastructure/persistence/JpaProfileImageRepository.java b/backend/ddang/src/main/java/com/ddang/ddang/image/infrastructure/persistence/JpaProfileImageRepository.java index 39b321bad..21f4e73e5 100644 --- a/backend/ddang/src/main/java/com/ddang/ddang/image/infrastructure/persistence/JpaProfileImageRepository.java +++ b/backend/ddang/src/main/java/com/ddang/ddang/image/infrastructure/persistence/JpaProfileImageRepository.java @@ -4,10 +4,12 @@ import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; -import java.util.Optional; - public interface JpaProfileImageRepository extends JpaRepository { - @Query("SELECT i FROM ProfileImage i WHERE i.image.storeName = :storeName") - Optional findByStoreName(final String storeName); + @Query(""" + SELECT COUNT(profile_image) > 0 + FROM ProfileImage profile_image + WHERE profile_image.image.storeName = :storeName + """) + boolean existsByStoreName(final String storeName); } diff --git a/backend/ddang/src/main/java/com/ddang/ddang/image/infrastructure/persistence/ProfileImageRepositoryImpl.java b/backend/ddang/src/main/java/com/ddang/ddang/image/infrastructure/persistence/ProfileImageRepositoryImpl.java index 12fa367f7..69fb884c4 100644 --- a/backend/ddang/src/main/java/com/ddang/ddang/image/infrastructure/persistence/ProfileImageRepositoryImpl.java +++ b/backend/ddang/src/main/java/com/ddang/ddang/image/infrastructure/persistence/ProfileImageRepositoryImpl.java @@ -1,12 +1,9 @@ package com.ddang.ddang.image.infrastructure.persistence; -import com.ddang.ddang.image.domain.ProfileImage; import com.ddang.ddang.image.domain.repository.ProfileImageRepository; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Repository; -import java.util.Optional; - @Repository @RequiredArgsConstructor public class ProfileImageRepositoryImpl implements ProfileImageRepository { @@ -14,12 +11,7 @@ public class ProfileImageRepositoryImpl implements ProfileImageRepository { private final JpaProfileImageRepository jpaProfileImageRepository; @Override - public Optional findById(final Long id) { - return jpaProfileImageRepository.findById(id); - } - - @Override - public Optional findByStoreName(final String storeName) { - return jpaProfileImageRepository.findByStoreName(storeName); + public boolean existsByStoreName(final String storeName) { + return jpaProfileImageRepository.existsByStoreName(storeName); } } diff --git a/backend/ddang/src/main/java/com/ddang/ddang/image/presentation/ImageController.java b/backend/ddang/src/main/java/com/ddang/ddang/image/presentation/ImageController.java index 16ace8049..d16838244 100644 --- a/backend/ddang/src/main/java/com/ddang/ddang/image/presentation/ImageController.java +++ b/backend/ddang/src/main/java/com/ddang/ddang/image/presentation/ImageController.java @@ -1,7 +1,6 @@ package com.ddang.ddang.image.presentation; import com.ddang.ddang.image.application.ImageService; -import java.net.MalformedURLException; import lombok.RequiredArgsConstructor; import org.springframework.core.io.Resource; import org.springframework.http.HttpHeaders; @@ -12,15 +11,17 @@ import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RestController; +import java.net.MalformedURLException; + @RestController @RequiredArgsConstructor public class ImageController { private final ImageService imageService; - @GetMapping("/users/images/{id}") - public ResponseEntity downloadProfileImage(@PathVariable Long id) throws MalformedURLException { - final Resource resource = imageService.readProfileImage(id); + @GetMapping("/users/images/{storeName}") + public ResponseEntity downloadProfileImage(@PathVariable String storeName) throws MalformedURLException { + final Resource resource = imageService.readProfileImage(storeName); HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.IMAGE_JPEG); @@ -28,9 +29,9 @@ public ResponseEntity downloadProfileImage(@PathVariable Long id) thro return new ResponseEntity<>(resource, headers, HttpStatus.OK); } - @GetMapping("/auctions/images/{id}") - public ResponseEntity downloadAuctionImage(@PathVariable Long id) throws MalformedURLException { - final Resource resource = imageService.readAuctionImage(id); + @GetMapping("/auctions/images/{storeName}") + public ResponseEntity downloadAuctionImage(@PathVariable String storeName) throws MalformedURLException { + final Resource resource = imageService.readAuctionImage(storeName); HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.IMAGE_JPEG); diff --git a/backend/ddang/src/test/java/com/ddang/ddang/image/application/ImageServiceTest.java b/backend/ddang/src/test/java/com/ddang/ddang/image/application/ImageServiceTest.java index e2044c85c..b86351be2 100644 --- a/backend/ddang/src/test/java/com/ddang/ddang/image/application/ImageServiceTest.java +++ b/backend/ddang/src/test/java/com/ddang/ddang/image/application/ImageServiceTest.java @@ -24,7 +24,7 @@ class ImageServiceTest extends ImageServiceFixture { @Test void 지정한_아이디에_해당하는_프로필_이미지를_조회한다() throws Exception { // when - final Resource actual = imageService.readProfileImage(프로필_이미지.getId()); + final Resource actual = imageService.readProfileImage(프로필_이미지.getImage().getStoreName()); // then assertThat(actual.getFilename()).isEqualTo(프로필_이미지_파일명); @@ -33,7 +33,7 @@ class ImageServiceTest extends ImageServiceFixture { @Test void 지정한_아이디에_해당하는_프로필_이미지가_없는_경우_null을_반환한다() throws MalformedURLException { // when - final Resource actual = imageService.readProfileImage(존재하지_않는_프로필_이미지_아이디); + final Resource actual = imageService.readProfileImage(존재하지_않는_프로필_이미지_이름); // then assertThat(actual).isNull(); @@ -42,7 +42,7 @@ class ImageServiceTest extends ImageServiceFixture { @Test void 지정한_아이디에_해당하는_경매_이미지를_조회한다() throws Exception { // when - final Resource actual = imageService.readAuctionImage(경매_이미지.getId()); + final Resource actual = imageService.readAuctionImage(경매_이미지.getImage().getStoreName()); // then assertThat(actual.getFilename()).isEqualTo(경매_이미지_파일명); @@ -51,7 +51,7 @@ class ImageServiceTest extends ImageServiceFixture { @Test void 지정한_아이디에_해당하는_경매_이미지가_없는_경우_null을_반환한다() throws MalformedURLException { // when - final Resource actual = imageService.readAuctionImage(존재하지_않는_경매_이미지_아이디); + final Resource actual = imageService.readAuctionImage(존재하지_않는_경매_이미지_이름); // then assertThat(actual).isNull(); diff --git a/backend/ddang/src/test/java/com/ddang/ddang/image/application/fixture/ImageServiceFixture.java b/backend/ddang/src/test/java/com/ddang/ddang/image/application/fixture/ImageServiceFixture.java index c70725205..02232306a 100644 --- a/backend/ddang/src/test/java/com/ddang/ddang/image/application/fixture/ImageServiceFixture.java +++ b/backend/ddang/src/test/java/com/ddang/ddang/image/application/fixture/ImageServiceFixture.java @@ -16,8 +16,8 @@ public class ImageServiceFixture { @Autowired private JpaAuctionImageRepository auctionImageRepository; - protected Long 존재하지_않는_프로필_이미지_아이디 = -999L; - protected Long 존재하지_않는_경매_이미지_아이디 = -999L; + protected String 존재하지_않는_프로필_이미지_이름 = "invalid_profile.png"; + protected String 존재하지_않는_경매_이미지_이름 = "invalid_auction.png"; protected ProfileImage 프로필_이미지; protected String 프로필_이미지_파일명; diff --git a/backend/ddang/src/test/java/com/ddang/ddang/image/infrastructure/persistence/AuctionImageRepositoryImplTest.java b/backend/ddang/src/test/java/com/ddang/ddang/image/infrastructure/persistence/AuctionImageRepositoryImplTest.java index a77fea90e..bb97c2993 100644 --- a/backend/ddang/src/test/java/com/ddang/ddang/image/infrastructure/persistence/AuctionImageRepositoryImplTest.java +++ b/backend/ddang/src/test/java/com/ddang/ddang/image/infrastructure/persistence/AuctionImageRepositoryImplTest.java @@ -1,7 +1,6 @@ package com.ddang.ddang.image.infrastructure.persistence; import com.ddang.ddang.configuration.QuerydslConfiguration; -import com.ddang.ddang.image.domain.AuctionImage; import com.ddang.ddang.image.domain.repository.AuctionImageRepository; import com.ddang.ddang.image.infrastructure.persistence.fixture.AuctionImageRepositoryImplFixture; import org.junit.jupiter.api.BeforeEach; @@ -12,8 +11,6 @@ import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; import org.springframework.context.annotation.Import; -import java.util.Optional; - import static org.assertj.core.api.Assertions.assertThat; @DataJpaTest @@ -30,11 +27,20 @@ void setUp(@Autowired final JpaAuctionImageRepository jpaAuctionImageRepository) } @Test - void 경매_이미지를_아이디를_통해_조회한다() { + void 경매_이미지_이름에_해당하는_경매_이미지가_존재하면_참을_반환한다() { + // when + final boolean actual = auctionImageRepository.existsByStoreName(존재하는_경매_이미지_이름); + + // then + assertThat(actual).isTrue(); + } + + @Test + void 경매_이미지_이름에_해당하는_경매_이미지가_존재하지_않으면_거짓을_반환한다() { // when - final Optional actual = auctionImageRepository.findById(경매_이미지.getId()); + final boolean actual = auctionImageRepository.existsByStoreName(존재하지_않는_경매_이미지_이름); // then - assertThat(actual).contains(경매_이미지); + assertThat(actual).isFalse(); } } diff --git a/backend/ddang/src/test/java/com/ddang/ddang/image/infrastructure/persistence/JpaAuctionImageRepositoryTest.java b/backend/ddang/src/test/java/com/ddang/ddang/image/infrastructure/persistence/JpaAuctionImageRepositoryTest.java index 3689fd8be..f0b7af2ad 100644 --- a/backend/ddang/src/test/java/com/ddang/ddang/image/infrastructure/persistence/JpaAuctionImageRepositoryTest.java +++ b/backend/ddang/src/test/java/com/ddang/ddang/image/infrastructure/persistence/JpaAuctionImageRepositoryTest.java @@ -3,8 +3,6 @@ import com.ddang.ddang.configuration.QuerydslConfiguration; import com.ddang.ddang.image.domain.AuctionImage; import com.ddang.ddang.image.infrastructure.persistence.fixture.JpaAuctionImageRepositoryFixture; -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; @@ -12,8 +10,6 @@ import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; import org.springframework.context.annotation.Import; -import java.util.Optional; - import static org.assertj.core.api.Assertions.assertThat; @DataJpaTest @@ -22,9 +18,6 @@ @SuppressWarnings("NonAsciiCharacters") class JpaAuctionImageRepositoryTest extends JpaAuctionImageRepositoryFixture { - @PersistenceContext - EntityManager em; - @Autowired JpaAuctionImageRepository auctionImageRepository; @@ -37,27 +30,25 @@ class JpaAuctionImageRepositoryTest extends JpaAuctionImageRepositoryFixture { final AuctionImage actual = auctionImageRepository.save(auctionImage); // then - em.flush(); - em.clear(); - assertThat(actual.getId()).isPositive(); } + @Test - void 지정한_아이디에_해당하는_경매_이미지를_조회한다() { + void 경매_이미지_이름에_해당하는_경매_이미지가_존재하면_참을_반환한다() { // when - final Optional actual = auctionImageRepository.findById(경매_이미지.getId()); + final boolean actual = auctionImageRepository.existsByStoreName(존재하는_경매_이미지_이름); // then - assertThat(actual).contains(경매_이미지); + assertThat(actual).isTrue(); } @Test - void 지정한_아이디에_해당하는_경매_이미지가_없는_경우_빈_Optional을_반환한다() { + void 경매_이미지_이름에_해당하는_경매_이미지가_존재하지_않으면_거짓을_반환한다() { // when - final Optional actual = auctionImageRepository.findById(존재하지_않는_경매_이미지_아이디); + final boolean actual = auctionImageRepository.existsByStoreName(존재하지_않는_경매_이미지_이름); // then - assertThat(actual).isEmpty(); + assertThat(actual).isFalse(); } } diff --git a/backend/ddang/src/test/java/com/ddang/ddang/image/infrastructure/persistence/JpaProfileImageRepositoryTest.java b/backend/ddang/src/test/java/com/ddang/ddang/image/infrastructure/persistence/JpaProfileImageRepositoryTest.java index 59db38093..72a9e6fc6 100644 --- a/backend/ddang/src/test/java/com/ddang/ddang/image/infrastructure/persistence/JpaProfileImageRepositoryTest.java +++ b/backend/ddang/src/test/java/com/ddang/ddang/image/infrastructure/persistence/JpaProfileImageRepositoryTest.java @@ -4,8 +4,6 @@ import com.ddang.ddang.configuration.QuerydslConfiguration; import com.ddang.ddang.image.domain.ProfileImage; import com.ddang.ddang.image.infrastructure.persistence.fixture.JpaProfileImageRepositoryFixture; -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; @@ -13,8 +11,6 @@ import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; import org.springframework.context.annotation.Import; -import java.util.Optional; - import static org.assertj.core.api.Assertions.assertThat; @DataJpaTest @@ -23,9 +19,6 @@ @SuppressWarnings("NonAsciiCharacters") class JpaProfileImageRepositoryTest extends JpaProfileImageRepositoryFixture { - @PersistenceContext - EntityManager em; - @Autowired JpaProfileImageRepository profileImageRepository; @@ -37,37 +30,25 @@ class JpaProfileImageRepositoryTest extends JpaProfileImageRepositoryFixture { // when final ProfileImage actual = profileImageRepository.save(profileImage); - em.flush(); - em.clear(); - // then assertThat(actual.getId()).isPositive(); } @Test - void 지정한_아이디에_해당하는_이미지를_조회한다() { - // when - final Optional actual = profileImageRepository.findById(프로필_이미지.getId()); - - // then - assertThat(actual).contains(프로필_이미지); - } - - @Test - void 지정한_아이디에_해당하는_이미지가_없는_경우_빈_Optional을_반환한다() { + void 프로필을_이미지_이름에_해당하는_프로필_이미지가_존재하면_참을_반환한다() { // when - final Optional actual = profileImageRepository.findById(존재하지_않는_프로필_이미지_아이디); + final boolean actual = profileImageRepository.existsByStoreName(존재하는_프로필_이미지_이름); // then - assertThat(actual).isEmpty(); + assertThat(actual).isTrue(); } @Test - void 저장된_이름에_해당하는_이미지를_반환한다() { + void 프로필을_이미지_이름에_해당하는_프로필_이미지가_존재하지_않으면_참을_반환한다() { // when - final Optional actual = profileImageRepository.findByStoreName(저장된_이미지_파일명); + final boolean actual = profileImageRepository.existsByStoreName(존재하지_않는_프로필_이미지_이름); // then - assertThat(actual).contains(프로필_이미지); + assertThat(actual).isFalse(); } } diff --git a/backend/ddang/src/test/java/com/ddang/ddang/image/infrastructure/persistence/ProfileImageRepositoryImplTest.java b/backend/ddang/src/test/java/com/ddang/ddang/image/infrastructure/persistence/ProfileImageRepositoryImplTest.java index 7f733ae97..804c98876 100644 --- a/backend/ddang/src/test/java/com/ddang/ddang/image/infrastructure/persistence/ProfileImageRepositoryImplTest.java +++ b/backend/ddang/src/test/java/com/ddang/ddang/image/infrastructure/persistence/ProfileImageRepositoryImplTest.java @@ -1,7 +1,6 @@ package com.ddang.ddang.image.infrastructure.persistence; import com.ddang.ddang.configuration.QuerydslConfiguration; -import com.ddang.ddang.image.domain.ProfileImage; import com.ddang.ddang.image.domain.repository.ProfileImageRepository; import com.ddang.ddang.image.infrastructure.persistence.fixture.ProfileImageRepositoryImplFixture; import org.junit.jupiter.api.BeforeEach; @@ -12,8 +11,6 @@ import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; import org.springframework.context.annotation.Import; -import java.util.Optional; - import static org.assertj.core.api.Assertions.assertThat; @DataJpaTest @@ -30,20 +27,20 @@ void setUp(@Autowired final JpaProfileImageRepository jpaProfileImageRepository) } @Test - void 프로필을_이미지를_아이디를_통해_조회한다() { + void 프로필을_이미지_이름에_해당하는_프로필_이미지가_존재하면_참을_반환한다() { // when - final Optional actual = profileImageRepository.findById(프로필_이미지.getId()); + final boolean actual = profileImageRepository.existsByStoreName(존재하는_프로필_이미지_이름); // then - assertThat(actual).contains(프로필_이미지); + assertThat(actual).isTrue(); } @Test - void 프로필을_이미지를_저장_이미지를_통해_조회한다() { + void 프로필을_이미지_이름에_해당하는_프로필_이미지가_존재하지_않으면_참을_반환한다() { // when - final Optional actual = profileImageRepository.findByStoreName(프로필_이미지.getImage().getStoreName()); + final boolean actual = profileImageRepository.existsByStoreName(존재하지_않는_프로필_이미지_이름); // then - assertThat(actual).contains(프로필_이미지); + assertThat(actual).isFalse(); } } diff --git a/backend/ddang/src/test/java/com/ddang/ddang/image/infrastructure/persistence/fixture/AuctionImageRepositoryImplFixture.java b/backend/ddang/src/test/java/com/ddang/ddang/image/infrastructure/persistence/fixture/AuctionImageRepositoryImplFixture.java index a3a88d949..e04980bc3 100644 --- a/backend/ddang/src/test/java/com/ddang/ddang/image/infrastructure/persistence/fixture/AuctionImageRepositoryImplFixture.java +++ b/backend/ddang/src/test/java/com/ddang/ddang/image/infrastructure/persistence/fixture/AuctionImageRepositoryImplFixture.java @@ -2,29 +2,22 @@ import com.ddang.ddang.image.domain.AuctionImage; import com.ddang.ddang.image.infrastructure.persistence.JpaAuctionImageRepository; -import jakarta.persistence.EntityManager; -import jakarta.persistence.PersistenceContext; import org.junit.jupiter.api.BeforeEach; import org.springframework.beans.factory.annotation.Autowired; @SuppressWarnings("NonAsciiCharacters") public class AuctionImageRepositoryImplFixture { - @PersistenceContext - private EntityManager em; - @Autowired private JpaAuctionImageRepository jpaAuctionImageRepository; - protected AuctionImage 경매_이미지; + protected String 존재하는_경매_이미지_이름 = "경매이미지.png"; + protected String 존재하지_않는_경매_이미지_이름 = "invalid.png"; @BeforeEach void fixtureSetUp() { - 경매_이미지 = new AuctionImage("경매이미지.png", "경매이미지.png"); + final AuctionImage 경매_이미지 = new AuctionImage("경매이미지.png", 존재하는_경매_이미지_이름); jpaAuctionImageRepository.save(경매_이미지); - - em.flush(); - em.clear(); } } diff --git a/backend/ddang/src/test/java/com/ddang/ddang/image/infrastructure/persistence/fixture/JpaAuctionImageRepositoryFixture.java b/backend/ddang/src/test/java/com/ddang/ddang/image/infrastructure/persistence/fixture/JpaAuctionImageRepositoryFixture.java index a92e8ec51..2f4a7d66d 100644 --- a/backend/ddang/src/test/java/com/ddang/ddang/image/infrastructure/persistence/fixture/JpaAuctionImageRepositoryFixture.java +++ b/backend/ddang/src/test/java/com/ddang/ddang/image/infrastructure/persistence/fixture/JpaAuctionImageRepositoryFixture.java @@ -18,13 +18,13 @@ public class JpaAuctionImageRepositoryFixture { protected String 업로드_이미지_파일명 = "uploadName"; protected String 저장된_이미지_파일명 = "storeName"; - protected Long 존재하지_않는_경매_이미지_아이디 = -999L; - protected AuctionImage 경매_이미지; + protected String 존재하는_경매_이미지_이름 = "경매이미지.png"; + protected String 존재하지_않는_경매_이미지_이름 = "invalid.png"; @BeforeEach void setUp() { - 경매_이미지 = new AuctionImage(업로드_이미지_파일명, 저장된_이미지_파일명); + final AuctionImage 경매_이미지 = new AuctionImage("경매이미지.png", 존재하는_경매_이미지_이름); auctionImageRepository.save(경매_이미지); diff --git a/backend/ddang/src/test/java/com/ddang/ddang/image/infrastructure/persistence/fixture/JpaProfileImageRepositoryFixture.java b/backend/ddang/src/test/java/com/ddang/ddang/image/infrastructure/persistence/fixture/JpaProfileImageRepositoryFixture.java index 1bf175301..2a855e0ed 100644 --- a/backend/ddang/src/test/java/com/ddang/ddang/image/infrastructure/persistence/fixture/JpaProfileImageRepositoryFixture.java +++ b/backend/ddang/src/test/java/com/ddang/ddang/image/infrastructure/persistence/fixture/JpaProfileImageRepositoryFixture.java @@ -18,13 +18,12 @@ public class JpaProfileImageRepositoryFixture { protected String 업로드_이미지_파일명 = "uploadName"; protected String 저장된_이미지_파일명 = "storeName"; - protected Long 존재하지_않는_프로필_이미지_아이디 = -999L; - - protected ProfileImage 프로필_이미지; + protected String 존재하는_프로필_이미지_이름 = "프로필이미지.png"; + protected String 존재하지_않는_프로필_이미지_이름 = "invalid.png"; @BeforeEach void setUp() { - 프로필_이미지 = new ProfileImage("uploadName", "storeName"); + final ProfileImage 프로필_이미지 = new ProfileImage("프로필이미지.png", 존재하는_프로필_이미지_이름); profileImageRepository.save(프로필_이미지); diff --git a/backend/ddang/src/test/java/com/ddang/ddang/image/infrastructure/persistence/fixture/ProfileImageRepositoryImplFixture.java b/backend/ddang/src/test/java/com/ddang/ddang/image/infrastructure/persistence/fixture/ProfileImageRepositoryImplFixture.java index 719737f47..04a5ce2cd 100644 --- a/backend/ddang/src/test/java/com/ddang/ddang/image/infrastructure/persistence/fixture/ProfileImageRepositoryImplFixture.java +++ b/backend/ddang/src/test/java/com/ddang/ddang/image/infrastructure/persistence/fixture/ProfileImageRepositoryImplFixture.java @@ -2,29 +2,22 @@ import com.ddang.ddang.image.domain.ProfileImage; import com.ddang.ddang.image.infrastructure.persistence.JpaProfileImageRepository; -import jakarta.persistence.EntityManager; -import jakarta.persistence.PersistenceContext; import org.junit.jupiter.api.BeforeEach; import org.springframework.beans.factory.annotation.Autowired; @SuppressWarnings("NonAsciiCharacters") public class ProfileImageRepositoryImplFixture { - @PersistenceContext - private EntityManager em; - @Autowired private JpaProfileImageRepository profileImageRepository; - protected ProfileImage 프로필_이미지; + protected String 존재하는_프로필_이미지_이름 = "프로필이미지.png"; + protected String 존재하지_않는_프로필_이미지_이름 = "invalid.png"; @BeforeEach void fixtureSetUp() { - 프로필_이미지 = new ProfileImage("프로필이미지.png", "프로필이미지.png"); + final ProfileImage 프로필_이미지 = new ProfileImage("프로필이미지.png", 존재하는_프로필_이미지_이름); profileImageRepository.save(프로필_이미지); - - em.flush(); - em.clear(); } } diff --git a/backend/ddang/src/test/java/com/ddang/ddang/image/presentation/ImageControllerTest.java b/backend/ddang/src/test/java/com/ddang/ddang/image/presentation/ImageControllerTest.java index 2b5a9978e..178ac5a21 100644 --- a/backend/ddang/src/test/java/com/ddang/ddang/image/presentation/ImageControllerTest.java +++ b/backend/ddang/src/test/java/com/ddang/ddang/image/presentation/ImageControllerTest.java @@ -12,7 +12,7 @@ import java.net.MalformedURLException; -import static org.mockito.ArgumentMatchers.anyLong; +import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.BDDMockito.given; import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; @@ -35,10 +35,10 @@ void setUp() { @Test void 지정한_사용자_아이디에_대한_사용자_이미지를_조회한다() throws Exception { // given - given(imageService.readProfileImage(anyLong())).willReturn(이미지_파일_리소스); + given(imageService.readProfileImage(anyString())).willReturn(이미지_파일_리소스); // when & then - mockMvc.perform(RestDocumentationRequestBuilders.get("/users/images/{id}", 프로필_이미지_아이디)) + mockMvc.perform(RestDocumentationRequestBuilders.get("/users/images/{storeName}", 프로필_이미지_이름)) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.IMAGE_JPEG)) .andExpect(content().bytes(이미지_파일_바이트)); @@ -47,10 +47,10 @@ void setUp() { @Test void 사용자_이미지_조회시_지정한_아이디에_대한_이미지가_없는_경우_404를_반환한다() throws Exception { // given - given(imageService.readProfileImage(anyLong())).willThrow(new ImageNotFoundException("지정한 이미지를 찾을 수 없습니다.")); + given(imageService.readProfileImage(anyString())).willThrow(new ImageNotFoundException("지정한 이미지를 찾을 수 없습니다.")); // when & then - mockMvc.perform(RestDocumentationRequestBuilders.get("/users/images/{id}", 존재하지_않는_프로필_이미지_아이디)) + mockMvc.perform(RestDocumentationRequestBuilders.get("/users/images/{storeName}", 존재하지_않는_프로필_이미지_이름)) .andExpect(status().isNotFound()) .andExpect(jsonPath("$.message").exists()); } @@ -58,10 +58,10 @@ void setUp() { @Test void 사용자_이미지_조회시_유효한_프로토콜이나_URL이_아닌_경우_500을_반환한다() throws Exception { // given - given(imageService.readProfileImage(anyLong())).willThrow(new MalformedURLException()); + given(imageService.readProfileImage(anyString())).willThrow(new MalformedURLException()); // when & then - mockMvc.perform(RestDocumentationRequestBuilders.get("/users/images/{id}", 프로필_이미지_아이디)) + mockMvc.perform(RestDocumentationRequestBuilders.get("/users/images/{storeName}", 프로필_이미지_이름)) .andExpect(status().isInternalServerError()) .andExpect(jsonPath("$.message").exists()); } @@ -69,10 +69,10 @@ void setUp() { @Test void 지정한_아이디에_대한_경매_이미지를_조회한다() throws Exception { // given - given(imageService.readAuctionImage(anyLong())).willReturn(이미지_파일_리소스); + given(imageService.readAuctionImage(anyString())).willReturn(이미지_파일_리소스); // when & then - mockMvc.perform(RestDocumentationRequestBuilders.get("/auctions/images/{id}", 경매_이미지_아이디)) + mockMvc.perform(RestDocumentationRequestBuilders.get("/auctions/images/{storeName}", 경매_이미지_이름)) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.IMAGE_JPEG)) .andExpect(content().bytes(이미지_파일_바이트)); @@ -81,10 +81,10 @@ void setUp() { @Test void 경매_이미지_조회시_지정한_아이디에_대한_이미지가_없는_경우_404를_반환한다() throws Exception { // given - given(imageService.readAuctionImage(anyLong())).willThrow(new ImageNotFoundException("지정한 이미지를 찾을 수 없습니다.")); + given(imageService.readAuctionImage(anyString())).willThrow(new ImageNotFoundException("지정한 이미지를 찾을 수 없습니다.")); // when & then - mockMvc.perform(RestDocumentationRequestBuilders.get("/auctions/images/{id}", 존재하지_않는_경매_이미지_아이디)) + mockMvc.perform(RestDocumentationRequestBuilders.get("/auctions/images/{storeName}", 존재하지_않는_경매_이미지_이름)) .andExpect(status().isNotFound()) .andExpect(jsonPath("$.message").exists()); } @@ -92,10 +92,10 @@ void setUp() { @Test void 경매_이미지_조회시_유효한_프로토콜이나_URL이_아닌_경우_500을_반환한다() throws Exception { // given - given(imageService.readAuctionImage(anyLong())).willThrow(new MalformedURLException()); + given(imageService.readAuctionImage(anyString())).willThrow(new MalformedURLException()); // when & then - mockMvc.perform(RestDocumentationRequestBuilders.get("/auctions/images/{id}", 경매_이미지_아이디)) + mockMvc.perform(RestDocumentationRequestBuilders.get("/auctions/images/{storeName}", 경매_이미지_이름)) .andExpect(status().isInternalServerError()) .andExpect(jsonPath("$.message").exists()); } diff --git a/backend/ddang/src/test/java/com/ddang/ddang/image/presentation/fixture/ImageControllerFixture.java b/backend/ddang/src/test/java/com/ddang/ddang/image/presentation/fixture/ImageControllerFixture.java index dbac712ed..9fe6ed49e 100644 --- a/backend/ddang/src/test/java/com/ddang/ddang/image/presentation/fixture/ImageControllerFixture.java +++ b/backend/ddang/src/test/java/com/ddang/ddang/image/presentation/fixture/ImageControllerFixture.java @@ -9,8 +9,8 @@ public class ImageControllerFixture extends CommonControllerSliceTest { protected byte[] 이미지_파일_바이트 = "이것은 이미지 파일의 바이트 코드입니다.".getBytes(); protected Resource 이미지_파일_리소스 = new ByteArrayResource(이미지_파일_바이트); - protected Long 프로필_이미지_아이디 = 1L; - protected Long 존재하지_않는_프로필_이미지_아이디 = -999L; - protected Long 경매_이미지_아이디 = 1L; - protected Long 존재하지_않는_경매_이미지_아이디 = -999L; + protected String 프로필_이미지_이름 = "profile_image.png"; + protected String 존재하지_않는_프로필_이미지_이름 = "invalid_profile_image.png"; + protected String 경매_이미지_이름 = "auction_image.png"; + protected String 존재하지_않는_경매_이미지_이름 = "invalid_auction_image.png"; } From f66f23e32aabc2f3de4374ec7b3d47e1c275aa97 Mon Sep 17 00:00:00 2001 From: kwonyj1022 Date: Thu, 19 Oct 2023 03:06:58 +0900 Subject: [PATCH 12/15] =?UTF-8?q?docs:=20=EB=AC=B8=EC=84=9C=20=EC=B5=9C?= =?UTF-8?q?=EC=8B=A0=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/static/docs/docs.html | 106 +++++++++--------- 1 file changed, 53 insertions(+), 53 deletions(-) diff --git a/backend/ddang/src/main/resources/static/docs/docs.html b/backend/ddang/src/main/resources/static/docs/docs.html index bf5f56834..1fef3bc53 100644 --- a/backend/ddang/src/main/resources/static/docs/docs.html +++ b/backend/ddang/src/main/resources/static/docs/docs.html @@ -914,7 +914,7 @@

요청

-

Unresolved directive in docs.adoc - include::/Users/labtop/intellij/test-ddang/2023-3-ddang/backend/ddang/build/generated-snippets/authentication-controller-test/ouath2-type과_access-token과_refresh-token을_전달하면_탈퇴한다/path-parameters.adoc[]

+

Unresolved directive in docs.adoc - include::/Users/kwon-yejin/GitHub/2023-3-ddang/backend/ddang/build/generated-snippets/authentication-controller-test/ouath2-type과_access-token과_refresh-token을_전달하면_탈퇴한다/path-parameters.adoc[]

@@ -990,7 +990,7 @@

응답

{ "name" : "사용자1", - "profileImage" : "http://localhost:8080/users/images/1", + "profileImage" : "http://localhost:8080/users/images/profile_image.png", "reliability" : 4.6 } @@ -1049,7 +1049,7 @@

응답

{ "name" : "updateName", - "profileImage" : "http://localhost:8080/users/images/1", + "profileImage" : "http://localhost:8080/users/images/profile_image.png", "reliability" : 4.6 } @@ -1453,7 +1453,7 @@

요청

Content-Disposition: form-data; name=request; filename=request Content-Type: application/json -{"title":"제목","description":"내용","bidUnit":1000,"startPrice":1000,"closingTime":"2023-10-18T21:12:06.450773","subCategoryId":2,"thirdRegionIds":[3]} +{"title":"제목","description":"내용","bidUnit":1000,"startPrice":1000,"closingTime":"2023-10-22T03:05:41.988992","subCategoryId":2,"thirdRegionIds":[3]} --6o2knFse3p53ty9dmcQvWAIx1zInP11uCfbm-- @@ -1509,7 +1509,7 @@

응답

{ "id" : 1, "title" : "제목", - "image" : "http://localhost:8080/auctions/images/1", + "image" : "http://localhost:8080/auctions/images/auction_image.png", "auctionPrice" : 1000, "status" : "UNBIDDEN", "auctioneerCount" : 0 @@ -1627,14 +1627,14 @@

응답

"auctions" : [ { "id" : 2, "title" : "경매 상품 1", - "image" : "http://localhost:8080/auctions/images/1", + "image" : "http://localhost:8080/auctions/images/auction_image.png", "auctionPrice" : 1000, "status" : "UNBIDDEN", "auctioneerCount" : 2 }, { "id" : 1, "title" : "경매 상품 1", - "image" : "http://localhost:8080/auctions/images/1", + "image" : "http://localhost:8080/auctions/images/auction_image.png", "auctionPrice" : 1000, "status" : "UNBIDDEN", "auctioneerCount" : 2 @@ -1769,14 +1769,14 @@

응답

"auctions" : [ { "id" : 2, "title" : "경매 상품 2", - "image" : "http://localhost:8080/auctions/images/1", + "image" : "http://localhost:8080/auctions/images/auction_image.png", "auctionPrice" : 1000, "status" : "UNBIDDEN", "auctioneerCount" : 2 }, { "id" : 1, "title" : "경매 상품 1", - "image" : "http://localhost:8080/auctions/images/1", + "image" : "http://localhost:8080/auctions/images/auction_image.png", "auctionPrice" : 1000, "status" : "UNBIDDEN", "auctioneerCount" : 2 @@ -1911,14 +1911,14 @@

응답

"auctions" : [ { "id" : 2, "title" : "경매 상품 2", - "image" : "http://localhost:8080/auctions/images/1", + "image" : "http://localhost:8080/auctions/images/auction_image.png", "auctionPrice" : 1000, "status" : "UNBIDDEN", "auctioneerCount" : 2 }, { "id" : 1, "title" : "경매 상품 1", - "image" : "http://localhost:8080/auctions/images/1", + "image" : "http://localhost:8080/auctions/images/auction_image.png", "auctionPrice" : 1000, "status" : "UNBIDDEN", "auctioneerCount" : 2 @@ -2049,7 +2049,7 @@

응답

{ "auction" : { "id" : 1, - "images" : [ "http://localhost:8080/auctions/images/1" ], + "images" : [ "http://localhost:8080/auctions/images/auction_image.png" ], "title" : "경매 상품 1", "category" : { "main" : "main", @@ -2060,8 +2060,8 @@

응답

"lastBidPrice" : null, "status" : "UNBIDDEN", "bidUnit" : 1000, - "registerTime" : "2023-10-15T21:12:06", - "closingTime" : "2023-10-15T21:12:06", + "registerTime" : "2023-10-19T03:05:42", + "closingTime" : "2023-10-19T03:05:42", "directRegions" : [ { "first" : "서울특별시", "second" : "강서구", @@ -2071,7 +2071,7 @@

응답

}, "seller" : { "id" : 1, - "image" : "http://localhost:8080/users/images/1", + "image" : "http://localhost:8080/users/images/profile_image.png", "nickname" : "판매자", "reliability" : 3.5 }, @@ -2587,9 +2587,9 @@

응답

"writer" : { "id" : 1, "name" : "질문자", - "image" : "http://localhost:8080/users/images/1" + "image" : "http://localhost:8080/users/images/profile_image1.png" }, - "createdTime" : "2023-10-15T21:12:06", + "createdTime" : "2023-10-19T03:05:42", "content" : "질문1", "isQuestioner" : false }, @@ -2598,9 +2598,9 @@

응답

"writer" : { "id" : 2, "name" : "판매자", - "image" : "http://localhost:8080/users/images/2" + "image" : "http://localhost:8080/users/images/profile_image2.png" }, - "createdTime" : "2023-10-15T21:12:06", + "createdTime" : "2023-10-19T03:05:42", "content" : "답변1" } }, { @@ -2609,9 +2609,9 @@

응답

"writer" : { "id" : 1, "name" : "질문자", - "image" : "http://localhost:8080/users/images/1" + "image" : "http://localhost:8080/users/images/profile_image1.png" }, - "createdTime" : "2023-10-15T21:12:06", + "createdTime" : "2023-10-19T03:05:42", "content" : "질문2", "isQuestioner" : false }, @@ -2620,9 +2620,9 @@

응답

"writer" : { "id" : 2, "name" : "판매자", - "image" : "http://localhost:8080/users/images/2" + "image" : "http://localhost:8080/users/images/profile_image2.png" }, - "createdTime" : "2023-10-15T21:12:06", + "createdTime" : "2023-10-19T03:05:42", "content" : "답변1" } } ] @@ -2833,14 +2833,14 @@

응답

[ { "name" : "사용자1", - "profileImage" : "http://localhost:8080/users/images/1", + "profileImage" : "http://localhost:8080/users/images/profile_image1.png", "price" : 10000, - "bidTime" : "2023-10-15T21:12:13" + "bidTime" : "2023-10-19T03:05:47" }, { "name" : "사용자2", - "profileImage" : "http://localhost:8080/users/images/2", + "profileImage" : "http://localhost:8080/users/images/profile_image2.png", "price" : 12000, - "bidTime" : "2023-10-15T21:12:13" + "bidTime" : "2023-10-19T03:05:47" } ] @@ -3025,16 +3025,16 @@

응답

"chatPartner" : { "id" : 2, "name" : "구매자1", - "profileImage" : "http://localhost:8080/users/images/2" + "profileImage" : "http://localhost:8080/users/images/profile_image.png" }, "auction" : { "id" : 1, "title" : "경매1", - "image" : "http://localhost:8080/auctions/images/1", + "image" : "http://localhost:8080/auctions/images/auction_image.png", "price" : 10000 }, "lastMessage" : { - "createdAt" : "2023-10-15T21:12:16", + "createdAt" : "2023-10-19T03:05:49", "contents" : "메시지1" }, "isChatAvailable" : true @@ -3043,16 +3043,16 @@

응답

"chatPartner" : { "id" : 3, "name" : "구매자2", - "profileImage" : "http://localhost:8080/users/images/3" + "profileImage" : "http://localhost:8080/users/images/profile_image.png" }, "auction" : { "id" : 2, "title" : "경매2", - "image" : "http://localhost:8080/auctions/images/1", + "image" : "http://localhost:8080/auctions/images/auction_image.png", "price" : 20000 }, "lastMessage" : { - "createdAt" : "2023-10-15T21:12:16", + "createdAt" : "2023-10-19T03:05:49", "contents" : "메시지2" }, "isChatAvailable" : true @@ -3213,12 +3213,12 @@

응답

"chatPartner" : { "id" : 1, "name" : "판매자", - "profileImage" : "http://localhost:8080/users/images/1" + "profileImage" : "http://localhost:8080/users/images/profile_image.png" }, "auction" : { "id" : 1, "title" : "경매1", - "image" : "http://localhost:8080/auctions/images/1", + "image" : "http://localhost:8080/auctions/images/auction_image.png", "price" : 10000 }, "isChatAvailable" : true @@ -3490,7 +3490,7 @@

응답

[ { "id" : 1, - "createdAt" : "2023-10-15T21:12:16", + "createdAt" : "2023-10-19T03:05:49", "isMyMessage" : true, "contents" : "메시지내용" } ] @@ -3640,7 +3640,7 @@

응답

"id" : 2, "name" : "회원1" }, - "createdTime" : "2023-10-15T21:12:26", + "createdTime" : "2023-10-19T03:05:57", "auction" : { "id" : 1, "title" : "제목" @@ -3652,7 +3652,7 @@

응답

"id" : 3, "name" : "회원2" }, - "createdTime" : "2023-10-15T21:12:26", + "createdTime" : "2023-10-19T03:05:57", "auction" : { "id" : 1, "title" : "제목" @@ -3664,7 +3664,7 @@

응답

"id" : 4, "name" : "회원3" }, - "createdTime" : "2023-10-15T21:12:26", + "createdTime" : "2023-10-19T03:05:57", "auction" : { "id" : 1, "title" : "제목" @@ -3828,7 +3828,7 @@

응답

"id" : 2, "name" : "구매자1" }, - "createdTime" : "2023-10-15T21:12:27", + "createdTime" : "2023-10-19T03:05:57", "chatRoom" : { "id" : 1 }, @@ -3839,7 +3839,7 @@

응답

"id" : 3, "name" : "구매자2" }, - "createdTime" : "2023-10-15T21:12:27", + "createdTime" : "2023-10-19T03:05:57", "chatRoom" : { "id" : 1 }, @@ -3850,7 +3850,7 @@

응답

"id" : 3, "name" : "구매자2" }, - "createdTime" : "2023-10-15T21:12:27", + "createdTime" : "2023-10-19T03:05:57", "chatRoom" : { "id" : 1 }, @@ -4014,7 +4014,7 @@

응답

"id" : 2, "name" : "구매자1" }, - "createdTime" : "2023-10-15T21:12:27", + "createdTime" : "2023-10-19T03:05:58", "question" : { "id" : 1 }, @@ -4025,7 +4025,7 @@

응답

"id" : 2, "name" : "구매자1" }, - "createdTime" : "2023-10-15T21:12:27", + "createdTime" : "2023-10-19T03:05:58", "question" : { "id" : 2 }, @@ -4036,7 +4036,7 @@

응답

"id" : 2, "name" : "구매자1" }, - "createdTime" : "2023-10-15T21:12:27", + "createdTime" : "2023-10-19T03:05:58", "question" : { "id" : 3 }, @@ -4200,7 +4200,7 @@

응답

"id" : 2, "name" : "구매자1" }, - "createdTime" : "2023-10-15T21:12:27", + "createdTime" : "2023-10-19T03:05:58", "answer" : { "id" : 1 }, @@ -4211,7 +4211,7 @@

응답

"id" : 2, "name" : "구매자1" }, - "createdTime" : "2023-10-15T21:12:27", + "createdTime" : "2023-10-19T03:05:58", "answer" : { "id" : 2 }, @@ -4222,7 +4222,7 @@

응답

"id" : 2, "name" : "구매자1" }, - "createdTime" : "2023-10-15T21:12:27", + "createdTime" : "2023-10-19T03:05:58", "answer" : { "id" : 3 }, @@ -4554,21 +4554,21 @@

응답

"writer" : { "id" : 2, "name" : "판매자2", - "profileImage" : "http://localhost:8080/users/images/2" + "profileImage" : "http://localhost:8080/users/images/profile_image2.png" }, "content" : "친절하다.", "score" : 5.0, - "createdTime" : "2023-10-15T21:12:29" + "createdTime" : "2023-10-19T03:05:58" }, { "id" : 2, "writer" : { "id" : 1, "name" : "판매자1", - "profileImage" : "http://localhost:8080/users/images/1" + "profileImage" : "http://localhost:8080/users/images/profile_image1.png" }, "content" : "친절하다.", "score" : 5.0, - "createdTime" : "2023-10-15T21:12:29" + "createdTime" : "2023-10-19T03:05:58" } ] @@ -4726,7 +4726,7 @@

응답

From d56bda4607aea9633509110ebae21f6be42238bb Mon Sep 17 00:00:00 2001 From: kwonyj1022 Date: Fri, 3 Nov 2023 11:13:39 +0900 Subject: [PATCH 13/15] =?UTF-8?q?style:=20=EA=B0=9C=ED=96=89=20=EC=88=98?= =?UTF-8?q?=EC=A0=95=20=EB=B0=8F=20=EB=88=84=EB=9D=BD=EB=90=9C=20final=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ddang/ddang/image/presentation/ImageController.java | 8 ++++---- .../ddang/user/domain/repository/UserRepository.java | 1 + .../persistence/JpaAuctionImageRepositoryTest.java | 1 - 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/backend/ddang/src/main/java/com/ddang/ddang/image/presentation/ImageController.java b/backend/ddang/src/main/java/com/ddang/ddang/image/presentation/ImageController.java index d16838244..12a12e401 100644 --- a/backend/ddang/src/main/java/com/ddang/ddang/image/presentation/ImageController.java +++ b/backend/ddang/src/main/java/com/ddang/ddang/image/presentation/ImageController.java @@ -20,20 +20,20 @@ public class ImageController { private final ImageService imageService; @GetMapping("/users/images/{storeName}") - public ResponseEntity downloadProfileImage(@PathVariable String storeName) throws MalformedURLException { + public ResponseEntity downloadProfileImage(@PathVariable final String storeName) throws MalformedURLException { final Resource resource = imageService.readProfileImage(storeName); - HttpHeaders headers = new HttpHeaders(); + final HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.IMAGE_JPEG); return new ResponseEntity<>(resource, headers, HttpStatus.OK); } @GetMapping("/auctions/images/{storeName}") - public ResponseEntity downloadAuctionImage(@PathVariable String storeName) throws MalformedURLException { + public ResponseEntity downloadAuctionImage(@PathVariable final String storeName) throws MalformedURLException { final Resource resource = imageService.readAuctionImage(storeName); - HttpHeaders headers = new HttpHeaders(); + final HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.IMAGE_JPEG); return new ResponseEntity<>(resource, headers, HttpStatus.OK); diff --git a/backend/ddang/src/main/java/com/ddang/ddang/user/domain/repository/UserRepository.java b/backend/ddang/src/main/java/com/ddang/ddang/user/domain/repository/UserRepository.java index 8fb2f3561..c424016bb 100644 --- a/backend/ddang/src/main/java/com/ddang/ddang/user/domain/repository/UserRepository.java +++ b/backend/ddang/src/main/java/com/ddang/ddang/user/domain/repository/UserRepository.java @@ -9,6 +9,7 @@ public interface UserRepository { User save(final User user); Optional findById(final Long id); + Optional findByIdWithProfileImage(final Long id); boolean existsById(final Long id); diff --git a/backend/ddang/src/test/java/com/ddang/ddang/image/infrastructure/persistence/JpaAuctionImageRepositoryTest.java b/backend/ddang/src/test/java/com/ddang/ddang/image/infrastructure/persistence/JpaAuctionImageRepositoryTest.java index f0b7af2ad..809345b48 100644 --- a/backend/ddang/src/test/java/com/ddang/ddang/image/infrastructure/persistence/JpaAuctionImageRepositoryTest.java +++ b/backend/ddang/src/test/java/com/ddang/ddang/image/infrastructure/persistence/JpaAuctionImageRepositoryTest.java @@ -33,7 +33,6 @@ class JpaAuctionImageRepositoryTest extends JpaAuctionImageRepositoryFixture { assertThat(actual.getId()).isPositive(); } - @Test void 경매_이미지_이름에_해당하는_경매_이미지가_존재하면_참을_반환한다() { // when From e5e8cadcc7823bbc039d9bc27a8dd16376ce5168 Mon Sep 17 00:00:00 2001 From: kwonyj1022 Date: Fri, 3 Nov 2023 11:25:59 +0900 Subject: [PATCH 14/15] =?UTF-8?q?rename:=20test=EC=97=90=20=EC=82=AC?= =?UTF-8?q?=EC=9A=A9=EB=90=98=EB=8A=94=20fixture=20=ED=81=B4=EB=9E=98?= =?UTF-8?q?=EC=8A=A4=20=EC=9D=B4=EB=A6=84=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../image/application/util/ImageStoreNameProcessorTest.java | 4 ++-- ...cessorFixture.java => ImageStoreNameProcessorFixture.java} | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) rename backend/ddang/src/test/java/com/ddang/ddang/image/application/util/fixture/{ImageIdProcessorFixture.java => ImageStoreNameProcessorFixture.java} (95%) diff --git a/backend/ddang/src/test/java/com/ddang/ddang/image/application/util/ImageStoreNameProcessorTest.java b/backend/ddang/src/test/java/com/ddang/ddang/image/application/util/ImageStoreNameProcessorTest.java index 271199c23..6f3b80589 100644 --- a/backend/ddang/src/test/java/com/ddang/ddang/image/application/util/ImageStoreNameProcessorTest.java +++ b/backend/ddang/src/test/java/com/ddang/ddang/image/application/util/ImageStoreNameProcessorTest.java @@ -1,6 +1,6 @@ package com.ddang.ddang.image.application.util; -import com.ddang.ddang.image.application.util.fixture.ImageIdProcessorFixture; +import com.ddang.ddang.image.application.util.fixture.ImageStoreNameProcessorFixture; import org.junit.jupiter.api.DisplayNameGeneration; import org.junit.jupiter.api.DisplayNameGenerator; import org.junit.jupiter.api.Test; @@ -10,7 +10,7 @@ @DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class) @SuppressWarnings("NonAsciiCharacters") -class ImageStoreNameProcessorTest extends ImageIdProcessorFixture { +class ImageStoreNameProcessorTest extends ImageStoreNameProcessorFixture { @Test void 경매_이미지가_null이_아니라면_경매_이미지_아이디를_반환한다() { diff --git a/backend/ddang/src/test/java/com/ddang/ddang/image/application/util/fixture/ImageIdProcessorFixture.java b/backend/ddang/src/test/java/com/ddang/ddang/image/application/util/fixture/ImageStoreNameProcessorFixture.java similarity index 95% rename from backend/ddang/src/test/java/com/ddang/ddang/image/application/util/fixture/ImageIdProcessorFixture.java rename to backend/ddang/src/test/java/com/ddang/ddang/image/application/util/fixture/ImageStoreNameProcessorFixture.java index 2da10ada3..d4c67a8f8 100644 --- a/backend/ddang/src/test/java/com/ddang/ddang/image/application/util/fixture/ImageIdProcessorFixture.java +++ b/backend/ddang/src/test/java/com/ddang/ddang/image/application/util/fixture/ImageStoreNameProcessorFixture.java @@ -7,7 +7,7 @@ import static org.mockito.Mockito.mock; @SuppressWarnings("NonAsciiCharacters") -public class ImageIdProcessorFixture { +public class ImageStoreNameProcessorFixture { protected AuctionImage 경매_이미지 = mock(AuctionImage.class); protected AuctionImage null인_경매_이미지 = null; From beebe844fe21cb64f91ee8de129353dab521972c Mon Sep 17 00:00:00 2001 From: kwonyj1022 Date: Fri, 17 Nov 2023 16:23:23 +0900 Subject: [PATCH 15/15] =?UTF-8?q?ci:=20=EC=B6=A9=EB=8F=8C=20=ED=95=B4?= =?UTF-8?q?=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/ChatRoomControllerTest.java | 24 +++++++------------ .../fixture/ChatRoomControllerFixture.java | 10 ++++---- 2 files changed, 13 insertions(+), 21 deletions(-) diff --git a/backend/ddang/src/test/java/com/ddang/ddang/chat/presentation/ChatRoomControllerTest.java b/backend/ddang/src/test/java/com/ddang/ddang/chat/presentation/ChatRoomControllerTest.java index d0f948c66..5d9f61dcb 100644 --- a/backend/ddang/src/test/java/com/ddang/ddang/chat/presentation/ChatRoomControllerTest.java +++ b/backend/ddang/src/test/java/com/ddang/ddang/chat/presentation/ChatRoomControllerTest.java @@ -241,20 +241,14 @@ void setUp() { .andExpectAll( status().isOk(), jsonPath("$.[0].id", is(조회용_채팅방1.id()), Long.class), - jsonPath("$.[0].chatPartner.name", is(조회용_채팅방1.partnerDto() - .name())), - jsonPath("$.[0].auction.title", is(조회용_채팅방1.auctionDto() - .title())), - jsonPath("$.[0].lastMessage.contents", is(조회용_채팅방1.lastMessageDto() - .contents())), + jsonPath("$.[0].chatPartner.name", is(조회용_채팅방1.partnerDto().name())), + jsonPath("$.[0].auction.title", is(조회용_채팅방1.auctionDto().title())), + jsonPath("$.[0].lastMessage.contents", is(조회용_채팅방1.lastMessageDto().contents())), jsonPath("$.[0].unreadMessageCount", is(조회용_채팅방1.unreadMessageCount()), Long.class), jsonPath("$.[1].id", is(조회용_채팅방2.id()), Long.class), - jsonPath("$.[1].chatPartner.name", is(조회용_채팅방2.partnerDto() - .name())), - jsonPath("$.[1].auction.title", is(조회용_채팅방2.auctionDto() - .title())), - jsonPath("$.[1].lastMessage.contents", is(조회용_채팅방2.lastMessageDto() - .contents())), + jsonPath("$.[1].chatPartner.name", is(조회용_채팅방2.partnerDto().name())), + jsonPath("$.[1].auction.title", is(조회용_채팅방2.auctionDto().title())), + jsonPath("$.[1].lastMessage.contents", is(조회용_채팅방2.lastMessageDto().contents())), jsonPath("$.[1].unreadMessageCount", is(조회용_채팅방1.unreadMessageCount()), Long.class) ); readAllParticipatingChatRooms_문서화(resultActions); @@ -288,10 +282,8 @@ void setUp() { .andExpectAll( status().isOk(), jsonPath("$.id", is(조회용_참가중인_채팅방.id()), Long.class), - jsonPath("$.chatPartner.name", is(조회용_참가중인_채팅방.partnerDto() - .name())), - jsonPath("$.auction.title", is(조회용_참가중인_채팅방.auctionDto() - .title())) + jsonPath("$.chatPartner.name", is(조회용_참가중인_채팅방.partnerDto().name())), + jsonPath("$.auction.title", is(조회용_참가중인_채팅방.auctionDto().title())) ); readChatRoom_문서화(resultActions); } diff --git a/backend/ddang/src/test/java/com/ddang/ddang/chat/presentation/fixture/ChatRoomControllerFixture.java b/backend/ddang/src/test/java/com/ddang/ddang/chat/presentation/fixture/ChatRoomControllerFixture.java index 6d83db0e4..39e081602 100644 --- a/backend/ddang/src/test/java/com/ddang/ddang/chat/presentation/fixture/ChatRoomControllerFixture.java +++ b/backend/ddang/src/test/java/com/ddang/ddang/chat/presentation/fixture/ChatRoomControllerFixture.java @@ -18,11 +18,11 @@ public class ChatRoomControllerFixture extends CommonControllerSliceTest { private Long 탈퇴한_사용자_아이디 = 5L; protected PrivateClaims 사용자_ID_클레임 = new PrivateClaims(1L); - protected ReadUserInChatRoomDto 판매자 = new ReadUserInChatRoomDto(1L, "판매자", 1L, 5.0d, false); - private ReadUserInChatRoomDto 구매자1 = new ReadUserInChatRoomDto(2L, "구매자1", 2L, 5.0d, false); - private ReadUserInChatRoomDto 구매자2 = new ReadUserInChatRoomDto(3L, "구매자2", 3L, 5.0d, false); - private ReadAuctionInChatRoomDto 조회용_경매1 = new ReadAuctionInChatRoomDto(1L, "경매1", 10_000, 1L); - private ReadAuctionInChatRoomDto 조회용_경매2 = new ReadAuctionInChatRoomDto(2L, "경매2", 20_000, 1L); + protected ReadUserInChatRoomDto 판매자 = new ReadUserInChatRoomDto(1L, "판매자", "profileImage1.png", 5.0d, false); + private ReadUserInChatRoomDto 구매자1 = new ReadUserInChatRoomDto(2L, "구매자1", "profileImage2.png", 5.0d, false); + private ReadUserInChatRoomDto 구매자2 = new ReadUserInChatRoomDto(3L, "구매자2", "profileImage3.png", 5.0d, false); + private ReadAuctionInChatRoomDto 조회용_경매1 = new ReadAuctionInChatRoomDto(1L, "경매1", 10_000, "auctionImage1.png"); + private ReadAuctionInChatRoomDto 조회용_경매2 = new ReadAuctionInChatRoomDto(2L, "경매2", 20_000, "auctionImage2.png"); protected ReadChatRoomWithLastMessageDto 조회용_채팅방1 = new ReadChatRoomWithLastMessageDto(1L, 조회용_경매1, 구매자1, new ReadLastMessageDto(1L, LocalDateTime.now(), 판매자, 구매자1, "메시지1"), 1L, true); protected ReadChatRoomWithLastMessageDto 조회용_채팅방2 = new ReadChatRoomWithLastMessageDto(2L, 조회용_경매2, 구매자2, new ReadLastMessageDto(1L, LocalDateTime.now(), 판매자, 구매자2, "메시지2"), 1L, true); protected CreateMessageRequest 메시지_생성_요청 = new CreateMessageRequest(1L, "메시지 내용");