From 86dcd43ef2baa5666e962670dadc5b4a4bd399b0 Mon Sep 17 00:00:00 2001 From: Junyong Lee Date: Sat, 1 Feb 2025 22:13:03 +0900 Subject: [PATCH 1/7] :bug: Fix searchFeeds's API --- .../com/toyProject7/karrot/feed/controller/FeedController.kt | 4 ++-- .../kotlin/com/toyProject7/karrot/feed/service/FeedService.kt | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/main/kotlin/com/toyProject7/karrot/feed/controller/FeedController.kt b/src/main/kotlin/com/toyProject7/karrot/feed/controller/FeedController.kt index 7a0a2e0..580f874 100644 --- a/src/main/kotlin/com/toyProject7/karrot/feed/controller/FeedController.kt +++ b/src/main/kotlin/com/toyProject7/karrot/feed/controller/FeedController.kt @@ -140,11 +140,11 @@ class FeedController( @GetMapping("/feed/search/{feedId}") fun searchFeeds( - @RequestBody request: SearchRequest, @PathVariable feedId: Long, + @RequestParam("text") text: String, @AuthUser user: User, ): ResponseEntity> { - val feeds = feedService.searchFeed(request, feedId) + val feeds = feedService.searchFeed(text, feedId) val response: List = feeds.map { feed -> FeedPreview.fromEntity(feed) 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 38b1c84..191939e 100644 --- a/src/main/kotlin/com/toyProject7/karrot/feed/service/FeedService.kt +++ b/src/main/kotlin/com/toyProject7/karrot/feed/service/FeedService.kt @@ -6,7 +6,6 @@ import com.toyProject7.karrot.feed.FeedNotFoundException import com.toyProject7.karrot.feed.FeedPermissionDeniedException import com.toyProject7.karrot.feed.controller.Feed import com.toyProject7.karrot.feed.controller.PostFeedRequest -import com.toyProject7.karrot.feed.controller.SearchRequest import com.toyProject7.karrot.feed.persistence.FeedEntity import com.toyProject7.karrot.feed.persistence.FeedLikesEntity import com.toyProject7.karrot.feed.persistence.FeedLikesRepository @@ -239,10 +238,9 @@ class FeedService( @Transactional fun searchFeed( - request: SearchRequest, + text: String, feedId: Long, ): List { - val text = request.text val feeds = feedRepository.findTop10ByTitleContainingIgnoreCaseOrContentContainingIgnoreCaseAndIdLessThanOrderByIdDesc(text, text, feedId) refreshPresignedUrlIfExpired(feeds) From 8164deb0ade52b13657ad0042f9f2016d90ce22a Mon Sep 17 00:00:00 2001 From: Junyong Lee Date: Sat, 1 Feb 2025 22:14:25 +0900 Subject: [PATCH 2/7] :bug: Fix searchArticles's API --- .../karrot/article/controller/ArticleController.kt | 4 ++-- .../com/toyProject7/karrot/article/service/ArticleService.kt | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/main/kotlin/com/toyProject7/karrot/article/controller/ArticleController.kt b/src/main/kotlin/com/toyProject7/karrot/article/controller/ArticleController.kt index ab33398..bcac34d 100644 --- a/src/main/kotlin/com/toyProject7/karrot/article/controller/ArticleController.kt +++ b/src/main/kotlin/com/toyProject7/karrot/article/controller/ArticleController.kt @@ -141,11 +141,11 @@ class ArticleController( @GetMapping("/item/search/{articleId}") fun searchArticles( - @RequestBody request: SearchRequest, @PathVariable articleId: Long, + @RequestParam("text") text: String, @AuthUser user: User, ): ResponseEntity> { - val articles = articleService.searchArticle(request, articleId) + val articles = articleService.searchArticle(text, articleId) val response: List = articles.map { article -> Item.fromArticle(Article.fromEntity(article), articleService.getChattingUsersByArticle(Article.fromEntity(article)).size) 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 8910c54..ef0c216 100644 --- a/src/main/kotlin/com/toyProject7/karrot/article/service/ArticleService.kt +++ b/src/main/kotlin/com/toyProject7/karrot/article/service/ArticleService.kt @@ -4,7 +4,6 @@ import com.toyProject7.karrot.article.ArticleNotFoundException import com.toyProject7.karrot.article.ArticlePermissionDeniedException import com.toyProject7.karrot.article.controller.Article import com.toyProject7.karrot.article.controller.PostArticleRequest -import com.toyProject7.karrot.article.controller.SearchRequest import com.toyProject7.karrot.article.controller.UpdateStatusRequest import com.toyProject7.karrot.article.persistence.ArticleEntity import com.toyProject7.karrot.article.persistence.ArticleLikesEntity @@ -254,10 +253,9 @@ class ArticleService( @Transactional fun searchArticle( - request: SearchRequest, + text: String, articleId: Long, ): List { - val text = request.text val articles = articleRepository.findTop10ByTitleContainingIgnoreCaseOrContentContainingIgnoreCaseAndIdLessThanOrderByIdDesc( text, From 7d5eed12423e4a23366995738ea8f8003196f0b8 Mon Sep 17 00:00:00 2001 From: Junyong Lee Date: Sat, 1 Feb 2025 22:15:08 +0900 Subject: [PATCH 3/7] :pencil: Delete SearchRequest data class --- .../karrot/article/controller/ArticleController.kt | 4 ---- .../com/toyProject7/karrot/feed/controller/FeedController.kt | 4 ---- 2 files changed, 8 deletions(-) diff --git a/src/main/kotlin/com/toyProject7/karrot/article/controller/ArticleController.kt b/src/main/kotlin/com/toyProject7/karrot/article/controller/ArticleController.kt index bcac34d..a7e45ce 100644 --- a/src/main/kotlin/com/toyProject7/karrot/article/controller/ArticleController.kt +++ b/src/main/kotlin/com/toyProject7/karrot/article/controller/ArticleController.kt @@ -175,10 +175,6 @@ data class UpdateStatusRequest( val status: Int, ) -data class SearchRequest( - val text: String, -) - data class ArticleResponse( val article: Article, val chattingUsers: List, diff --git a/src/main/kotlin/com/toyProject7/karrot/feed/controller/FeedController.kt b/src/main/kotlin/com/toyProject7/karrot/feed/controller/FeedController.kt index 580f874..d984262 100644 --- a/src/main/kotlin/com/toyProject7/karrot/feed/controller/FeedController.kt +++ b/src/main/kotlin/com/toyProject7/karrot/feed/controller/FeedController.kt @@ -159,7 +159,3 @@ data class PostFeedRequest( val tag: String, val imageCount: Int, ) - -data class SearchRequest( - val text: String, -) From 64829200ea134f73976e31dcd98ead18b150c5b4 Mon Sep 17 00:00:00 2001 From: Junghoon Kim Date: Sat, 1 Feb 2025 23:57:26 +0900 Subject: [PATCH 4/7] :pencil: reduced @schedule check time to 10 seconds and made it so if the buyer and the seller is the same in auction it does not create a chatroom --- .../karrot/auction/service/AuctionService.kt | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) 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 8ecbf71..4e0cb1e 100644 --- a/src/main/kotlin/com/toyProject7/karrot/auction/service/AuctionService.kt +++ b/src/main/kotlin/com/toyProject7/karrot/auction/service/AuctionService.kt @@ -208,7 +208,7 @@ class AuctionService( return auctionRepository.findByIdOrNull(auctionId) ?: throw AuctionNotFoundException() } - @Scheduled(fixedRate = 60000) // Run every minute + @Scheduled(fixedRate = 10000) fun checkAndEndAuctions() { val now = Instant.now() val endedAuctions = auctionRepository.findByEndTimeBeforeAndStatus(now, 0) @@ -237,10 +237,13 @@ class AuctionService( isDummy = 1, ) articleRepository.save(articleEntity) - chatRoomService.createChatRoom( - articleEntity.id ?: throw IllegalArgumentException("Article ID cannot be null"), - articleEntity.seller.id ?: throw IllegalArgumentException("Seller ID cannot be null"), - articleEntity.buyer?.id ?: throw IllegalArgumentException("Buyer ID cannot be null"), - ) + if (auction.seller.id != auction.bidder?.id) + { + chatRoomService.createChatRoom( + articleEntity.id ?: throw IllegalArgumentException("Article ID cannot be null"), + articleEntity.seller.id ?: throw IllegalArgumentException("Seller ID cannot be null"), + articleEntity.buyer?.id ?: throw IllegalArgumentException("Buyer ID cannot be null"), + ) + } } } From 23b7c596f7d907aac5dd85f6c8187f5a3bf18bb3 Mon Sep 17 00:00:00 2001 From: Junghoon Kim Date: Sun, 2 Feb 2025 00:01:30 +0900 Subject: [PATCH 5/7] :art: lint --- .../karrot/auction/service/AuctionService.kt | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) 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 4e0cb1e..4084565 100644 --- a/src/main/kotlin/com/toyProject7/karrot/auction/service/AuctionService.kt +++ b/src/main/kotlin/com/toyProject7/karrot/auction/service/AuctionService.kt @@ -237,13 +237,12 @@ class AuctionService( isDummy = 1, ) articleRepository.save(articleEntity) - if (auction.seller.id != auction.bidder?.id) - { - chatRoomService.createChatRoom( - articleEntity.id ?: throw IllegalArgumentException("Article ID cannot be null"), - articleEntity.seller.id ?: throw IllegalArgumentException("Seller ID cannot be null"), - articleEntity.buyer?.id ?: throw IllegalArgumentException("Buyer ID cannot be null"), - ) - } + if (auction.seller.id != auction.bidder?.id) { + chatRoomService.createChatRoom( + articleEntity.id ?: throw IllegalArgumentException("Article ID cannot be null"), + articleEntity.seller.id ?: throw IllegalArgumentException("Seller ID cannot be null"), + articleEntity.buyer?.id ?: throw IllegalArgumentException("Buyer ID cannot be null"), + ) + } } } From dd393151aa2712636b05113ee9460a1e4ff2958e Mon Sep 17 00:00:00 2001 From: Junyong Lee <97828079+alpakar02@users.noreply.github.com> Date: Sun, 2 Feb 2025 02:08:36 +0900 Subject: [PATCH 6/7] :bug: Fix editComment --- .../com/toyProject7/karrot/comment/service/CommentService.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/kotlin/com/toyProject7/karrot/comment/service/CommentService.kt b/src/main/kotlin/com/toyProject7/karrot/comment/service/CommentService.kt index f473857..ec6448a 100644 --- a/src/main/kotlin/com/toyProject7/karrot/comment/service/CommentService.kt +++ b/src/main/kotlin/com/toyProject7/karrot/comment/service/CommentService.kt @@ -54,9 +54,8 @@ class CommentService( if (comment.user.id != user.id) { throw CommentWriterDoesNotMatchException() } - comment.feed.content = request.content + comment.content = request.content comment.updatedAt = Instant.now() - commentRepository.save(comment) feedService.saveCommentInFeed(comment.feed, comment) return Comment.fromEntity(comment) } From b416153c6c1ed78eff3f3cc4d99866867730561a Mon Sep 17 00:00:00 2001 From: ws11222 <148057351+ws11222@users.noreply.github.com> Date: Sun, 2 Feb 2025 10:14:01 +0900 Subject: [PATCH 7/7] :hammer: Update ArticleService.kt --- .../com/toyProject7/karrot/article/service/ArticleService.kt | 1 + 1 file changed, 1 insertion(+) 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 ef0c216..af3d638 100644 --- a/src/main/kotlin/com/toyProject7/karrot/article/service/ArticleService.kt +++ b/src/main/kotlin/com/toyProject7/karrot/article/service/ArticleService.kt @@ -273,6 +273,7 @@ class ArticleService( ) { val articleEntity = articleRepository.findByIdOrNull(articleId) ?: throw ArticleNotFoundException() articleEntity.buyer = userService.getUserEntityById(buyerId) + articleRepository.save(articleEntity) } @Transactional