From 0c4f517bb3ade8779611ca902792e1ac8c978295 Mon Sep 17 00:00:00 2001 From: Junyong Lee Date: Fri, 31 Jan 2025 16:18:44 +0900 Subject: [PATCH] :bug: Fix Service(Image, Article, Feed, Auction) to get PresignedUrl with no delay --- README.md | 2 +- .../karrot/article/service/ArticleService.kt | 2 +- .../karrot/auction/service/AuctionService.kt | 3 +-- .../karrot/feed/service/FeedService.kt | 2 +- .../karrot/image/service/ImageService.kt | 19 ++++++++++--------- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 4d8a7a6..add4fa1 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ ## 팀원 소개 - **김정훈**: 소셜 로그인, 환경 설정, 보안 설정 -- **박원석**: +- **박원석**: aws 담당, 마이페이지, 채팅, 경매 - **이준용**: --- diff --git a/src/main/kotlin/com/toyProject7/karrot/article/service/ArticleService.kt b/src/main/kotlin/com/toyProject7/karrot/article/service/ArticleService.kt index 205f3f3..39d8c62 100644 --- a/src/main/kotlin/com/toyProject7/karrot/article/service/ArticleService.kt +++ b/src/main/kotlin/com/toyProject7/karrot/article/service/ArticleService.kt @@ -28,7 +28,7 @@ class ArticleService( private val articleRepository: ArticleRepository, private val articleLikesRepository: ArticleLikesRepository, private val userService: UserService, - @Lazy private val imageService: ImageService, + private val imageService: ImageService, @Lazy private val chatRoomService: ChatRoomService, ) { @Transactional diff --git a/src/main/kotlin/com/toyProject7/karrot/auction/service/AuctionService.kt b/src/main/kotlin/com/toyProject7/karrot/auction/service/AuctionService.kt index e1506a2..9ac3360 100644 --- a/src/main/kotlin/com/toyProject7/karrot/auction/service/AuctionService.kt +++ b/src/main/kotlin/com/toyProject7/karrot/auction/service/AuctionService.kt @@ -17,7 +17,6 @@ import com.toyProject7.karrot.auction.persistence.AuctionRepository import com.toyProject7.karrot.image.persistence.ImageUrlEntity import com.toyProject7.karrot.image.service.ImageService import com.toyProject7.karrot.user.service.UserService -import org.springframework.context.annotation.Lazy import org.springframework.data.repository.findByIdOrNull import org.springframework.stereotype.Service import org.springframework.transaction.annotation.Transactional @@ -29,7 +28,7 @@ class AuctionService( private val auctionRepository: AuctionRepository, private val auctionLikesRepository: AuctionLikesRepository, private val userService: UserService, - @Lazy private val imageService: ImageService, + private val imageService: ImageService, ) { @Transactional fun updatePrice(auctionMessage: AuctionMessage): AuctionMessage { diff --git a/src/main/kotlin/com/toyProject7/karrot/feed/service/FeedService.kt b/src/main/kotlin/com/toyProject7/karrot/feed/service/FeedService.kt index 2250cee..58aca5a 100644 --- a/src/main/kotlin/com/toyProject7/karrot/feed/service/FeedService.kt +++ b/src/main/kotlin/com/toyProject7/karrot/feed/service/FeedService.kt @@ -26,7 +26,7 @@ class FeedService( private val feedLikesRepository: FeedLikesRepository, private val userService: UserService, @Lazy private val commentService: CommentService, - @Lazy private val imageService: ImageService, + private val imageService: ImageService, ) { @Transactional fun postFeed( diff --git a/src/main/kotlin/com/toyProject7/karrot/image/service/ImageService.kt b/src/main/kotlin/com/toyProject7/karrot/image/service/ImageService.kt index f0a9663..e125a37 100644 --- a/src/main/kotlin/com/toyProject7/karrot/image/service/ImageService.kt +++ b/src/main/kotlin/com/toyProject7/karrot/image/service/ImageService.kt @@ -1,13 +1,14 @@ package com.toyProject7.karrot.image.service -import com.toyProject7.karrot.article.service.ArticleService -import com.toyProject7.karrot.auction.service.AuctionService -import com.toyProject7.karrot.feed.service.FeedService +import com.toyProject7.karrot.article.persistence.ArticleRepository +import com.toyProject7.karrot.auction.persistence.AuctionRepository +import com.toyProject7.karrot.feed.persistence.FeedRepository import com.toyProject7.karrot.image.ImageDeleteException import com.toyProject7.karrot.image.ImagePresignedUrlCreateException import com.toyProject7.karrot.image.ImageS3UrlCreateException import com.toyProject7.karrot.image.persistence.ImageUrlEntity import com.toyProject7.karrot.image.persistence.ImageUrlRepository +import org.springframework.data.repository.findByIdOrNull import org.springframework.stereotype.Service import org.springframework.transaction.annotation.Transactional import software.amazon.awssdk.services.s3.S3Client @@ -25,9 +26,9 @@ class ImageService( private val s3Client: S3Client, private val s3Presigner: S3Presigner, private val imageUrlRepository: ImageUrlRepository, - private val articleService: ArticleService, - private val feedService: FeedService, - private val auctionService: AuctionService, + private val articleRepository: ArticleRepository, + private val feedRepository: FeedRepository, + private val auctionRepository: AuctionRepository, ) { @Transactional fun postImageUrl( @@ -41,13 +42,13 @@ class ImageService( ) when (type) { "article" -> { - imageUrlEntity.article = articleService.getArticleEntityById(typeId) + imageUrlEntity.article = articleRepository.findByIdOrNull(typeId) } "feed" -> { - imageUrlEntity.feed = feedService.getFeedEntityById(typeId) + imageUrlEntity.feed = feedRepository.findByIdOrNull(typeId) } "auction" -> { - imageUrlEntity.auction = auctionService.getAuctionEntityById(typeId) + imageUrlEntity.auction = auctionRepository.findByIdOrNull(typeId) } } imageUrlRepository.save(imageUrlEntity)