From 65bb891b73813f2d48173c2600e21a98c232f5cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9E=84=EB=8F=99=ED=98=84?= Date: Thu, 26 Oct 2023 19:42:18 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=ED=9A=8C=EC=9B=90=20=EB=93=B1=EA=B8=89?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80=20(#36)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../user/dto/response/SingleUserResponse.java | 3 +++ .../yonseigolf/server/user/entity/User.java | 21 +++++++++++-------- .../server/user/entity/UserClass.java | 5 +++++ .../user/controller/UserControllerTest.java | 5 ++++- 4 files changed, 24 insertions(+), 10 deletions(-) create mode 100644 src/main/java/yonseigolf/server/user/entity/UserClass.java diff --git a/src/main/java/yonseigolf/server/user/dto/response/SingleUserResponse.java b/src/main/java/yonseigolf/server/user/dto/response/SingleUserResponse.java index 27fd1df..2829d7b 100644 --- a/src/main/java/yonseigolf/server/user/dto/response/SingleUserResponse.java +++ b/src/main/java/yonseigolf/server/user/dto/response/SingleUserResponse.java @@ -5,6 +5,7 @@ import lombok.Getter; import lombok.NoArgsConstructor; import yonseigolf.server.user.entity.User; +import yonseigolf.server.user.entity.UserClass; import yonseigolf.server.user.entity.UserRole; @Getter @@ -21,6 +22,7 @@ public class SingleUserResponse { private String major; private long semester; private UserRole role; + private UserClass userClass; public static SingleUserResponse fromUser(User user) { @@ -33,6 +35,7 @@ public static SingleUserResponse fromUser(User user) { .major(user.getMajor()) .semester(user.getSemester()) .role(user.getRole()) + .userClass(user.getUserClass()) .build(); } } diff --git a/src/main/java/yonseigolf/server/user/entity/User.java b/src/main/java/yonseigolf/server/user/entity/User.java index 4cac7a3..3008928 100644 --- a/src/main/java/yonseigolf/server/user/entity/User.java +++ b/src/main/java/yonseigolf/server/user/entity/User.java @@ -26,17 +26,20 @@ public class User { private int semester; @Enumerated(EnumType.STRING) private UserRole role; + @Enumerated(EnumType.STRING) + private UserClass userClass; public static User of(SignUpUserRequest request, Long kakaoId) { - return User.builder() - .kakaoId(kakaoId) - .name(request.getName()) - .phoneNumber(request.getPhoneNumber()) - .studentId(request.getStudentId()) - .major(request.getMajor()) - .semester(request.getSemester()) - .role(UserRole.MEMBER) - .build(); + return User.builder() + .kakaoId(kakaoId) + .name(request.getName()) + .phoneNumber(request.getPhoneNumber()) + .studentId(request.getStudentId()) + .major(request.getMajor()) + .semester(request.getSemester()) + .role(UserRole.MEMBER) + .userClass(UserClass.NONE) + .build(); } } diff --git a/src/main/java/yonseigolf/server/user/entity/UserClass.java b/src/main/java/yonseigolf/server/user/entity/UserClass.java new file mode 100644 index 0000000..4495862 --- /dev/null +++ b/src/main/java/yonseigolf/server/user/entity/UserClass.java @@ -0,0 +1,5 @@ +package yonseigolf.server.user.entity; + +public enum UserClass { + YB, OB, NONE +} diff --git a/src/test/java/yonseigolf/server/user/controller/UserControllerTest.java b/src/test/java/yonseigolf/server/user/controller/UserControllerTest.java index 6f00b01..5377b54 100644 --- a/src/test/java/yonseigolf/server/user/controller/UserControllerTest.java +++ b/src/test/java/yonseigolf/server/user/controller/UserControllerTest.java @@ -10,13 +10,13 @@ import org.springframework.http.MediaType; import org.springframework.mock.web.MockHttpSession; import org.springframework.restdocs.payload.JsonFieldType; -import yonseigolf.server.apply.dto.response.SingleApplicationResult; import yonseigolf.server.docs.utils.RestDocsSupport; import yonseigolf.server.user.dto.request.KakaoCode; import yonseigolf.server.user.dto.request.SignUpUserRequest; import yonseigolf.server.user.dto.response.*; import yonseigolf.server.user.dto.token.KakaoOauthInfo; import yonseigolf.server.user.dto.token.OauthToken; +import yonseigolf.server.user.entity.UserClass; import yonseigolf.server.user.entity.UserRole; import yonseigolf.server.user.service.OauthLoginService; import yonseigolf.server.user.service.UserService; @@ -217,6 +217,7 @@ void findAllUserTest() throws Exception { .studentId(1) .semester(10) .role(UserRole.MEMBER) + .userClass(UserClass.NONE) .build() ); @@ -254,6 +255,8 @@ void findAllUserTest() throws Exception { .description("유저 기수"), fieldWithPath("content[].role").type(JsonFieldType.STRING) .description("유저 권한"), + fieldWithPath("content[].userClass").type(JsonFieldType.STRING) + .description("유저 등급"), fieldWithPath("pageable").ignored(), fieldWithPath("last").type(JsonFieldType.BOOLEAN) .description("마지막 페이지 여부"),