콘텐츠 고정

- 고정 콘텐츠 개수 표시 수정
This commit is contained in:
Klaus 2024-01-27 02:43:41 +09:00
parent 95e31bb629
commit cec4cd0d28
2 changed files with 10 additions and 4 deletions

View File

@ -566,7 +566,7 @@ class AudioContentService(
false false
} }
val pinContentListCount = pinContentRepository.getPinContentList(memberId = member.id!!).size val pinContentListCount = pinContentRepository.getPinContentList(memberId = member.id!!, active = true).size
val isAvailablePin = if (member.id!! == audioContent.member!!.id!!) { val isAvailablePin = if (member.id!! == audioContent.member!!.id!!) {
pinContentListCount < 3 pinContentListCount < 3
} else { } else {

View File

@ -7,16 +7,22 @@ import org.springframework.data.jpa.repository.JpaRepository
interface PinContentRepository : JpaRepository<PinContent, Long>, PinContentQueryRepository interface PinContentRepository : JpaRepository<PinContent, Long>, PinContentQueryRepository
interface PinContentQueryRepository { interface PinContentQueryRepository {
fun getPinContentList(memberId: Long): List<PinContent> fun getPinContentList(memberId: Long, active: Boolean? = null): List<PinContent>
fun findByContentIdAndMemberId(contentId: Long, memberId: Long, active: Boolean? = null): PinContent? fun findByContentIdAndMemberId(contentId: Long, memberId: Long, active: Boolean? = null): PinContent?
} }
class PinContentQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) : PinContentQueryRepository { class PinContentQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) : PinContentQueryRepository {
override fun getPinContentList(memberId: Long): List<PinContent> { override fun getPinContentList(memberId: Long, active: Boolean?): List<PinContent> {
var where = pinContent.member.id.eq(memberId)
if (active != null) {
where = where.and(pinContent.isActive.eq(active))
}
return queryFactory return queryFactory
.selectFrom(pinContent) .selectFrom(pinContent)
.where(pinContent.member.id.eq(memberId)) .where(where)
.orderBy(pinContent.updatedAt.asc()) .orderBy(pinContent.updatedAt.asc())
.fetch() .fetch()
} }