Skip to content

Commit 5003445

Browse files
committed
refactor: 소셜 로그인으로 인한 빌더 수정 및 칼럼 추가
1 parent e6e3022 commit 5003445

3 files changed

Lines changed: 29 additions & 3 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.back.web7_9_codecrete_be.domain.users.entity;
2+
3+
public enum SocialType {
4+
LOCAL, // 일반 회원
5+
KAKAO, // 카카오
6+
GOOGLE // 구글
7+
}

src/main/java/com/back/web7_9_codecrete_be/domain/users/entity/User.java

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,12 @@ public class User {
2828
@Column(nullable = false, unique = true, length = 20)
2929
private String nickname;
3030

31-
@Column(nullable = false, length = 100)
31+
// 소셜 로그인 사용자는 password가 없을 수 있으므로 nullable = true
32+
@Column(length = 100)
3233
private String password;
3334

34-
@Column(nullable = false)
35+
// 소셜 로그인 시 생년월일을 불러오지 못하므로 nullable = true
36+
@Column(nullable = true)
3537
private LocalDate birth;
3638

3739
@Column(name = "profile_image", length = 255)
@@ -59,18 +61,30 @@ public class User {
5961
@Column(name = "is_deleted", nullable = false)
6062
private Boolean isDeleted;
6163

64+
// 소셜 로그인용 컬럼 추가
65+
@Enumerated(EnumType.STRING)
66+
@Column(name = "social_type", nullable = false, length = 20)
67+
private SocialType socialType;
68+
69+
@Column(name = "social_id", length = 100)
70+
private String socialId;
71+
6272
@Builder
6373
public User(String email,
6474
String nickname,
6575
String password,
6676
LocalDate birth,
67-
String profileImage) {
77+
String profileImage,
78+
SocialType socialType,
79+
String socialId) {
6880

6981
this.email = email;
7082
this.nickname = nickname;
7183
this.password = password;
7284
this.birth = birth;
7385
this.profileImage = profileImage;
86+
this.socialType = socialType;
87+
this.socialId = socialId;
7488

7589
// 기본값 세팅
7690
this.role = Role.USER;

src/main/java/com/back/web7_9_codecrete_be/global/initData/BaseInitData.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.back.web7_9_codecrete_be.global.initData;
22

3+
import com.back.web7_9_codecrete_be.domain.users.entity.SocialType;
34
import com.back.web7_9_codecrete_be.domain.users.entity.User;
45
import com.back.web7_9_codecrete_be.domain.users.repository.UserRepository;
56
import jakarta.annotation.PostConstruct;
@@ -35,6 +36,8 @@ private void createTestUser() {
3536
.password(passwordEncoder.encode("test1234!"))
3637
.birth(LocalDate.of(1999, 1, 1))
3738
.profileImage("https://example.com/profile.jpg")
39+
.socialType(SocialType.LOCAL)
40+
.socialId(null)
3841
.build();
3942

4043
userRepository.save(testUser);
@@ -51,6 +54,8 @@ private void createAdminUser() {
5154
.password(passwordEncoder.encode("admin1234!"))
5255
.birth(LocalDate.of(1990, 1, 1))
5356
.profileImage("https://example.com/profile.jpg")
57+
.socialType(SocialType.LOCAL)
58+
.socialId(null)
5459
.build();
5560

5661
// dev 전용 어드민 권한 부여

0 commit comments

Comments
 (0)