Skip to content

Commit

Permalink
[feat][#53] User domain 정리 및 Profile로 분리
Browse files Browse the repository at this point in the history
  • Loading branch information
ProtoSeo committed Jul 22, 2022
1 parent 044c8c9 commit a4adbbc
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 40 deletions.
33 changes: 33 additions & 0 deletions src/main/java/kr/startoff/backend/domain/user/domain/Profile.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package kr.startoff.backend.domain.user.domain;

import javax.persistence.Column;
import javax.persistence.Embeddable;

import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Embeddable
@NoArgsConstructor
@Getter
public class Profile {
@Column(name = "github_url")
private String githubUrl = "";

@Column(name = "blog_url")
private String blogUrl = "";

@Column(name = "baekjoon_id")
private String baekjoonId = "";

@Column(name = "introduce")
private String introduce = "";

@Builder
public Profile(String githubUrl, String blogUrl, String baekjoonId, String introduce) {
this.githubUrl = githubUrl;
this.blogUrl = blogUrl;
this.baekjoonId = baekjoonId;
this.introduce = introduce;
}
}
55 changes: 15 additions & 40 deletions src/main/java/kr/startoff/backend/domain/user/domain/User.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package kr.startoff.backend.domain.user.domain;

import javax.persistence.Column;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;

import lombok.Builder;
import lombok.Getter;
Expand All @@ -22,39 +22,26 @@ public class User {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "user_id")
Long id;
private Long id;

@Column(name = "password", nullable = false)
String password;
private String password;

@Column(name = "email", nullable = false, unique = true)
String email;
private String email;

@Column(name = "nickname", nullable = false, unique = true)
String nickname;
private String nickname;

@Column(name = "github_url")
String githubUrl = "";

@Column(name = "blog_url")
String blogUrl = "";

@Column(name = "baekjoon_id")
String baekjoonId = "";
@Column(name = "image_url")
private String imageUrl;

@Column(name = "introduce")
String introduce = "";
@Embedded
private Profile profile = new Profile();

@NotNull
@Enumerated(EnumType.STRING)
@Column(name = "provider")
AuthProvider provider;

@Column(name = "provider_id")
String providerId;

@Column(name = "image_url")
String imageUrl = "";
@Column(name = "provider", nullable = false)
private AuthProvider provider;

@Builder
public User(String email, String nickname, String password, AuthProvider provider) {
Expand All @@ -72,23 +59,11 @@ public void updateNickname(String nickname) {
this.nickname = nickname;
}

public void updateGithubUrl(String githubUrl) {
this.githubUrl = githubUrl;
}

public void updateBlogUrl(String blogUrl) {
this.blogUrl = blogUrl;
}

public void updateBaekjoonId(String baekjoonId) {
this.baekjoonId = baekjoonId;
}

public void updateIntroduce(String introduce) {
this.introduce = introduce;
}

public void updateImageUrl(String imageUrl) {
this.imageUrl = imageUrl;
}

public void updateProfile(Profile profile) {
this.profile = profile;
}
}

0 comments on commit a4adbbc

Please sign in to comment.