Skip to content

Commit

Permalink
[Refactor/#398] 멤버 탈퇴시 구독 정보 삭제될 수 있도록 수정 (#399)
Browse files Browse the repository at this point in the history
  • Loading branch information
belljun3395 authored Sep 11, 2024
1 parent bff63c3 commit 3550d40
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.few.api.domain.member.subscription

import com.few.api.domain.member.subscription.dto.DeleteSubscriptionDto
import com.few.api.repo.dao.subscription.SubscriptionDao
import com.few.api.repo.dao.subscription.command.UpdateDeletedAtInAllSubscriptionCommand
import org.springframework.stereotype.Service
import org.springframework.transaction.annotation.Transactional

@Service
class MemberSubscriptionService(
private val subscriptionDao: SubscriptionDao,
) {

@Transactional
fun deleteSubscription(dto: DeleteSubscriptionDto) {
subscriptionDao.updateDeletedAtInAllSubscription(
UpdateDeletedAtInAllSubscriptionCommand(
memberId = dto.memberId,
opinion = dto.opinion
)
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.few.api.domain.member.subscription.dto

data class DeleteSubscriptionDto(
val memberId: Long,
val opinion: String = "withdrawal",
)
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
package com.few.api.domain.member.usecase

import com.few.api.domain.member.subscription.MemberSubscriptionService
import com.few.api.domain.member.subscription.dto.DeleteSubscriptionDto
import com.few.api.domain.member.usecase.dto.DeleteMemberUseCaseIn
import com.few.api.domain.member.usecase.dto.DeleteMemberUseCaseOut
import com.few.api.repo.dao.member.MemberDao
import com.few.api.repo.dao.member.command.DeleteMemberCommand
import org.springframework.stereotype.Component
import org.springframework.transaction.annotation.Transactional
import java.util.*

@Component
class DeleteMemberUseCase(
private val memberDao: MemberDao,
private val memberSubscriptionService: MemberSubscriptionService,
) {
@Transactional
fun execute(useCaseIn: DeleteMemberUseCaseIn): DeleteMemberUseCaseOut {
Expand All @@ -20,6 +22,12 @@ class DeleteMemberUseCase(
)
)

memberSubscriptionService.deleteSubscription(
DeleteSubscriptionDto(
memberId = useCaseIn.memberId,
opinion = "cancel"
)
)
return DeleteMemberUseCaseOut(true)
}
}

0 comments on commit 3550d40

Please sign in to comment.