fix: 유저 행동 기록, 포인트 지급 #320
|
@ -3,7 +3,6 @@ package kr.co.vividnext.sodalive.content.comment
|
||||||
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.MemberService
|
|
||||||
import kr.co.vividnext.sodalive.useraction.ActionType
|
import kr.co.vividnext.sodalive.useraction.ActionType
|
||||||
import kr.co.vividnext.sodalive.useraction.UserActionService
|
import kr.co.vividnext.sodalive.useraction.UserActionService
|
||||||
import org.springframework.data.domain.Pageable
|
import org.springframework.data.domain.Pageable
|
||||||
|
@ -19,7 +18,6 @@ import org.springframework.web.bind.annotation.RestController
|
||||||
@RestController
|
@RestController
|
||||||
class AudioContentCommentController(
|
class AudioContentCommentController(
|
||||||
private val service: AudioContentCommentService,
|
private val service: AudioContentCommentService,
|
||||||
private val memberService: MemberService,
|
|
||||||
private val userActionService: UserActionService
|
private val userActionService: UserActionService
|
||||||
) {
|
) {
|
||||||
@PostMapping("/audio-content/comment")
|
@PostMapping("/audio-content/comment")
|
||||||
|
@ -38,15 +36,11 @@ class AudioContentCommentController(
|
||||||
)
|
)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
val memberId = member.id!!
|
|
||||||
val pushTokenList = memberService.getPushTokenList(recipient = memberId)
|
|
||||||
|
|
||||||
userActionService.recordAction(
|
userActionService.recordAction(
|
||||||
memberId = member.id!!,
|
memberId = member.id!!,
|
||||||
isAuth = member.auth != null,
|
isAuth = member.auth != null,
|
||||||
actionType = ActionType.CONTENT_COMMENT,
|
actionType = ActionType.CONTENT_COMMENT,
|
||||||
contentCommentId = commentId,
|
contentCommentId = commentId
|
||||||
pushTokenList = pushTokenList
|
|
||||||
)
|
)
|
||||||
|
|
||||||
userActionService.recordAction(
|
userActionService.recordAction(
|
||||||
|
@ -54,8 +48,7 @@ class AudioContentCommentController(
|
||||||
isAuth = member.auth != null,
|
isAuth = member.auth != null,
|
||||||
actionType = ActionType.ORDER_CONTENT_COMMENT,
|
actionType = ActionType.ORDER_CONTENT_COMMENT,
|
||||||
contentId = request.contentId,
|
contentId = request.contentId,
|
||||||
contentCommentId = commentId,
|
contentCommentId = commentId
|
||||||
pushTokenList = pushTokenList
|
|
||||||
)
|
)
|
||||||
} catch (_: Exception) {
|
} catch (_: Exception) {
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,12 +66,7 @@ class MemberController(
|
||||||
userActionService.recordAction(
|
userActionService.recordAction(
|
||||||
memberId = response.memberId,
|
memberId = response.memberId,
|
||||||
isAuth = false,
|
isAuth = false,
|
||||||
actionType = ActionType.SIGN_UP,
|
actionType = ActionType.SIGN_UP
|
||||||
pushTokenList = if (request.pushToken != null) {
|
|
||||||
listOf(request.pushToken)
|
|
||||||
} else {
|
|
||||||
emptyList()
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
return ApiResponse.ok(message = "회원가입을 축하드립니다.", data = response.loginResponse)
|
return ApiResponse.ok(message = "회원가입을 축하드립니다.", data = response.loginResponse)
|
||||||
|
@ -360,12 +355,7 @@ class MemberController(
|
||||||
userActionService.recordAction(
|
userActionService.recordAction(
|
||||||
memberId = response.memberId,
|
memberId = response.memberId,
|
||||||
isAuth = false,
|
isAuth = false,
|
||||||
actionType = ActionType.SIGN_UP,
|
actionType = ActionType.SIGN_UP
|
||||||
pushTokenList = if (request.pushToken != null) {
|
|
||||||
listOf(request.pushToken)
|
|
||||||
} else {
|
|
||||||
emptyList()
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -396,12 +386,7 @@ class MemberController(
|
||||||
userActionService.recordAction(
|
userActionService.recordAction(
|
||||||
memberId = response.memberId,
|
memberId = response.memberId,
|
||||||
isAuth = false,
|
isAuth = false,
|
||||||
actionType = ActionType.SIGN_UP,
|
actionType = ActionType.SIGN_UP
|
||||||
pushTokenList = if (request.pushToken != null) {
|
|
||||||
listOf(request.pushToken)
|
|
||||||
} else {
|
|
||||||
emptyList()
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@ package kr.co.vividnext.sodalive.member.auth
|
||||||
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.MemberService
|
|
||||||
import kr.co.vividnext.sodalive.useraction.ActionType
|
import kr.co.vividnext.sodalive.useraction.ActionType
|
||||||
import kr.co.vividnext.sodalive.useraction.UserActionService
|
import kr.co.vividnext.sodalive.useraction.UserActionService
|
||||||
import org.springframework.security.core.annotation.AuthenticationPrincipal
|
import org.springframework.security.core.annotation.AuthenticationPrincipal
|
||||||
|
@ -16,7 +15,6 @@ import org.springframework.web.bind.annotation.RestController
|
||||||
@RequestMapping("/auth")
|
@RequestMapping("/auth")
|
||||||
class AuthController(
|
class AuthController(
|
||||||
private val service: AuthService,
|
private val service: AuthService,
|
||||||
private val memberService: MemberService,
|
|
||||||
private val userActionService: UserActionService
|
private val userActionService: UserActionService
|
||||||
) {
|
) {
|
||||||
@PostMapping
|
@PostMapping
|
||||||
|
@ -36,13 +34,10 @@ class AuthController(
|
||||||
val authResponse = service.authenticate(authenticateData, member.id!!)
|
val authResponse = service.authenticate(authenticateData, member.id!!)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
val memberId = member.id!!
|
|
||||||
val pushTokenList = memberService.getPushTokenList(recipient = memberId)
|
|
||||||
userActionService.recordAction(
|
userActionService.recordAction(
|
||||||
memberId = member.id!!,
|
memberId = member.id!!,
|
||||||
isAuth = true,
|
isAuth = true,
|
||||||
actionType = ActionType.USER_AUTHENTICATION,
|
actionType = ActionType.USER_AUTHENTICATION
|
||||||
pushTokenList = pushTokenList
|
|
||||||
)
|
)
|
||||||
} catch (_: Exception) {
|
} catch (_: Exception) {
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@ package kr.co.vividnext.sodalive.useraction
|
||||||
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.MemberService
|
|
||||||
import org.springframework.security.core.annotation.AuthenticationPrincipal
|
import org.springframework.security.core.annotation.AuthenticationPrincipal
|
||||||
import org.springframework.web.bind.annotation.PostMapping
|
import org.springframework.web.bind.annotation.PostMapping
|
||||||
import org.springframework.web.bind.annotation.RequestBody
|
import org.springframework.web.bind.annotation.RequestBody
|
||||||
|
@ -12,10 +11,7 @@ import org.springframework.web.bind.annotation.RestController
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/user-action")
|
@RequestMapping("/user-action")
|
||||||
class UserActionController(
|
class UserActionController(private val service: UserActionService) {
|
||||||
private val service: UserActionService,
|
|
||||||
private val memberService: MemberService
|
|
||||||
) {
|
|
||||||
@PostMapping
|
@PostMapping
|
||||||
fun recordAction(
|
fun recordAction(
|
||||||
@RequestBody request: UserActionRequest,
|
@RequestBody request: UserActionRequest,
|
||||||
|
@ -23,13 +19,10 @@ class UserActionController(
|
||||||
) = run {
|
) = run {
|
||||||
if (member == null) throw SodaException("")
|
if (member == null) throw SodaException("")
|
||||||
|
|
||||||
val memberId = member.id!!
|
|
||||||
val pushTokenList = memberService.getPushTokenList(recipient = memberId)
|
|
||||||
service.recordAction(
|
service.recordAction(
|
||||||
memberId = memberId,
|
memberId = member.id!!,
|
||||||
isAuth = member.auth != null,
|
isAuth = member.auth != null,
|
||||||
actionType = request.actionType,
|
actionType = request.actionType
|
||||||
pushTokenList = pushTokenList
|
|
||||||
)
|
)
|
||||||
|
|
||||||
ApiResponse.ok(Unit, "")
|
ApiResponse.ok(Unit, "")
|
||||||
|
|
|
@ -7,7 +7,6 @@ import kotlinx.coroutines.cancel
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
import kr.co.vividnext.sodalive.content.order.OrderRepository
|
import kr.co.vividnext.sodalive.content.order.OrderRepository
|
||||||
import kr.co.vividnext.sodalive.fcm.FcmService
|
|
||||||
import kr.co.vividnext.sodalive.point.MemberPoint
|
import kr.co.vividnext.sodalive.point.MemberPoint
|
||||||
import kr.co.vividnext.sodalive.point.MemberPointRepository
|
import kr.co.vividnext.sodalive.point.MemberPointRepository
|
||||||
import kr.co.vividnext.sodalive.point.PointGrantLog
|
import kr.co.vividnext.sodalive.point.PointGrantLog
|
||||||
|
@ -29,7 +28,6 @@ class UserActionService(
|
||||||
private val memberPointRepository: MemberPointRepository,
|
private val memberPointRepository: MemberPointRepository,
|
||||||
private val transactionTemplate: TransactionTemplate,
|
private val transactionTemplate: TransactionTemplate,
|
||||||
|
|
||||||
private val fcmService: FcmService,
|
|
||||||
private val entityManager: EntityManager
|
private val entityManager: EntityManager
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
@ -44,8 +42,7 @@ class UserActionService(
|
||||||
isAuth: Boolean,
|
isAuth: Boolean,
|
||||||
actionType: ActionType,
|
actionType: ActionType,
|
||||||
contentId: Long? = null,
|
contentId: Long? = null,
|
||||||
contentCommentId: Long? = null,
|
contentCommentId: Long? = null
|
||||||
pushTokenList: List<String> = emptyList()
|
|
||||||
) {
|
) {
|
||||||
coroutineScope.launch {
|
coroutineScope.launch {
|
||||||
val now = LocalDateTime.now()
|
val now = LocalDateTime.now()
|
||||||
|
@ -171,13 +168,6 @@ class UserActionService(
|
||||||
expiresAt = now.plusDays(3)
|
expiresAt = now.plusDays(3)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
if (pushTokenList.isNotEmpty()) {
|
|
||||||
fcmService.sendPointGranted(
|
|
||||||
pushTokenList,
|
|
||||||
point
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue