콘텐츠 상세
- 상단에 고정 상태, 고정이 가능한 상태 인지 판단하는 플래그 추가
This commit is contained in:
@@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user