fix(content): 삭제 콘텐츠의 상단 고정을 비활성화한다
This commit is contained in:
@@ -207,8 +207,14 @@ class AudioContentService(
|
||||
val audioContent = repository.findByIdAndCreatorId(audioContentId, member.id!!)
|
||||
?: throw SodaException(messageKey = "content.error.invalid_content_retry")
|
||||
|
||||
val pinContent = pinContentRepository.findByContentIdAndMemberId(
|
||||
contentId = audioContentId,
|
||||
memberId = member.id!!
|
||||
)
|
||||
|
||||
audioContent.isActive = false
|
||||
audioContent.releaseDate = null
|
||||
pinContent?.isActive = false
|
||||
}
|
||||
|
||||
@Transactional
|
||||
|
||||
@@ -15,6 +15,7 @@ interface PinContentQueryRepository {
|
||||
class PinContentQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) : PinContentQueryRepository {
|
||||
override fun getPinContentList(memberId: Long, active: Boolean?): List<PinContent> {
|
||||
var where = pinContent.member.id.eq(memberId)
|
||||
.and(pinContent.content.isActive.eq(true))
|
||||
|
||||
if (active != null) {
|
||||
where = where.and(pinContent.isActive.eq(active))
|
||||
@@ -30,6 +31,7 @@ class PinContentQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) :
|
||||
override fun findByContentIdAndMemberId(contentId: Long, memberId: Long, active: Boolean?): PinContent? {
|
||||
var where = pinContent.content.id.eq(contentId)
|
||||
.and(pinContent.member.id.eq(memberId))
|
||||
.and(pinContent.content.isActive.eq(true))
|
||||
|
||||
if (active != null) {
|
||||
where = where
|
||||
|
||||
@@ -572,6 +572,28 @@ class AudioContentServiceTest {
|
||||
assertTrue(inactivePinContent.isActive)
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("콘텐츠 삭제 시 해당 콘텐츠의 상단 고정도 함께 비활성화한다")
|
||||
fun shouldDeactivatePinContentWhenDeletingAudioContent() {
|
||||
val creator = createMember(id = 2430L, nickname = "pin-delete-creator")
|
||||
val audioContent = createAudioContent(creator = creator)
|
||||
val pinContent = PinContent(isActive = true)
|
||||
pinContent.member = creator
|
||||
pinContent.content = audioContent
|
||||
Mockito.`when`(repository.findByIdAndCreatorId(audioContent.id!!, creator.id!!)).thenReturn(audioContent)
|
||||
Mockito.`when`(
|
||||
pinContentRepository.findByContentIdAndMemberId(
|
||||
contentId = audioContent.id!!,
|
||||
memberId = creator.id!!
|
||||
)
|
||||
).thenReturn(pinContent)
|
||||
|
||||
service.deleteAudioContent(audioContentId = audioContent.id!!, member = creator)
|
||||
|
||||
assertEquals(false, audioContent.isActive)
|
||||
assertEquals(false, pinContent.isActive)
|
||||
}
|
||||
|
||||
private fun createMember(id: Long, nickname: String): Member {
|
||||
val member = Member(
|
||||
email = "$nickname@test.com",
|
||||
|
||||
Reference in New Issue
Block a user