Skip to content

Commit

Permalink
Refactor: 예민도 테스트 결과 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
yso8296 committed Nov 15, 2024
1 parent 670188e commit b59132b
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<VaccinationRecommendDto> vaccinationRecommendDtos = vaccinationRecommendRepository.findByAgeRange(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/hackathon/nullnullteam/member/Member.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

0 comments on commit b59132b

Please sign in to comment.