marketing info 업데이트 API 생성
This commit is contained in:
parent
3216c73ee8
commit
83ed4b6961
|
@ -0,0 +1,6 @@
|
|||
package kr.co.vividnext.sodalive.member
|
||||
|
||||
data class MarketingInfoUpdateRequest(
|
||||
val adid: String,
|
||||
val pid: String
|
||||
)
|
|
@ -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")
|
||||
fun updateAdid(
|
||||
@RequestBody request: AdidUpdateRequest,
|
||||
|
|
|
@ -646,4 +646,19 @@ class MemberService(
|
|||
private fun getOrCreateLock(memberId: Long): 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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue