Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
wellbeing-dough committed Sep 24, 2023
2 parents 74efbd6 + 552d068 commit 1b73b1d
Showing 1 changed file with 33 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,14 @@ public class VoteWithPostedUserData {
private String region;
private LocalDateTime createdAt;
private GenderType postedUserGender;
private Integer postedUserAge;
private AgeType postedUserAge;
private MbtiType postedUserMbti;
private AlcoholLimitType postedUserAlcoholLimit;
private String postedUserNickname;
private String postedUserImageUrl;

public static VoteWithPostedUserData generateNormalVoteData(VoteWithPostedUserCommonData voteCommonData, VoteContent voteContent) {
AgeType classifiedAge = classifyAge(voteCommonData.getPostedUserAge());
return VoteWithPostedUserData.builder()
.voteId(voteCommonData.getVoteId())
.postedUserId(voteCommonData.getPostedUserId())
Expand All @@ -58,7 +59,7 @@ public static VoteWithPostedUserData generateNormalVoteData(VoteWithPostedUserCo
.votedCount(voteCommonData.getVotedCount())
.createdAt(voteCommonData.getCreatedAt())
.postedUserGender(voteCommonData.getPostedUserGender())
.postedUserAge(voteCommonData.getPostedUserAge())
.postedUserAge(classifiedAge)
.postedUserMbti(voteCommonData.getPostedUserMbti())
.postedUserAlcoholLimit(voteCommonData.getPostedUserAlcoholLimit())
.postedUserNickname(voteCommonData.getPostedUserNickname())
Expand All @@ -67,6 +68,7 @@ public static VoteWithPostedUserData generateNormalVoteData(VoteWithPostedUserCo
}

public static VoteWithPostedUserData generateDrinkVoteData(VoteWithPostedUserCommonData voteCommonData, VoteDrinkContent voteDrinkContent) {
AgeType classifiedAge = classifyAge(voteCommonData.getPostedUserAge());
return VoteWithPostedUserData.builder()
.voteId(voteCommonData.getVoteId())
.postedUserId(voteCommonData.getPostedUserId())
Expand All @@ -84,11 +86,39 @@ public static VoteWithPostedUserData generateDrinkVoteData(VoteWithPostedUserCom
.region(voteDrinkContent.getRegion())
.createdAt(voteCommonData.getCreatedAt())
.postedUserGender(voteCommonData.getPostedUserGender())
.postedUserAge(voteCommonData.getPostedUserAge())
.postedUserAge(classifiedAge)
.postedUserMbti(voteCommonData.getPostedUserMbti())
.postedUserAlcoholLimit(voteCommonData.getPostedUserAlcoholLimit())
.postedUserNickname(voteCommonData.getPostedUserNickname())
.postedUserImageUrl(voteCommonData.getPostedUserImageUrl())
.build();
}

public static AgeType classifyAge(Integer age) {
if (age == null) {
return AgeType.NULL; // 혹은 원하는 다른 동작 수행
}
AgeType ageGroup;
switch (age / 10) {
case 1:
ageGroup = AgeType.teenager;
break;
case 2:
ageGroup = AgeType.twenties;
break;
case 3:
ageGroup = AgeType.thirties;
break;
case 4:
ageGroup = AgeType.fourties;
break;
case 5:
ageGroup = AgeType.fifties;
break;
default:
ageGroup = AgeType.NULL;
break;
}
return ageGroup;
}
}

0 comments on commit 1b73b1d

Please sign in to comment.