feat(chat): 채팅방 초기화 API 추가 및 세션 종료 실패 시 롤백 처리

- /api/chat/room/{chatRoomId}/reset POST 엔드포인트 추가
- 초기화 절차: 30캔 결제 → 기존 방 나가기 → 동일 캐릭터로 새 방 생성 → 응답 반환
- 결제 시 CanUsage.CHAT_ROOM_RESET 신규 항목 사용(본인 귀속)
- ChatQuotaService.resetFreeToDefault 추가 및 초기화 성공 시 무료 10회로 리셋(nextRechargeAt 초기화)
- 사용내역 타이틀에 "캐릭터 톡 초기화" 노출(CanService)
- ChatRoomResetRequest DTO(container 포함) 추가
- leaveChatRoom에 throwOnSessionEndFailure 옵션 추가(기본 false 유지)
- endExternalSession에 throwOnFailure 옵션 추가: 최대 3회 재시도 후 실패 시 예외 전파 가능
- 채팅방 초기화 흐름에서는 외부 세션 종료 실패 시 예외를 던져 트랜잭션 롤백되도록 처리
This commit is contained in:
2025-08-27 17:16:18 +09:00
parent 258943535c
commit 42ed4692af
8 changed files with 92 additions and 8 deletions

View File

@@ -72,4 +72,11 @@ class ChatQuotaService(
quota.remainingPaid += addPaid
quota.nextRechargeAt = null
}
@Transactional
fun resetFreeToDefault(memberId: Long) {
val quota = repo.findForUpdate(memberId) ?: repo.save(ChatQuota(memberId = memberId))
quota.remainingFree = FREE_BUCKET
quota.nextRechargeAt = null
}
}