diff --git a/src/main/kotlin/com/dotori/v2/domain/auth/service/impl/SignInEmailAndPasswordServiceImpl.kt b/src/main/kotlin/com/dotori/v2/domain/auth/service/impl/SignInEmailAndPasswordServiceImpl.kt index 0d86b3e7..12767260 100644 --- a/src/main/kotlin/com/dotori/v2/domain/auth/service/impl/SignInEmailAndPasswordServiceImpl.kt +++ b/src/main/kotlin/com/dotori/v2/domain/auth/service/impl/SignInEmailAndPasswordServiceImpl.kt @@ -45,12 +45,12 @@ class SignInEmailAndPasswordServiceImpl( ) ) return toResponse( - accessToken, - refreshToken, - accessExp, - refreshExp, - member.roles, - expiresAt + accessToken = accessToken, + refreshToken = refreshToken, + accessExp = accessExp, + refreshExp = refreshExp, + roles = member.roles, + expiresAt = expiresAt ) } diff --git a/src/main/kotlin/com/dotori/v2/domain/music/domain/repository/MusicLikeRepository.kt b/src/main/kotlin/com/dotori/v2/domain/music/domain/repository/MusicLikeRepository.kt index 520fdf57..dc10e3d5 100644 --- a/src/main/kotlin/com/dotori/v2/domain/music/domain/repository/MusicLikeRepository.kt +++ b/src/main/kotlin/com/dotori/v2/domain/music/domain/repository/MusicLikeRepository.kt @@ -12,5 +12,7 @@ interface MusicLikeRepository : JpaRepository { @Query("select l from MusicLike l where l.memberId = :memberId and l.musicId = :musicId") fun findByMemberIdAndMusicId(@Param("memberId") memberId: Long,@Param("musicId") musicId: Long): MusicLike? + fun deleteAllByMusicId(music: Long) + fun existsByMusicIdAndMemberId(musicId: Long, memberId: Long): Boolean } \ No newline at end of file diff --git a/src/main/kotlin/com/dotori/v2/domain/music/service/impl/DeleteMusicServiceImpl.kt b/src/main/kotlin/com/dotori/v2/domain/music/service/impl/DeleteMusicServiceImpl.kt index a9d422c0..51131b3c 100644 --- a/src/main/kotlin/com/dotori/v2/domain/music/service/impl/DeleteMusicServiceImpl.kt +++ b/src/main/kotlin/com/dotori/v2/domain/music/service/impl/DeleteMusicServiceImpl.kt @@ -2,6 +2,7 @@ package com.dotori.v2.domain.music.service.impl import com.dotori.v2.domain.member.enums.MusicStatus import com.dotori.v2.domain.music.domain.entity.Music +import com.dotori.v2.domain.music.domain.repository.MusicLikeRepository import com.dotori.v2.domain.music.domain.repository.MusicRepository import com.dotori.v2.domain.music.exception.MusicNotFoundException import com.dotori.v2.domain.music.presentation.data.res.MusicListResDto @@ -15,16 +16,20 @@ import org.springframework.transaction.annotation.Transactional @Transactional(rollbackFor = [Exception::class]) class DeleteMusicServiceImpl( private val musicRepository: MusicRepository, - private val redisCacheService: RedisCacheService + private val redisCacheService: RedisCacheService, + private val musicLikeRepository: MusicLikeRepository ) : DeleteMusicService { override fun execute(musicId: Long) { - val music: Music = musicRepository.findByIdOrNull(musicId) ?: throw MusicNotFoundException() + val music: Music = musicRepository.findByIdOrNull(musicId) + ?: throw MusicNotFoundException() val date = music.createdDate.toLocalDate().toString() redisCacheService.putToCacheMusic(date, MusicListResDto(mutableListOf())) + musicLikeRepository.deleteAllByMusicId(musicId) musicRepository.delete(music) music.member.updateMusicStatus(MusicStatus.CAN) } -} \ No newline at end of file + +} diff --git a/src/main/kotlin/com/dotori/v2/domain/music/service/impl/DeleteMyMusicServiceImpl.kt b/src/main/kotlin/com/dotori/v2/domain/music/service/impl/DeleteMyMusicServiceImpl.kt index bc8b125a..fac0081a 100644 --- a/src/main/kotlin/com/dotori/v2/domain/music/service/impl/DeleteMyMusicServiceImpl.kt +++ b/src/main/kotlin/com/dotori/v2/domain/music/service/impl/DeleteMyMusicServiceImpl.kt @@ -3,6 +3,7 @@ package com.dotori.v2.domain.music.service.impl import com.dotori.v2.domain.member.domain.entity.Member import com.dotori.v2.domain.member.enums.MusicStatus import com.dotori.v2.domain.music.domain.entity.Music +import com.dotori.v2.domain.music.domain.repository.MusicLikeRepository import com.dotori.v2.domain.music.domain.repository.MusicRepository import com.dotori.v2.domain.music.exception.MusicNotFoundException import com.dotori.v2.domain.music.exception.NotMyMusicException @@ -19,12 +20,15 @@ import org.springframework.transaction.annotation.Transactional class DeleteMyMusicServiceImpl( private val musicRepository: MusicRepository, private val userUtil: UserUtil, - private val redisCacheService: RedisCacheService + private val redisCacheService: RedisCacheService, + private val musicLikeRepository: MusicLikeRepository ) : DeleteMyMusicService { override fun execute(musicId: Long) { - val music: Music = musicRepository.findByIdOrNull(musicId) ?: throw MusicNotFoundException() + val music: Music = musicRepository.findByIdOrNull(musicId) + ?: throw MusicNotFoundException() + val member: Member = userUtil.fetchCurrentUser() validMusic(music, member) @@ -32,6 +36,7 @@ class DeleteMyMusicServiceImpl( val date = music.createdDate.toLocalDate().toString() redisCacheService.putToCacheMusic(date, MusicListResDto(mutableListOf())) + musicLikeRepository.deleteAllByMusicId(musicId) musicRepository.delete(music) music.member.updateMusicStatus(MusicStatus.CAN) }