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..a7e45ce 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) @@ -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/article/service/ArticleService.kt b/src/main/kotlin/com/toyProject7/karrot/article/service/ArticleService.kt index 9a9c8c4..bc70011 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, 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..4084565 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,12 @@ 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"), + ) + } } } 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) } 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..d984262 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) @@ -159,7 +159,3 @@ data class PostFeedRequest( val tag: String, val imageCount: Int, ) - -data class SearchRequest( - val text: String, -) 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)