feat: 유저 행동 데이터 기록 추가 - 콘텐츠에 댓글 쓰기

This commit is contained in:
2025-05-16 20:32:48 +09:00
parent eb8c8c14e8
commit ddcd54d3b9
7 changed files with 132 additions and 52 deletions

View File

@@ -66,7 +66,11 @@ class MemberController(
userActionService.recordAction(
memberId = response.memberId,
actionType = ActionType.SIGN_UP,
pushToken = request.pushToken
pushTokenList = if (request.pushToken != null) {
listOf(request.pushToken)
} else {
emptyList()
}
)
return ApiResponse.ok(message = "회원가입을 축하드립니다.", data = response.loginResponse)
@@ -355,7 +359,11 @@ class MemberController(
userActionService.recordAction(
memberId = response.memberId,
actionType = ActionType.SIGN_UP,
pushToken = request.pushToken
pushTokenList = if (request.pushToken != null) {
listOf(request.pushToken)
} else {
emptyList()
}
)
}
@@ -386,7 +394,11 @@ class MemberController(
userActionService.recordAction(
memberId = response.memberId,
actionType = ActionType.SIGN_UP,
pushToken = request.pushToken
pushTokenList = if (request.pushToken != null) {
listOf(request.pushToken)
} else {
emptyList()
}
)
}

View File

@@ -64,6 +64,8 @@ interface MemberQueryRepository {
fun existsByNickname(nickname: String): Boolean
fun findNicknamesWithPrefix(prefix: String): List<String>
fun getPushTokenList(memberId: Long): List<String>
}
@Repository
@@ -507,4 +509,17 @@ class MemberQueryRepositoryImpl(
)
.fetch()
}
override fun getPushTokenList(memberId: Long): List<String> {
val where = member.isActive.isTrue
.and(member.email.notIn("admin@sodalive.net"))
.and(member.id.eq(memberId))
return queryFactory
.select(pushToken.token)
.from(member)
.innerJoin(pushToken).on(member.id.eq(pushToken.member.id))
.where(where)
.fetch()
}
}

View File

@@ -907,6 +907,12 @@ class MemberService(
return MemberResolveResult(member = member, isNew = true)
}
fun getPushTokenList(recipient: Long): List<String> {
return repository.getPushTokenList(recipient)
.toSet()
.toList()
}
private fun checkEmail(email: String) {
val member = repository.findByEmail(email)

View File

@@ -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
@@ -33,11 +35,16 @@ class AuthController(
val authResponse = service.authenticate(authenticateData, member.id!!)
userActionService.recordAction(
memberId = member.id!!,
actionType = ActionType.USER_AUTHENTICATION,
pushToken = member.pushToken
)
try {
val memberId = member.id!!
val pushTokenList = memberService.getPushTokenList(recipient = memberId)
userActionService.recordAction(
memberId = member.id!!,
actionType = ActionType.USER_AUTHENTICATION,
pushTokenList = pushTokenList
)
} catch (_: Exception) {
}
ApiResponse.ok(authResponse)
}