|
12 | 12 | import com.back.domain.cocktail.entity.Cocktail; |
13 | 13 | import com.back.domain.cocktail.enums.AlcoholBaseType; |
14 | 14 | import com.back.domain.cocktail.enums.AlcoholStrength; |
15 | | -import com.back.domain.cocktail.enums.CocktailType; |
16 | 15 | import com.back.domain.cocktail.repository.CocktailRepository; |
17 | 16 | import jakarta.annotation.PostConstruct; |
18 | 17 | import lombok.RequiredArgsConstructor; |
@@ -496,19 +495,16 @@ private ChatResponseDto handleStepRecommendation(ChatRequestDto requestDto) { |
496 | 495 | break; |
497 | 496 |
|
498 | 497 | case 3: |
499 | | - stepData = getCocktailTypeOptions( |
500 | | - parseAlcoholStrength(requestDto.getSelectedAlcoholStrength()), |
501 | | - parseAlcoholBaseType(requestDto.getSelectedAlcoholBaseType()) |
502 | | - ); |
503 | | - message = "완벽해요! 마지막으로 어떤 스타일로 즐기실 건가요? 🥃"; |
504 | | - type = MessageType.RADIO_OPTIONS; |
| 498 | + stepData = null; |
| 499 | + message = "좋아요! 이제 원하는 칵테일 스타일을 자유롭게 말씀해주세요 💬\n 없으면 'x', 또는 '없음' 과 같이 입력해주세요!"; |
| 500 | + type = MessageType.INPUT; |
505 | 501 | break; |
506 | 502 |
|
507 | 503 | case 4: |
508 | | - stepData = getFinalRecommendations( |
| 504 | + stepData = getFinalRecommendationsWithMessage( |
509 | 505 | parseAlcoholStrength(requestDto.getSelectedAlcoholStrength()), |
510 | 506 | parseAlcoholBaseType(requestDto.getSelectedAlcoholBaseType()), |
511 | | - parseCocktailType(requestDto.getSelectedCocktailType()) |
| 507 | + requestDto.getMessage() |
512 | 508 | ); |
513 | 509 | message = stepData.getStepTitle(); |
514 | 510 | type = MessageType.CARD_LIST; // 최종 추천은 카드 리스트 |
@@ -585,17 +581,6 @@ private AlcoholBaseType parseAlcoholBaseType(String value) { |
585 | 581 | } |
586 | 582 | } |
587 | 583 |
|
588 | | - private CocktailType parseCocktailType(String value) { |
589 | | - if (value == null || value.trim().isEmpty() || "ALL".equalsIgnoreCase(value)) { |
590 | | - return null; |
591 | | - } |
592 | | - try { |
593 | | - return CocktailType.valueOf(value); |
594 | | - } catch (IllegalArgumentException e) { |
595 | | - log.warn("Invalid CocktailType value: {}", value); |
596 | | - return null; |
597 | | - } |
598 | | - } |
599 | 584 |
|
600 | 585 | private StepRecommendationResponseDto getAlcoholStrengthOptions() { |
601 | 586 | List<StepRecommendationResponseDto.StepOption> options = new ArrayList<>(); |
@@ -651,47 +636,21 @@ private StepRecommendationResponseDto getAlcoholBaseTypeOptions(AlcoholStrength |
651 | 636 | ); |
652 | 637 | } |
653 | 638 |
|
654 | | - private StepRecommendationResponseDto getCocktailTypeOptions(AlcoholStrength alcoholStrength, AlcoholBaseType alcoholBaseType) { |
655 | | - List<StepRecommendationResponseDto.StepOption> options = new ArrayList<>(); |
656 | | - |
657 | | - // "전체" 옵션 추가 |
658 | | - options.add(new StepRecommendationResponseDto.StepOption( |
659 | | - "ALL", |
660 | | - "전체", |
661 | | - null |
662 | | - )); |
663 | | - |
664 | | - for (CocktailType cocktailType : CocktailType.values()) { |
665 | | - options.add(new StepRecommendationResponseDto.StepOption( |
666 | | - cocktailType.name(), |
667 | | - cocktailType.getDescription(), |
668 | | - null |
669 | | - )); |
670 | | - } |
671 | | - |
672 | | - return new StepRecommendationResponseDto( |
673 | | - 3, |
674 | | - "어떤 종류의 잔으로 드시겠어요?", |
675 | | - options, |
676 | | - null, |
677 | | - false |
678 | | - ); |
679 | | - } |
680 | 639 |
|
681 | | - private StepRecommendationResponseDto getFinalRecommendations( |
| 640 | + private StepRecommendationResponseDto getFinalRecommendationsWithMessage( |
682 | 641 | AlcoholStrength alcoholStrength, |
683 | 642 | AlcoholBaseType alcoholBaseType, |
684 | | - CocktailType cocktailType) { |
| 643 | + String userMessage) { |
685 | 644 | // 필터링 조건에 맞는 칵테일 검색 |
686 | 645 | // "ALL" 선택 시 해당 필터를 null로 처리하여 전체 검색 |
687 | 646 | List<AlcoholStrength> strengths = (alcoholStrength == null) ? null : List.of(alcoholStrength); |
688 | 647 | List<AlcoholBaseType> baseTypes = (alcoholBaseType == null) ? null : List.of(alcoholBaseType); |
689 | | - List<CocktailType> cocktailTypes = (cocktailType == null) ? null : List.of(cocktailType); |
690 | 648 |
|
| 649 | + // userMessage를 키워드로 사용하여 검색 |
691 | 650 | Page<Cocktail> cocktailPage = cocktailRepository.searchWithFilters( |
692 | | - null, // 키워드 없음 |
| 651 | + userMessage, // 사용자 입력 메시지를 키워드로 사용 |
693 | 652 | strengths, |
694 | | - cocktailTypes, |
| 653 | + null, // cocktailType 사용 안 함 |
695 | 654 | baseTypes, |
696 | 655 | PageRequest.of(0, 3) // 최대 3개 추천 |
697 | 656 | ); |
|
0 commit comments