diff --git a/src/main/java/com/hackathon/nullnullteam/anxietyresultrecord/controller/dto/AnxietyResultRecordRequest.java b/src/main/java/com/hackathon/nullnullteam/anxietyresultrecord/controller/dto/AnxietyResultRecordRequest.java index 75b9ca3..7ad013d 100644 --- a/src/main/java/com/hackathon/nullnullteam/anxietyresultrecord/controller/dto/AnxietyResultRecordRequest.java +++ b/src/main/java/com/hackathon/nullnullteam/anxietyresultrecord/controller/dto/AnxietyResultRecordRequest.java @@ -7,12 +7,12 @@ public class AnxietyResultRecordRequest { @Builder public record Result( - int count + int score ) { public AnxietyResultRecordCommand.Result toCommand() { return AnxietyResultRecordCommand.Result.builder() - .count(count) + .score(score) .build(); } } diff --git a/src/main/java/com/hackathon/nullnullteam/anxietyresultrecord/service/AnxietyResultRecordService.java b/src/main/java/com/hackathon/nullnullteam/anxietyresultrecord/service/AnxietyResultRecordService.java index 03ba9d6..978d7a7 100644 --- a/src/main/java/com/hackathon/nullnullteam/anxietyresultrecord/service/AnxietyResultRecordService.java +++ b/src/main/java/com/hackathon/nullnullteam/anxietyresultrecord/service/AnxietyResultRecordService.java @@ -35,6 +35,7 @@ public void AnxietyTestResult(Long memberId, AnxietyResultRecordCommand.Result c Member member = memberReaderService.getMemberById(memberId); AnxietyResultRecord anxietyResultRecord = command.toEntity(member); anxietyResultRecordWriterService.save(anxietyResultRecord); + member.setAnxietyLevel(command.score()); // 백신 추천 정보를 조회 List vaccinationRecommendDtos = vaccinationRecommendRepository.findByAgeRange( diff --git a/src/main/java/com/hackathon/nullnullteam/anxietyresultrecord/service/dto/AnxietyResultRecordCommand.java b/src/main/java/com/hackathon/nullnullteam/anxietyresultrecord/service/dto/AnxietyResultRecordCommand.java index c94c6e2..429a392 100644 --- a/src/main/java/com/hackathon/nullnullteam/anxietyresultrecord/service/dto/AnxietyResultRecordCommand.java +++ b/src/main/java/com/hackathon/nullnullteam/anxietyresultrecord/service/dto/AnxietyResultRecordCommand.java @@ -9,14 +9,14 @@ public class AnxietyResultRecordCommand { @Builder public record Result( - int count + int score ) { public AnxietyResultRecord toEntity(Member member) { return AnxietyResultRecord.builder() .member(member) - .anxietyLevel(AnxietyLevel.fromString(count)) - .anxietyScore(count) + .anxietyLevel(AnxietyLevel.fromString(score)) + .anxietyScore(score) .build(); } } diff --git a/src/main/java/com/hackathon/nullnullteam/member/AnxietyLevel.java b/src/main/java/com/hackathon/nullnullteam/member/AnxietyLevel.java index 1c8b361..17215c6 100644 --- a/src/main/java/com/hackathon/nullnullteam/member/AnxietyLevel.java +++ b/src/main/java/com/hackathon/nullnullteam/member/AnxietyLevel.java @@ -15,12 +15,12 @@ public enum AnxietyLevel { this.description = description; } - public static AnxietyLevel fromString(int count) { - if (count <= 5) { + public static AnxietyLevel fromString(int score) { + if (score <= 50) { return LOW; - } else if (count <= 10) { + } else if (score <= 70) { return MEDIUM; - } else if (count <= 15) { + } else if (score <= 90) { return HIGH; } return VERY_HIGH; diff --git a/src/main/java/com/hackathon/nullnullteam/member/Member.java b/src/main/java/com/hackathon/nullnullteam/member/Member.java index 41777c4..38aa5b6 100644 --- a/src/main/java/com/hackathon/nullnullteam/member/Member.java +++ b/src/main/java/com/hackathon/nullnullteam/member/Member.java @@ -36,4 +36,8 @@ public class Member extends BaseTimeEntity { private AnxietyLevel anxietyLevel; private String profile; + + public void setAnxietyLevel(int score) { + this.anxietyLevel = AnxietyLevel.fromString(score); + } }