feat(creator-channel): 후원 탭 endpoint를 추가한다
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
package kr.co.vividnext.sodalive.v2.api.creator.channel.donation.adapter.`in`.web
|
||||
|
||||
import kr.co.vividnext.sodalive.common.ApiResponse
|
||||
import kr.co.vividnext.sodalive.common.SodaException
|
||||
import kr.co.vividnext.sodalive.member.Member
|
||||
import kr.co.vividnext.sodalive.v2.api.creator.channel.donation.application.CreatorChannelDonationFacade
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
|
||||
import org.springframework.security.core.annotation.AuthenticationPrincipal
|
||||
import org.springframework.web.bind.annotation.GetMapping
|
||||
import org.springframework.web.bind.annotation.PathVariable
|
||||
import org.springframework.web.bind.annotation.RequestMapping
|
||||
import org.springframework.web.bind.annotation.RequestParam
|
||||
import org.springframework.web.bind.annotation.RestController
|
||||
|
||||
@RestController
|
||||
@ConditionalOnProperty(name = ["creator-channel.donation-tab.enabled"], havingValue = "true")
|
||||
@RequestMapping("/api/v2/creator-channels")
|
||||
class CreatorChannelDonationController(
|
||||
private val creatorChannelDonationFacade: CreatorChannelDonationFacade
|
||||
) {
|
||||
@GetMapping("/{creatorId}/donations")
|
||||
fun getDonationTab(
|
||||
@PathVariable creatorId: Long,
|
||||
@RequestParam(required = false) page: Int?,
|
||||
@RequestParam(required = false) size: Int?,
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
ApiResponse.ok(
|
||||
creatorChannelDonationFacade.getDonationTab(
|
||||
creatorId = creatorId,
|
||||
viewer = requireMember(member),
|
||||
page = page,
|
||||
size = size
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
private fun requireMember(member: Member?): Member {
|
||||
return member ?: throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user