parent
59a035e5c2
commit
31e33d49df
|
@ -3,13 +3,9 @@ package kr.co.vividnext.sodalive.live.room.menu
|
||||||
import kr.co.vividnext.sodalive.common.ApiResponse
|
import kr.co.vividnext.sodalive.common.ApiResponse
|
||||||
import kr.co.vividnext.sodalive.common.SodaException
|
import kr.co.vividnext.sodalive.common.SodaException
|
||||||
import kr.co.vividnext.sodalive.member.Member
|
import kr.co.vividnext.sodalive.member.Member
|
||||||
import kr.co.vividnext.sodalive.member.MemberRole
|
|
||||||
import org.springframework.security.access.prepost.PreAuthorize
|
import org.springframework.security.access.prepost.PreAuthorize
|
||||||
import org.springframework.security.core.annotation.AuthenticationPrincipal
|
import org.springframework.security.core.annotation.AuthenticationPrincipal
|
||||||
import org.springframework.web.bind.annotation.GetMapping
|
import org.springframework.web.bind.annotation.GetMapping
|
||||||
import org.springframework.web.bind.annotation.PostMapping
|
|
||||||
import org.springframework.web.bind.annotation.PutMapping
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping
|
import org.springframework.web.bind.annotation.RequestMapping
|
||||||
import org.springframework.web.bind.annotation.RequestParam
|
import org.springframework.web.bind.annotation.RequestParam
|
||||||
import org.springframework.web.bind.annotation.RestController
|
import org.springframework.web.bind.annotation.RestController
|
||||||
|
@ -17,7 +13,7 @@ import org.springframework.web.bind.annotation.RestController
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/live/room/menu")
|
@RequestMapping("/live/room/menu")
|
||||||
class LiveRoomMenuController(private val service: LiveRoomMenuService) {
|
class LiveRoomMenuController(private val service: LiveRoomMenuService) {
|
||||||
@GetMapping("/creator")
|
@GetMapping("/all")
|
||||||
@PreAuthorize("hasRole('CREATOR')")
|
@PreAuthorize("hasRole('CREATOR')")
|
||||||
fun getAllLiveMenu(
|
fun getAllLiveMenu(
|
||||||
@RequestParam creatorId: Long,
|
@RequestParam creatorId: Long,
|
||||||
|
@ -27,40 +23,4 @@ class LiveRoomMenuController(private val service: LiveRoomMenuService) {
|
||||||
|
|
||||||
ApiResponse.ok(service.getAllLiveMenu(creatorId = creatorId, memberId = member.id!!))
|
ApiResponse.ok(service.getAllLiveMenu(creatorId = creatorId, memberId = member.id!!))
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping
|
|
||||||
@PreAuthorize("hasRole('CREATOR')")
|
|
||||||
fun createLiveMenu(
|
|
||||||
@RequestBody request: CreateLiveMenuRequest,
|
|
||||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
|
||||||
) = run {
|
|
||||||
if (member == null || member.role != MemberRole.CREATOR) {
|
|
||||||
throw SodaException("로그인 정보를 확인해주세요.")
|
|
||||||
}
|
|
||||||
|
|
||||||
ApiResponse.ok(service.createLiveMenu(memberId = member.id!!, request = request))
|
|
||||||
}
|
|
||||||
|
|
||||||
@PutMapping
|
|
||||||
@PreAuthorize("hasRole('CREATOR')")
|
|
||||||
fun updateLiveMenu(
|
|
||||||
@RequestBody request: UpdateLiveMenuRequest,
|
|
||||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
|
||||||
) = run {
|
|
||||||
if (member == null || member.role != MemberRole.CREATOR) {
|
|
||||||
throw SodaException("로그인 정보를 확인해주세요.")
|
|
||||||
}
|
|
||||||
|
|
||||||
ApiResponse.ok(service.updateLiveMenu(memberId = member.id!!, request = request))
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping
|
|
||||||
fun getMenu(
|
|
||||||
@RequestParam creatorId: Long,
|
|
||||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
|
||||||
) = run {
|
|
||||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
|
||||||
|
|
||||||
ApiResponse.ok(service.getLiveMenu(creatorId = creatorId))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue