캐릭터 챗봇 #338
| @@ -24,9 +24,7 @@ class ChatQuotaController( | |||||||
|     ) |     ) | ||||||
|  |  | ||||||
|     data class ChatQuotaPurchaseRequest( |     data class ChatQuotaPurchaseRequest( | ||||||
|         val container: String, |         val container: String | ||||||
|         val addPaid: Int = 50, |  | ||||||
|         val needCan: Int = 30 |  | ||||||
|     ) |     ) | ||||||
|  |  | ||||||
|     @GetMapping("/me") |     @GetMapping("/me") | ||||||
| @@ -44,7 +42,7 @@ class ChatQuotaController( | |||||||
|     fun purchaseQuota( |     fun purchaseQuota( | ||||||
|         @AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?, |         @AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?, | ||||||
|         @RequestBody request: ChatQuotaPurchaseRequest |         @RequestBody request: ChatQuotaPurchaseRequest | ||||||
|     ): ApiResponse<Boolean> = run { |     ): ApiResponse<ChatQuotaStatusResponse> = run { | ||||||
|         if (member == null) throw SodaException("로그인 정보를 확인해주세요.") |         if (member == null) throw SodaException("로그인 정보를 확인해주세요.") | ||||||
|         if (member.auth == null) throw SodaException("본인인증을 하셔야 합니다.") |         if (member.auth == null) throw SodaException("본인인증을 하셔야 합니다.") | ||||||
|         if (request.container.isBlank()) throw SodaException("container를 확인해주세요.") |         if (request.container.isBlank()) throw SodaException("container를 확인해주세요.") | ||||||
| @@ -52,14 +50,16 @@ class ChatQuotaController( | |||||||
|         // 30캔 차감 처리 (결제 기록 남김) |         // 30캔 차감 처리 (결제 기록 남김) | ||||||
|         canPaymentService.spendCan( |         canPaymentService.spendCan( | ||||||
|             memberId = member.id!!, |             memberId = member.id!!, | ||||||
|             needCan = if (request.needCan > 0) request.needCan else 30, |             needCan = 30, | ||||||
|             canUsage = CanUsage.CHAT_QUOTA_PURCHASE, |             canUsage = CanUsage.CHAT_QUOTA_PURCHASE, | ||||||
|             container = request.container |             container = request.container | ||||||
|         ) |         ) | ||||||
|  |  | ||||||
|         // 유료 횟수 적립 (기본 50) |         // 유료 횟수 적립 (기본 50) | ||||||
|         val add = if (request.addPaid > 0) request.addPaid else 50 |         val add = 50 | ||||||
|         chatQuotaService.purchase(member.id!!, add) |         chatQuotaService.purchase(member.id!!, add) | ||||||
|         ApiResponse.ok(true) |  | ||||||
|  |         val s = chatQuotaService.getStatus(member.id!!) | ||||||
|  |         ApiResponse.ok(ChatQuotaStatusResponse(s.totalRemaining, s.nextRechargeAtEpochMillis)) | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user