diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/explorer/profile/creatorCommunity/CreatorCommunity.kt b/src/main/kotlin/kr/co/vividnext/sodalive/explorer/profile/creatorCommunity/CreatorCommunity.kt index f3b62f66..fdd42838 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/explorer/profile/creatorCommunity/CreatorCommunity.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/explorer/profile/creatorCommunity/CreatorCommunity.kt @@ -24,7 +24,11 @@ class CreatorCommunity( var isActive: Boolean = true, var isFixed: Boolean = false, @Column(nullable = true) - var fixedAt: LocalDateTime? = null + var fixedAt: LocalDateTime? = null, + @Column(name = "language_code", nullable = true, length = 10) + var languageCode: String? = null, + @Column(name = "content_revision", nullable = false) + var contentRevision: Long = 0 ) : BaseEntity() { @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "member_id", nullable = false) diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/explorer/profile/creatorCommunity/CreatorCommunityRepository.kt b/src/main/kotlin/kr/co/vividnext/sodalive/explorer/profile/creatorCommunity/CreatorCommunityRepository.kt index 616c25f3..5b2a5029 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/explorer/profile/creatorCommunity/CreatorCommunityRepository.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/explorer/profile/creatorCommunity/CreatorCommunityRepository.kt @@ -7,12 +7,29 @@ import kr.co.vividnext.sodalive.explorer.profile.creatorCommunity.QCreatorCommun import kr.co.vividnext.sodalive.member.QMember.member import kr.co.vividnext.sodalive.member.following.QCreatorFollowing.creatorFollowing import org.springframework.data.jpa.repository.JpaRepository +import org.springframework.data.jpa.repository.Lock +import org.springframework.data.jpa.repository.Query +import org.springframework.data.repository.query.Param import java.time.LocalDate import java.time.LocalDateTime import java.time.LocalTime +import javax.persistence.LockModeType interface CreatorCommunityRepository : JpaRepository, CreatorCommunityQueryRepository { fun countByMemberIdAndIsFixedIsTrueAndIsActiveIsTrue(memberId: Long): Long + + fun findByIdAndIsActiveTrue(postId: Long): CreatorCommunity? + + @Lock(LockModeType.PESSIMISTIC_WRITE) + @Query("select c from CreatorCommunity c where c.id = :postId and c.isActive = true") + fun findByIdAndIsActiveTrueForUpdate(@Param("postId") postId: Long): CreatorCommunity? + + @Lock(LockModeType.PESSIMISTIC_WRITE) + @Query("select c from CreatorCommunity c where c.id = :postId and c.member.id = :memberId") + fun findByIdAndMemberIdForUpdate( + @Param("postId") postId: Long, + @Param("memberId") memberId: Long + ): CreatorCommunity? } interface CreatorCommunityQueryRepository {