From b47c6a0dc0f60dc47b6d2ff6b752e098be34cd7a Mon Sep 17 00:00:00 2001 From: taejin1221 Date: Fri, 30 Aug 2024 17:31:00 +0900 Subject: [PATCH] =?UTF-8?q?Feat:=20Member=20DB=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 한글이름, 영어이름, 기수, 과정 추가 - 과정 표현하는 Enumerate 추가 - 수정에 따른 오류 수정 - getNickname -> getKoreaName of getEnglishName Related to: #2 --- .../java/kaboo/kaboo_auth/domain/Course.java | 13 +++++++++++++ .../kaboo_auth/domain/CustomUserDetails.java | 2 +- .../kaboo/kaboo_auth/domain/entity/Member.java | 18 +++++++++++++++--- .../service/CustomOAuth2Service.java | 2 +- .../repository/MemberRepositoryTest.java | 4 ++-- 5 files changed, 32 insertions(+), 7 deletions(-) create mode 100644 src/main/java/kaboo/kaboo_auth/domain/Course.java diff --git a/src/main/java/kaboo/kaboo_auth/domain/Course.java b/src/main/java/kaboo/kaboo_auth/domain/Course.java new file mode 100644 index 0000000..c5a3a06 --- /dev/null +++ b/src/main/java/kaboo/kaboo_auth/domain/Course.java @@ -0,0 +1,13 @@ +package kaboo.kaboo_auth.domain; + +public enum Course { + AI("GenAI"), + FULLSTACK("Fullstack"), + CLOUD("Cloud"); + + private final String course; + + Course(String course) { + this.course = course; + } +} diff --git a/src/main/java/kaboo/kaboo_auth/domain/CustomUserDetails.java b/src/main/java/kaboo/kaboo_auth/domain/CustomUserDetails.java index ce539d0..7554366 100644 --- a/src/main/java/kaboo/kaboo_auth/domain/CustomUserDetails.java +++ b/src/main/java/kaboo/kaboo_auth/domain/CustomUserDetails.java @@ -22,7 +22,7 @@ public String getUsername() { @Override public String getName() { - return member.getNickname(); + return member.getKoreaName(); } @Override diff --git a/src/main/java/kaboo/kaboo_auth/domain/entity/Member.java b/src/main/java/kaboo/kaboo_auth/domain/entity/Member.java index 4d5fa53..86de7b7 100644 --- a/src/main/java/kaboo/kaboo_auth/domain/entity/Member.java +++ b/src/main/java/kaboo/kaboo_auth/domain/entity/Member.java @@ -7,6 +7,7 @@ import jakarta.persistence.GeneratedValue; import jakarta.persistence.GenerationType; import jakarta.persistence.Id; +import kaboo.kaboo_auth.domain.Course; import kaboo.kaboo_auth.domain.UserRole; import lombok.Builder; import lombok.Getter; @@ -23,19 +24,30 @@ public class Member { private String username; private String email; - private String nickname; + private String koreaName; + private String englishName; private String password; private String info; + private int classNum; + + @Enumerated(EnumType.STRING) + private Course course; + @Enumerated(EnumType.STRING) private UserRole role; @Builder - public Member(String username, String email, String nickname, String password, UserRole role) { + public Member(String username, String email, String koreaName, String englishName, String password, String info, + int classNum, Course course, UserRole role) { this.username = username; this.email = email; - this.nickname = nickname; + this.koreaName = koreaName; + this.englishName = englishName; this.password = password; + this.info = info; + this.classNum = classNum; + this.course = course; this.role = role; } } diff --git a/src/main/java/kaboo/kaboo_auth/service/CustomOAuth2Service.java b/src/main/java/kaboo/kaboo_auth/service/CustomOAuth2Service.java index 8ca515c..87eb4b4 100644 --- a/src/main/java/kaboo/kaboo_auth/service/CustomOAuth2Service.java +++ b/src/main/java/kaboo/kaboo_auth/service/CustomOAuth2Service.java @@ -51,7 +51,7 @@ public OAuth2User loadUser(OAuth2UserRequest userRequest) throws OAuth2Authentic String rawPassword = username + passwordPostfix; member = Member.builder() .username(username) - .nickname(nickname) + .koreaName(nickname) .email(email) .password(passwordEncoder.encode(rawPassword)) .role(UserRole.ROLE_USER) diff --git a/src/test/java/kaboo/kaboo_auth/repository/MemberRepositoryTest.java b/src/test/java/kaboo/kaboo_auth/repository/MemberRepositoryTest.java index a7d9ad0..b1c8d0f 100644 --- a/src/test/java/kaboo/kaboo_auth/repository/MemberRepositoryTest.java +++ b/src/test/java/kaboo/kaboo_auth/repository/MemberRepositoryTest.java @@ -23,7 +23,7 @@ class MemberRepositoryTest { @DisplayName("DB 저장 Test") void saveMemberTest() { // Given - Member member = Member.builder().username("Alice").nickname("Alice").password("1234").build(); + Member member = Member.builder().username("Alice").englishName("Alice").password("1234").build(); memberRepository.save(member); // When @@ -37,7 +37,7 @@ void saveMemberTest() { @DisplayName("Username으로 찾기 성공 Test") void findByUsername_Success() { // Given - Member member1 = Member.builder().username("Alice").nickname("Alice").password("1234").build(); + Member member1 = Member.builder().username("Alice").englishName("Alice").password("1234").build(); memberRepository.save(member1); // When