Compare commits
No commits in common. "b27d3bd5c66bfb1b910d263a198c8fc1addfa3e1" and "03ebc9cfe9f5bc3f3f2f618b4b8b253090461d38" have entirely different histories.
b27d3bd5c6
...
03ebc9cfe9
|
@ -3,6 +3,7 @@ package kr.co.vividnext.sodalive.content.comment
|
|||
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 kr.co.vividnext.sodalive.useraction.ActionType
|
||||
import kr.co.vividnext.sodalive.useraction.UserActionService
|
||||
import org.springframework.data.domain.Pageable
|
||||
|
@ -18,6 +19,7 @@ import org.springframework.web.bind.annotation.RestController
|
|||
@RestController
|
||||
class AudioContentCommentController(
|
||||
private val service: AudioContentCommentService,
|
||||
private val memberService: MemberService,
|
||||
private val userActionService: UserActionService
|
||||
) {
|
||||
@PostMapping("/audio-content/comment")
|
||||
|
@ -36,11 +38,15 @@ class AudioContentCommentController(
|
|||
)
|
||||
|
||||
try {
|
||||
val memberId = member.id!!
|
||||
val pushTokenList = memberService.getPushTokenList(recipient = memberId)
|
||||
|
||||
userActionService.recordAction(
|
||||
memberId = member.id!!,
|
||||
isAuth = member.auth != null,
|
||||
actionType = ActionType.CONTENT_COMMENT,
|
||||
contentCommentId = commentId
|
||||
contentCommentId = commentId,
|
||||
pushTokenList = pushTokenList
|
||||
)
|
||||
|
||||
userActionService.recordAction(
|
||||
|
@ -48,7 +54,8 @@ class AudioContentCommentController(
|
|||
isAuth = member.auth != null,
|
||||
actionType = ActionType.ORDER_CONTENT_COMMENT,
|
||||
contentId = request.contentId,
|
||||
contentCommentId = commentId
|
||||
contentCommentId = commentId,
|
||||
pushTokenList = pushTokenList
|
||||
)
|
||||
} catch (_: Exception) {
|
||||
}
|
||||
|
|
|
@ -66,7 +66,12 @@ class MemberController(
|
|||
userActionService.recordAction(
|
||||
memberId = response.memberId,
|
||||
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)
|
||||
|
@ -355,7 +360,12 @@ class MemberController(
|
|||
userActionService.recordAction(
|
||||
memberId = response.memberId,
|
||||
isAuth = false,
|
||||
actionType = ActionType.SIGN_UP
|
||||
actionType = ActionType.SIGN_UP,
|
||||
pushTokenList = if (request.pushToken != null) {
|
||||
listOf(request.pushToken)
|
||||
} else {
|
||||
emptyList()
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -386,7 +396,12 @@ class MemberController(
|
|||
userActionService.recordAction(
|
||||
memberId = response.memberId,
|
||||
isAuth = false,
|
||||
actionType = ActionType.SIGN_UP
|
||||
actionType = ActionType.SIGN_UP,
|
||||
pushTokenList = if (request.pushToken != null) {
|
||||
listOf(request.pushToken)
|
||||
} else {
|
||||
emptyList()
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ package kr.co.vividnext.sodalive.member.auth
|
|||
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 kr.co.vividnext.sodalive.useraction.ActionType
|
||||
import kr.co.vividnext.sodalive.useraction.UserActionService
|
||||
import org.springframework.security.core.annotation.AuthenticationPrincipal
|
||||
|
@ -15,6 +16,7 @@ import org.springframework.web.bind.annotation.RestController
|
|||
@RequestMapping("/auth")
|
||||
class AuthController(
|
||||
private val service: AuthService,
|
||||
private val memberService: MemberService,
|
||||
private val userActionService: UserActionService
|
||||
) {
|
||||
@PostMapping
|
||||
|
@ -34,10 +36,13 @@ class AuthController(
|
|||
val authResponse = service.authenticate(authenticateData, member.id!!)
|
||||
|
||||
try {
|
||||
val memberId = member.id!!
|
||||
val pushTokenList = memberService.getPushTokenList(recipient = memberId)
|
||||
userActionService.recordAction(
|
||||
memberId = member.id!!,
|
||||
isAuth = true,
|
||||
actionType = ActionType.USER_AUTHENTICATION
|
||||
actionType = ActionType.USER_AUTHENTICATION,
|
||||
pushTokenList = pushTokenList
|
||||
)
|
||||
} catch (_: Exception) {
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ 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
|
||||
|
@ -11,7 +12,10 @@ import org.springframework.web.bind.annotation.RestController
|
|||
|
||||
@RestController
|
||||
@RequestMapping("/user-action")
|
||||
class UserActionController(private val service: UserActionService) {
|
||||
class UserActionController(
|
||||
private val service: UserActionService,
|
||||
private val memberService: MemberService
|
||||
) {
|
||||
@PostMapping
|
||||
fun recordAction(
|
||||
@RequestBody request: UserActionRequest,
|
||||
|
@ -19,10 +23,13 @@ class UserActionController(private val service: UserActionService) {
|
|||
) = run {
|
||||
if (member == null) throw SodaException("")
|
||||
|
||||
val memberId = member.id!!
|
||||
val pushTokenList = memberService.getPushTokenList(recipient = memberId)
|
||||
service.recordAction(
|
||||
memberId = member.id!!,
|
||||
memberId = memberId,
|
||||
isAuth = member.auth != null,
|
||||
actionType = request.actionType
|
||||
actionType = request.actionType,
|
||||
pushTokenList = pushTokenList
|
||||
)
|
||||
|
||||
ApiResponse.ok(Unit, "")
|
||||
|
|
|
@ -7,6 +7,7 @@ import kotlinx.coroutines.cancel
|
|||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
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.MemberPointRepository
|
||||
import kr.co.vividnext.sodalive.point.PointGrantLog
|
||||
|
@ -28,6 +29,7 @@ class UserActionService(
|
|||
private val memberPointRepository: MemberPointRepository,
|
||||
private val transactionTemplate: TransactionTemplate,
|
||||
|
||||
private val fcmService: FcmService,
|
||||
private val entityManager: EntityManager
|
||||
) {
|
||||
|
||||
|
@ -42,7 +44,8 @@ class UserActionService(
|
|||
isAuth: Boolean,
|
||||
actionType: ActionType,
|
||||
contentId: Long? = null,
|
||||
contentCommentId: Long? = null
|
||||
contentCommentId: Long? = null,
|
||||
pushTokenList: List<String> = emptyList()
|
||||
) {
|
||||
coroutineScope.launch {
|
||||
val now = LocalDateTime.now()
|
||||
|
@ -168,6 +171,13 @@ class UserActionService(
|
|||
expiresAt = now.plusDays(3)
|
||||
)
|
||||
)
|
||||
|
||||
if (pushTokenList.isNotEmpty()) {
|
||||
fcmService.sendPointGranted(
|
||||
pushTokenList,
|
||||
point
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue