콘텐츠 상세

- 상단에 고정 상태, 고정이 가능한 상태 인지 판단하는 플래그 추가
This commit is contained in:
2024-01-27 00:03:34 +09:00
parent 711842f00d
commit 443818efb5
3 changed files with 34 additions and 6 deletions

View File

@@ -9,7 +9,7 @@ interface PinContentRepository : JpaRepository<PinContent, Long>, PinContentQuer
interface PinContentQueryRepository {
fun getPinContentList(memberId: Long): List<PinContent>
fun findByContentIdAndMemberId(contentId: Long, memberId: Long): PinContent?
fun findByContentIdAndMemberId(contentId: Long, memberId: Long, active: Boolean? = null): PinContent?
}
class PinContentQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) : PinContentQueryRepository {
@@ -21,13 +21,18 @@ class PinContentQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) :
.fetch()
}
override fun findByContentIdAndMemberId(contentId: Long, memberId: Long): PinContent? {
override fun findByContentIdAndMemberId(contentId: Long, memberId: Long, active: Boolean?): PinContent? {
var where = pinContent.content.id.eq(contentId)
.and(pinContent.member.id.eq(memberId))
if (active != null) {
where = where
.and(pinContent.isActive.eq(active))
}
return queryFactory
.selectFrom(pinContent)
.where(
pinContent.content.id.eq(contentId)
.and(pinContent.member.id.eq(memberId))
)
.where(where)
.fetchFirst()
}
}