Skip to content

Commit c6b22bb

Browse files
authored
[feat] 챗봇 - input 추가 및 마지막 단계 삭제 #236
[feat] 챗봇 - input 추가 및 마지막 단계 삭제 #236
2 parents f097852 + 107f333 commit c6b22bb

File tree

3 files changed

+14
-54
lines changed

3 files changed

+14
-54
lines changed

src/main/java/com/back/domain/chatbot/dto/ChatRequestDto.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ public class ChatRequestDto {
2323
private boolean isStepRecommendation = false;
2424

2525
private Integer currentStep;
26-
// "ALL" 처리를 위해 스텝 3개 String으로 변경
26+
// "ALL" 처리를 위해 스텝 2개 String으로 변경
2727
private String selectedAlcoholStrength;
2828
private String selectedAlcoholBaseType;
29-
private String selectedCocktailType;
29+
// selectedCocktailType 삭제
3030
}

src/main/java/com/back/domain/chatbot/enums/MessageType.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ public enum MessageType {
55
RADIO_OPTIONS("라디오옵션"), // 라디오 버튼 선택지
66
CARD_LIST("카드리스트"), // 칵테일 추천 카드 리스트
77
LOADING("로딩중"), // 로딩 메시지
8-
ERROR("에러"); // 에러 메시지
8+
ERROR("에러"), // 에러 메시지
9+
INPUT("입력"); // 텍스트 입력 요청
910

1011
private final String description;
1112

src/main/java/com/back/domain/chatbot/service/ChatbotService.java

Lines changed: 10 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import com.back.domain.cocktail.entity.Cocktail;
1313
import com.back.domain.cocktail.enums.AlcoholBaseType;
1414
import com.back.domain.cocktail.enums.AlcoholStrength;
15-
import com.back.domain.cocktail.enums.CocktailType;
1615
import com.back.domain.cocktail.repository.CocktailRepository;
1716
import jakarta.annotation.PostConstruct;
1817
import lombok.RequiredArgsConstructor;
@@ -496,19 +495,16 @@ private ChatResponseDto handleStepRecommendation(ChatRequestDto requestDto) {
496495
break;
497496

498497
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;
505501
break;
506502

507503
case 4:
508-
stepData = getFinalRecommendations(
504+
stepData = getFinalRecommendationsWithMessage(
509505
parseAlcoholStrength(requestDto.getSelectedAlcoholStrength()),
510506
parseAlcoholBaseType(requestDto.getSelectedAlcoholBaseType()),
511-
parseCocktailType(requestDto.getSelectedCocktailType())
507+
requestDto.getMessage()
512508
);
513509
message = stepData.getStepTitle();
514510
type = MessageType.CARD_LIST; // 최종 추천은 카드 리스트
@@ -585,17 +581,6 @@ private AlcoholBaseType parseAlcoholBaseType(String value) {
585581
}
586582
}
587583

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-
}
599584

600585
private StepRecommendationResponseDto getAlcoholStrengthOptions() {
601586
List<StepRecommendationResponseDto.StepOption> options = new ArrayList<>();
@@ -651,47 +636,21 @@ private StepRecommendationResponseDto getAlcoholBaseTypeOptions(AlcoholStrength
651636
);
652637
}
653638

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-
}
680639

681-
private StepRecommendationResponseDto getFinalRecommendations(
640+
private StepRecommendationResponseDto getFinalRecommendationsWithMessage(
682641
AlcoholStrength alcoholStrength,
683642
AlcoholBaseType alcoholBaseType,
684-
CocktailType cocktailType) {
643+
String userMessage) {
685644
// 필터링 조건에 맞는 칵테일 검색
686645
// "ALL" 선택 시 해당 필터를 null로 처리하여 전체 검색
687646
List<AlcoholStrength> strengths = (alcoholStrength == null) ? null : List.of(alcoholStrength);
688647
List<AlcoholBaseType> baseTypes = (alcoholBaseType == null) ? null : List.of(alcoholBaseType);
689-
List<CocktailType> cocktailTypes = (cocktailType == null) ? null : List.of(cocktailType);
690648

649+
// userMessage를 키워드로 사용하여 검색
691650
Page<Cocktail> cocktailPage = cocktailRepository.searchWithFilters(
692-
null, // 키워드 없음
651+
userMessage, // 사용자 입력 메시지를 키워드로 사용
693652
strengths,
694-
cocktailTypes,
653+
null, // cocktailType 사용 안 함
695654
baseTypes,
696655
PageRequest.of(0, 3) // 최대 3개 추천
697656
);

0 commit comments

Comments
 (0)