Skip to content

Commit cd22572

Browse files
authored
[merge] 전체 옵션 오류 해결 #212
[fix] 전체 옵션 오류 해결 #212
2 parents ea857a1 + e8f2e0f commit cd22572

File tree

2 files changed

+46
-12
lines changed

2 files changed

+46
-12
lines changed

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
package com.back.domain.chatbot.dto;
22

3-
import com.back.domain.cocktail.enums.AlcoholBaseType;
4-
import com.back.domain.cocktail.enums.AlcoholStrength;
5-
import com.back.domain.cocktail.enums.CocktailType;
63
import jakarta.validation.constraints.NotBlank;
74
import lombok.Getter;
85
import lombok.NoArgsConstructor;
@@ -21,7 +18,7 @@ public class ChatRequestDto {
2118
// 단계별 추천 관련 필드들
2219
private boolean isStepRecommendation = false;
2320
private Integer currentStep;
24-
private AlcoholStrength selectedAlcoholStrength;
25-
private AlcoholBaseType selectedAlcoholBaseType;
26-
private CocktailType selectedCocktailType;
21+
private String selectedAlcoholStrength; // "ALL" 처리를 위해 스텝 3개 String으로 변경
22+
private String selectedAlcoholBaseType;
23+
private String selectedCocktailType;
2724
}

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

Lines changed: 43 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -422,25 +422,25 @@ private ChatResponseDto handleStepRecommendation(ChatRequestDto requestDto) {
422422
break;
423423

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

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

439439
case 4:
440440
stepData = getFinalRecommendations(
441-
requestDto.getSelectedAlcoholStrength(),
442-
requestDto.getSelectedAlcoholBaseType(),
443-
requestDto.getSelectedCocktailType()
441+
parseAlcoholStrength(requestDto.getSelectedAlcoholStrength()),
442+
parseAlcoholBaseType(requestDto.getSelectedAlcoholBaseType()),
443+
parseCocktailType(requestDto.getSelectedCocktailType())
444444
);
445445
message = stepData.getStepTitle();
446446
type = MessageType.CARD_LIST; // 최종 추천은 카드 리스트
@@ -470,6 +470,43 @@ private ChatResponseDto handleStepRecommendation(ChatRequestDto requestDto) {
470470
}
471471

472472
// ============ 단계별 추천 관련 메서드들 ============
473+
// "ALL" 또는 null/빈값은 null로 처리하여 전체 선택 의미
474+
475+
private AlcoholStrength parseAlcoholStrength(String value) {
476+
if (value == null || value.trim().isEmpty() || "ALL".equalsIgnoreCase(value)) {
477+
return null;
478+
}
479+
try {
480+
return AlcoholStrength.valueOf(value);
481+
} catch (IllegalArgumentException e) {
482+
log.warn("Invalid AlcoholStrength value: {}", value);
483+
return null;
484+
}
485+
}
486+
487+
private AlcoholBaseType parseAlcoholBaseType(String value) {
488+
if (value == null || value.trim().isEmpty() || "ALL".equalsIgnoreCase(value)) {
489+
return null;
490+
}
491+
try {
492+
return AlcoholBaseType.valueOf(value);
493+
} catch (IllegalArgumentException e) {
494+
log.warn("Invalid AlcoholBaseType value: {}", value);
495+
return null;
496+
}
497+
}
498+
499+
private CocktailType parseCocktailType(String value) {
500+
if (value == null || value.trim().isEmpty() || "ALL".equalsIgnoreCase(value)) {
501+
return null;
502+
}
503+
try {
504+
return CocktailType.valueOf(value);
505+
} catch (IllegalArgumentException e) {
506+
log.warn("Invalid CocktailType value: {}", value);
507+
return null;
508+
}
509+
}
473510

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

0 commit comments

Comments
 (0)