feat(live): 입장 정책 모델을 추가한다

This commit is contained in:
2026-07-15 21:26:37 +09:00
parent fe79431744
commit b582545991
3 changed files with 112 additions and 0 deletions
@@ -0,0 +1,11 @@
package kr.co.vividnext.sodalive.v2.live.action
sealed interface LiveEntryDecision {
data object ShowDetail : LiveEntryDecision
data object Enter : LiveEntryDecision
data class RequestPassword(val can: Int) : LiveEntryDecision
data object RequestPayment : LiveEntryDecision
}
@@ -0,0 +1,23 @@
package kr.co.vividnext.sodalive.v2.live.action
data class LiveEntryContext(
val channelName: String?,
val managerId: Long,
val currentUserId: Long,
val price: Int,
val isPaid: Boolean,
val isPrivateRoom: Boolean
)
object LiveEntryPolicy {
fun decide(context: LiveEntryContext): LiveEntryDecision = with(context) {
when {
channelName.isNullOrBlank() -> LiveEntryDecision.ShowDetail
managerId == currentUserId -> LiveEntryDecision.Enter
(price == 0 || isPaid) && isPrivateRoom -> LiveEntryDecision.RequestPassword(can = 0)
price == 0 || isPaid -> LiveEntryDecision.Enter
isPrivateRoom -> LiveEntryDecision.RequestPassword(can = price)
else -> LiveEntryDecision.RequestPayment
}
}
}