feat(live): 입장 정책 모델을 추가한다
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user