feat: 유저 행동 데이터 기록 Controller 추가
This commit is contained in:
parent
ddcd54d3b9
commit
6fc372c898
|
@ -0,0 +1,36 @@
|
|||
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,
|
||||
actionType = request.actionType,
|
||||
pushTokenList = pushTokenList
|
||||
)
|
||||
|
||||
ApiResponse.ok(Unit, "")
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
package kr.co.vividnext.sodalive.useraction
|
||||
|
||||
data class UserActionRequest(val actionType: ActionType)
|
Loading…
Reference in New Issue