Refactor/#66 chatbot api - #69
Conversation
Feat/#61 slot generator
- 취소/노쇼 예약 내역 조회 AI Tool 추가 - 주변 인기 맛집 추천 AI Tool 추가 (반경 3km, 인기순 정렬) - 예약 가능 시간대 조회 AI Tool 추가 - 챗봇 요청에 위치 좌표(latitude/longitude) 필드 추가 - 쿠폰 목록 API Cache-Control: no-store 추가 - 챗봇 대화 내역 조회 시 세션 없으면 빈 목록 반환으로 수정 - SecurityConfig ASYNC DispatcherType 설정 제거 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- N+1 쿼리 제거: PENDING orderId 조회 IN 쿼리 1회로 교체 (PaymentRepository) - DB 레벨 필터링: findAllByUserAndStatusIn 추가로 메모리 필터 제거 (ReservationRepository) - DB 레벨 매장 조회: findByStoreNameIgnoreCaseAndIsDeletedFalse 추가 (StoreRepository) - ThreadLocal 누수 방지: PendingPaymentHolder.clear() try-finally로 보장 (ChatbotService) - 챗봇 시스템 프롬프트 가드레일 6항목 추가 (역할고정, 범위제한, 프롬프트보호, 타인정보보호, 역할극거부, 개인정보수집금지) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Code Review
This pull request significantly enhances the chatbot's functionality by introducing location-aware store searches, reservation management tools (viewing and canceling), and a more sophisticated AI prompting system that includes history summarization and strict guardrails. It also implements a ThreadLocal mechanism to capture pending payment information during AI-driven reservation creation. Review feedback highlights several areas for improvement: ensuring store name uniqueness to prevent runtime exceptions, refactoring duplicated payment creation logic into a reusable method, externalizing hardcoded search radius values, and optimizing string concatenation in the history summarization logic for better performance.
| @Query("SELECT s.storeName FROM Store s WHERE s.isDeleted = false AND LOWER(s.storeName) LIKE LOWER(CONCAT('%', :name, '%')) ORDER BY s.storeName ASC") | ||
| List<String> findNamesByNameContaining(@Param("name") String name, Pageable pageable); | ||
|
|
||
| Optional<Store> findByStoreNameIgnoreCaseAndIsDeletedFalse(String storeName); |
There was a problem hiding this comment.
| String orderId = "CATCH-" + saved.getId() + "-" + System.currentTimeMillis(); | ||
| Payment payment = Payment.builder() | ||
| .reservation(saved) | ||
| .orderId(orderId) | ||
| .amount(DEPOSIT_AMOUNT) | ||
| .build(); | ||
| paymentRepository.save(payment); |
|
|
||
| double latitude = ((Number) lat).doubleValue(); | ||
| double longitude = ((Number) lon).doubleValue(); | ||
| double radiusMeters = 3000; |
| List<ChatMessage> older = history.subList(0, history.size() - SUMMARY_KEEP_RECENT); | ||
| String historyText = older.stream() | ||
| .map(m -> (m.getRole() == MessageRole.USER ? "사용자" : "AI") + ": " + m.getContent()) | ||
| .reduce("", (a, b) -> a + "\n" + b); |
There was a problem hiding this comment.
📢 기능 설명
챗봇 기능 확장 및 쿠폰 조회 버그 수정
챗봇 코드리뷰 반영 및 가드레일 추가
필요시 실행결과 스크린샷 첨부
연결된 issue
연결된 issue를 자동을 닫기 위해 아래 {이슈넘버}를 입력해주세요.
close #66
✅ 체크리스트