Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions src/main/java/com/back/domain/chatbot/dto/ChatRequestDto.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
package com.back.domain.chatbot.dto;

import com.back.domain.cocktail.enums.AlcoholBaseType;
import com.back.domain.cocktail.enums.AlcoholStrength;
import com.back.domain.cocktail.enums.CocktailType;
import jakarta.validation.constraints.NotBlank;
import lombok.Getter;
import lombok.NoArgsConstructor;
Expand All @@ -21,7 +18,7 @@ public class ChatRequestDto {
// 단계별 추천 관련 필드들
private boolean isStepRecommendation = false;
private Integer currentStep;
private AlcoholStrength selectedAlcoholStrength;
private AlcoholBaseType selectedAlcoholBaseType;
private CocktailType selectedCocktailType;
private String selectedAlcoholStrength; // "ALL" 처리를 위해 스텝 3개 String으로 변경
private String selectedAlcoholBaseType;
private String selectedCocktailType;
}
49 changes: 43 additions & 6 deletions src/main/java/com/back/domain/chatbot/service/ChatbotService.java
Original file line number Diff line number Diff line change
Expand Up @@ -422,25 +422,25 @@ private ChatResponseDto handleStepRecommendation(ChatRequestDto requestDto) {
break;

case 2:
stepData = getAlcoholBaseTypeOptions(requestDto.getSelectedAlcoholStrength());
stepData = getAlcoholBaseTypeOptions(parseAlcoholStrength(requestDto.getSelectedAlcoholStrength()));
message = "좋은 선택이네요! 이제 베이스가 될 술을 선택해주세요 🍸";
type = MessageType.RADIO_OPTIONS;
break;

case 3:
stepData = getCocktailTypeOptions(
requestDto.getSelectedAlcoholStrength(),
requestDto.getSelectedAlcoholBaseType()
parseAlcoholStrength(requestDto.getSelectedAlcoholStrength()),
parseAlcoholBaseType(requestDto.getSelectedAlcoholBaseType())
);
message = "완벽해요! 마지막으로 어떤 스타일로 즐기실 건가요? 🥃";
type = MessageType.RADIO_OPTIONS;
break;

case 4:
stepData = getFinalRecommendations(
requestDto.getSelectedAlcoholStrength(),
requestDto.getSelectedAlcoholBaseType(),
requestDto.getSelectedCocktailType()
parseAlcoholStrength(requestDto.getSelectedAlcoholStrength()),
parseAlcoholBaseType(requestDto.getSelectedAlcoholBaseType()),
parseCocktailType(requestDto.getSelectedCocktailType())
);
message = stepData.getStepTitle();
type = MessageType.CARD_LIST; // 최종 추천은 카드 리스트
Expand Down Expand Up @@ -470,6 +470,43 @@ private ChatResponseDto handleStepRecommendation(ChatRequestDto requestDto) {
}

// ============ 단계별 추천 관련 메서드들 ============
// "ALL" 또는 null/빈값은 null로 처리하여 전체 선택 의미

private AlcoholStrength parseAlcoholStrength(String value) {
if (value == null || value.trim().isEmpty() || "ALL".equalsIgnoreCase(value)) {
return null;
}
try {
return AlcoholStrength.valueOf(value);
} catch (IllegalArgumentException e) {
log.warn("Invalid AlcoholStrength value: {}", value);
return null;
}
}

private AlcoholBaseType parseAlcoholBaseType(String value) {
if (value == null || value.trim().isEmpty() || "ALL".equalsIgnoreCase(value)) {
return null;
}
try {
return AlcoholBaseType.valueOf(value);
} catch (IllegalArgumentException e) {
log.warn("Invalid AlcoholBaseType value: {}", value);
return null;
}
}

private CocktailType parseCocktailType(String value) {
if (value == null || value.trim().isEmpty() || "ALL".equalsIgnoreCase(value)) {
return null;
}
try {
return CocktailType.valueOf(value);
} catch (IllegalArgumentException e) {
log.warn("Invalid CocktailType value: {}", value);
return null;
}
}

private StepRecommendationResponseDto getAlcoholStrengthOptions() {
List<StepRecommendationResponseDto.StepOption> options = new ArrayList<>();
Expand Down