-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feat/socialLogin' of https://github.com/wafflestudio/22…
…-5-team7-server into feat/socialLogin
- Loading branch information
Showing
17 changed files
with
168 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 7 additions & 1 deletion
8
src/main/kotlin/com/toyProject7/karrot/chatRoom/persistence/ChatMessageRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,13 @@ | ||
package com.toyProject7.karrot.chatRoom.persistence | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository | ||
import java.time.Instant | ||
|
||
interface ChatMessageRepository : JpaRepository<ChatMessageEntity, Long> { | ||
fun findAllByChatRoomIdOrderByCreatedAtAsc(chatRoomId: Long): List<ChatMessageEntity> | ||
fun findTop10ByChatRoomIdAndCreatedAtBeforeOrderByCreatedAtDesc( | ||
chatRoomId: Long, | ||
createdAt: Instant, | ||
): List<ChatMessageEntity> | ||
|
||
fun findTop1ByChatRoomIdOrderByCreatedAtDesc(chatRoomId: Long): ChatMessageEntity? | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 3 additions & 1 deletion
4
src/main/kotlin/com/toyProject7/karrot/chatRoom/persistence/ChatRoomRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
package com.toyProject7.karrot.chatRoom.persistence | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository | ||
import java.time.Instant | ||
|
||
interface ChatRoomRepository : JpaRepository<ChatRoomEntity, Long> { | ||
fun findAllBySellerIdOrBuyerIdOrderByCreatedAtDesc( | ||
fun findTop10BySellerIdOrBuyerIdAndUpdatedAtBeforeOrderByUpdatedAtDesc( | ||
sellerId: String, | ||
buyerId: String, | ||
updatedAt: Instant, | ||
): List<ChatRoomEntity> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 18 additions & 1 deletion
19
src/main/kotlin/com/toyProject7/karrot/comment/persistence/CommentRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,22 @@ | ||
package com.toyProject7.karrot.comment.persistence | ||
|
||
import com.toyProject7.karrot.feed.persistence.FeedEntity | ||
import com.toyProject7.karrot.user.persistence.UserEntity | ||
import org.springframework.data.jpa.repository.JpaRepository | ||
import org.springframework.data.jpa.repository.Query | ||
import org.springframework.data.repository.query.Param | ||
|
||
interface CommentRepository : JpaRepository<CommentEntity, Long> | ||
interface CommentRepository : JpaRepository<CommentEntity, Long> { | ||
@Query( | ||
""" | ||
SELECT DISTINCT c.feed | ||
FROM comments c | ||
WHERE c.user = :user AND c.feed.id < :feedId | ||
ORDER BY c.feed.id DESC | ||
""", | ||
) | ||
fun findFeedsByUserComments( | ||
@Param("user") user: UserEntity, | ||
@Param("feedId") feedId: Long, | ||
): List<FeedEntity> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 5 additions & 6 deletions
11
src/main/kotlin/com/toyProject7/karrot/feed/persistence/FeedRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,19 @@ | ||
package com.toyProject7.karrot.feed.persistence | ||
|
||
import com.toyProject7.karrot.user.persistence.UserEntity | ||
import jakarta.persistence.LockModeType | ||
import org.springframework.data.jpa.repository.JpaRepository | ||
import org.springframework.data.jpa.repository.Lock | ||
import org.springframework.data.jpa.repository.Modifying | ||
import org.springframework.data.jpa.repository.Query | ||
|
||
interface FeedRepository : JpaRepository<FeedEntity, Long> { | ||
@Lock(LockModeType.PESSIMISTIC_WRITE) | ||
@Query("SELECT r FROM feeds r WHERE r.id = :id") | ||
fun findByIdWithWriteLock(id: Long): FeedEntity? | ||
|
||
fun findTop10ByIdBeforeOrderByIdDesc(id: Long): List<FeedEntity> | ||
|
||
fun findTop10ByAuthorAndIdLessThanOrderByIdDesc( | ||
author: UserEntity, | ||
id: Long, | ||
): List<FeedEntity> | ||
|
||
@Modifying | ||
@Query("UPDATE feeds f SET f.viewCount = f.viewCount + 1 WHERE f.id = :id") | ||
fun incrementViewCount(id: Long): Int | ||
} |
Oops, something went wrong.