Skip to content

Commit

Permalink
feat: 회원 등급 추가 (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
birdieHyun authored Oct 26, 2023
1 parent e93dea2 commit 65bb891
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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) {

Expand All @@ -33,6 +35,7 @@ public static SingleUserResponse fromUser(User user) {
.major(user.getMajor())
.semester(user.getSemester())
.role(user.getRole())
.userClass(user.getUserClass())
.build();
}
}
21 changes: 12 additions & 9 deletions src/main/java/yonseigolf/server/user/entity/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
5 changes: 5 additions & 0 deletions src/main/java/yonseigolf/server/user/entity/UserClass.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package yonseigolf.server.user.entity;

public enum UserClass {
YB, OB, NONE
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -217,6 +217,7 @@ void findAllUserTest() throws Exception {
.studentId(1)
.semester(10)
.role(UserRole.MEMBER)
.userClass(UserClass.NONE)
.build()
);

Expand Down Expand Up @@ -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("마지막 페이지 여부"),
Expand Down

0 comments on commit 65bb891

Please sign in to comment.