diff --git a/src/main/java/com/example/mutsideout_mju/dto/response/user/ProfileResponseData.java b/src/main/java/com/example/mutsideout_mju/dto/response/user/ProfileResponseData.java index a33756f..3357806 100644 --- a/src/main/java/com/example/mutsideout_mju/dto/response/user/ProfileResponseData.java +++ b/src/main/java/com/example/mutsideout_mju/dto/response/user/ProfileResponseData.java @@ -1,21 +1,20 @@ package com.example.mutsideout_mju.dto.response.user; -import com.example.mutsideout_mju.entity.Grade; +import com.example.mutsideout_mju.entity.UserGrade; import lombok.Builder; import lombok.Getter; -import org.springframework.context.annotation.Profile; @Getter @Builder public class ProfileResponseData { private String email; private String name; - private Grade grade; + private UserGrade userGrade; - public static ProfileResponseData of(String email, String name, Grade grade) { + public static ProfileResponseData of(String email, String name, UserGrade userGrade) { return builder() .email(email) - .grade(grade) + .userGrade(userGrade) .name(name) .build(); } diff --git a/src/main/java/com/example/mutsideout_mju/dto/response/user/UserGradeResponseDto.java b/src/main/java/com/example/mutsideout_mju/dto/response/user/UserGradeResponseDto.java index 9826e1f..17a4bf3 100644 --- a/src/main/java/com/example/mutsideout_mju/dto/response/user/UserGradeResponseDto.java +++ b/src/main/java/com/example/mutsideout_mju/dto/response/user/UserGradeResponseDto.java @@ -1,6 +1,6 @@ package com.example.mutsideout_mju.dto.response.user; -import com.example.mutsideout_mju.entity.Grade; +import com.example.mutsideout_mju.entity.UserGrade; import lombok.Builder; import lombok.Getter; @@ -8,18 +8,18 @@ @Builder public class UserGradeResponseDto { private String name; - private Grade grade; + private UserGrade userGrade; - public static UserGradeResponseDto of(String name, Grade grade) { + public static UserGradeResponseDto of(String name, UserGrade userGrade) { return UserGradeResponseDto.builder() .name(name) - .grade(grade) + .userGrade(userGrade) .build(); } - public static UserGradeResponseDto from(Grade grade) { + public static UserGradeResponseDto from(UserGrade userGrade) { return UserGradeResponseDto.builder() - .grade(grade) + .userGrade(userGrade) .build(); } } diff --git a/src/main/java/com/example/mutsideout_mju/entity/User.java b/src/main/java/com/example/mutsideout_mju/entity/User.java index e484fd9..740a57d 100644 --- a/src/main/java/com/example/mutsideout_mju/entity/User.java +++ b/src/main/java/com/example/mutsideout_mju/entity/User.java @@ -22,7 +22,7 @@ public class User extends BaseEntity { @Column(nullable = false) private String password; @Enumerated(EnumType.STRING) - private Grade grade; + private UserGrade userGrade; @OneToMany(mappedBy = "user", cascade = CascadeType.ALL, orphanRemoval = true) private List userSurveys; @@ -36,8 +36,8 @@ public class User extends BaseEntity { @OneToMany(mappedBy = "user", cascade = CascadeType.ALL, orphanRemoval = true) private List rooms; - public void setGrade(Grade grade) { - this.grade = grade; + public void setUserGrade(UserGrade userGrade) { + this.userGrade = userGrade; } public void setName(String name) { @@ -48,13 +48,13 @@ public void setPassword(String password) { this.password = password; } - public Grade determineGrade(long count) { + public UserGrade determineGrade(long count) { if (count >= 4) { - return Grade.TOMATO; + return UserGrade.TOMATO; } else if (count >= 2) { - return Grade.BANANA; + return UserGrade.BANANA; } else { - return Grade.AVOCADO; + return UserGrade.AVOCADO; } } } diff --git a/src/main/java/com/example/mutsideout_mju/entity/Grade.java b/src/main/java/com/example/mutsideout_mju/entity/UserGrade.java similarity index 77% rename from src/main/java/com/example/mutsideout_mju/entity/Grade.java rename to src/main/java/com/example/mutsideout_mju/entity/UserGrade.java index 2d9941b..d996ab3 100644 --- a/src/main/java/com/example/mutsideout_mju/entity/Grade.java +++ b/src/main/java/com/example/mutsideout_mju/entity/UserGrade.java @@ -1,6 +1,6 @@ package com.example.mutsideout_mju.entity; -public enum Grade { +public enum UserGrade { AVOCADO, BANANA, TOMATO diff --git a/src/main/java/com/example/mutsideout_mju/service/UserService.java b/src/main/java/com/example/mutsideout_mju/service/UserService.java index 7597c37..de7ed41 100644 --- a/src/main/java/com/example/mutsideout_mju/service/UserService.java +++ b/src/main/java/com/example/mutsideout_mju/service/UserService.java @@ -5,7 +5,7 @@ import com.example.mutsideout_mju.dto.request.user.UpdateUserDto; import com.example.mutsideout_mju.dto.response.user.ProfileResponseData; import com.example.mutsideout_mju.dto.response.user.UserGradeResponseDto; -import com.example.mutsideout_mju.entity.Grade; +import com.example.mutsideout_mju.entity.UserGrade; import com.example.mutsideout_mju.entity.SurveyOption; import com.example.mutsideout_mju.entity.User; import com.example.mutsideout_mju.entity.UserSurvey; @@ -37,19 +37,19 @@ public UserGradeResponseDto calculateUserGrade(User user) { long count = userSurveyList.stream() .filter(userSurvey -> isValidSurveyOption(userSurvey)) .count(); - Grade grade = user.determineGrade(count); + UserGrade userGrade = user.determineGrade(count); - user.setGrade(grade); + user.setUserGrade(userGrade); userRepository.save(user); - return UserGradeResponseDto.of(user.getName(), grade); + return UserGradeResponseDto.of(user.getName(), userGrade); } /** * 유저 등급 반환 */ public UserGradeResponseDto getUserGrade(User user) { - return UserGradeResponseDto.from(user.getGrade()); + return UserGradeResponseDto.from(user.getUserGrade()); } /** @@ -94,7 +94,7 @@ public void updateUser(User user, UpdateUserDto updateUserDto) { * 유저 전체 정보(이메일, 이름, 등급) 조회 */ public ProfileResponseData getMyPage(User user){ - ProfileResponseData profileResponseData = ProfileResponseData.of(user.getEmail(), user.getName(), user.getGrade()); + ProfileResponseData profileResponseData = ProfileResponseData.of(user.getEmail(), user.getName(), user.getUserGrade()); return profileResponseData; }