38 lines
1.3 KiB
Kotlin
38 lines
1.3 KiB
Kotlin
package kr.co.vividnext.sodalive.useraction
|
|
|
|
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.member.MemberService
|
|
import org.springframework.security.core.annotation.AuthenticationPrincipal
|
|
import org.springframework.web.bind.annotation.PostMapping
|
|
import org.springframework.web.bind.annotation.RequestBody
|
|
import org.springframework.web.bind.annotation.RequestMapping
|
|
import org.springframework.web.bind.annotation.RestController
|
|
|
|
@RestController
|
|
@RequestMapping("/user-action")
|
|
class UserActionController(
|
|
private val service: UserActionService,
|
|
private val memberService: MemberService
|
|
) {
|
|
@PostMapping
|
|
fun recordAction(
|
|
@RequestBody request: UserActionRequest,
|
|
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
|
) = run {
|
|
if (member == null) throw SodaException("")
|
|
|
|
val memberId = member.id!!
|
|
val pushTokenList = memberService.getPushTokenList(recipient = memberId)
|
|
service.recordAction(
|
|
memberId = memberId,
|
|
isAuth = member.auth != null,
|
|
actionType = request.actionType,
|
|
pushTokenList = pushTokenList
|
|
)
|
|
|
|
ApiResponse.ok(Unit, "")
|
|
}
|
|
}
|