marketing info 업데이트 API 생성

This commit is contained in:
Klaus 2025-03-04 12:27:17 +09:00
parent 3216c73ee8
commit 83ed4b6961
3 changed files with 37 additions and 0 deletions

View File

@ -0,0 +1,6 @@
package kr.co.vividnext.sodalive.member
data class MarketingInfoUpdateRequest(
val adid: String,
val pid: String
)

View File

@ -128,6 +128,22 @@ class MemberController(
) )
} }
@PutMapping("/marketing-info/update")
fun updateMarketingInfo(
@RequestBody request: MarketingInfoUpdateRequest,
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
) = run {
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
ApiResponse.ok(
service.updateMarketingInfo(
memberId = member.id!!,
adid = request.adid,
pid = request.pid
)
)
}
@PutMapping("/adid/update") @PutMapping("/adid/update")
fun updateAdid( fun updateAdid(
@RequestBody request: AdidUpdateRequest, @RequestBody request: AdidUpdateRequest,

View File

@ -646,4 +646,19 @@ class MemberService(
private fun getOrCreateLock(memberId: Long): ReentrantReadWriteLock { private fun getOrCreateLock(memberId: Long): ReentrantReadWriteLock {
return tokenLocks.computeIfAbsent(memberId) { ReentrantReadWriteLock() } return tokenLocks.computeIfAbsent(memberId) { ReentrantReadWriteLock() }
} }
@Transactional
fun updateMarketingInfo(memberId: Long, adid: String, pid: String) {
val member = repository.findByIdOrNull(id = memberId)
?: throw SodaException("로그인 정보를 확인해주세요.")
if (adid != member.adid) {
member.adid = adid
}
if (pid != member.activePid) {
member.activePid = pid
member.partnerExpirationDateTime = LocalDateTime.now().plusYears(1)
}
}
} }