parent
95e31bb629
commit
cec4cd0d28
|
@ -566,7 +566,7 @@ class AudioContentService(
|
|||
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!!) {
|
||||
pinContentListCount < 3
|
||||
} else {
|
||||
|
|
|
@ -7,16 +7,22 @@ import org.springframework.data.jpa.repository.JpaRepository
|
|||
interface PinContentRepository : JpaRepository<PinContent, Long>, 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?
|
||||
}
|
||||
|
||||
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
|
||||
.selectFrom(pinContent)
|
||||
.where(pinContent.member.id.eq(memberId))
|
||||
.where(where)
|
||||
.orderBy(pinContent.updatedAt.asc())
|
||||
.fetch()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue