fix(quota)!: AI 채팅 쿼터(무료/유료) 구매 Response를 ChatQuotaStatusResponse으로 변경
This commit is contained in:
parent
6ecac8d331
commit
048c48d754
|
@ -24,9 +24,7 @@ class ChatQuotaController(
|
|||
)
|
||||
|
||||
data class ChatQuotaPurchaseRequest(
|
||||
val container: String,
|
||||
val addPaid: Int = 50,
|
||||
val needCan: Int = 30
|
||||
val container: String
|
||||
)
|
||||
|
||||
@GetMapping("/me")
|
||||
|
@ -44,7 +42,7 @@ class ChatQuotaController(
|
|||
fun purchaseQuota(
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?,
|
||||
@RequestBody request: ChatQuotaPurchaseRequest
|
||||
): ApiResponse<Boolean> = run {
|
||||
): ApiResponse<ChatQuotaStatusResponse> = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member.auth == null) throw SodaException("본인인증을 하셔야 합니다.")
|
||||
if (request.container.isBlank()) throw SodaException("container를 확인해주세요.")
|
||||
|
@ -52,14 +50,16 @@ class ChatQuotaController(
|
|||
// 30캔 차감 처리 (결제 기록 남김)
|
||||
canPaymentService.spendCan(
|
||||
memberId = member.id!!,
|
||||
needCan = if (request.needCan > 0) request.needCan else 30,
|
||||
needCan = 30,
|
||||
canUsage = CanUsage.CHAT_QUOTA_PURCHASE,
|
||||
container = request.container
|
||||
)
|
||||
|
||||
// 유료 횟수 적립 (기본 50)
|
||||
val add = if (request.addPaid > 0) request.addPaid else 50
|
||||
val add = 50
|
||||
chatQuotaService.purchase(member.id!!, add)
|
||||
ApiResponse.ok(true)
|
||||
|
||||
val s = chatQuotaService.getStatus(member.id!!)
|
||||
ApiResponse.ok(ChatQuotaStatusResponse(s.totalRemaining, s.nextRechargeAtEpochMillis))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue