Skip to content

Commit

Permalink
[refactor][#53] user domain 수정
Browse files Browse the repository at this point in the history
- setter 삭제
- post, project 양방향 관계 제거
- many to many table 제거
  • Loading branch information
ProtoSeo committed Jul 20, 2022
1 parent cf3abbe commit ebfae5e
Showing 1 changed file with 27 additions and 26 deletions.
53 changes: 27 additions & 26 deletions src/main/java/kr/startoff/backend/domain/user/domain/User.java
Original file line number Diff line number Diff line change
@@ -1,36 +1,23 @@
package kr.startoff.backend.domain.user.domain;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
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.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;

import kr.startoff.backend.domain.post.domain.Post;
import kr.startoff.backend.domain.project.domain.Project;
import kr.startoff.backend.domain.tag.domain.SkillTag;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Entity
@Table(name = "user")
@NoArgsConstructor
@Getter
@Setter
public class User {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
Expand Down Expand Up @@ -69,19 +56,6 @@ public class User {
@Column(name = "image_url")
String imageUrl = "";

@OneToMany(mappedBy = "user", cascade = CascadeType.ALL)
List<Project> projects = new ArrayList<>();

@OneToMany(mappedBy = "author", cascade = CascadeType.ALL)
List<Post> userPosts = new ArrayList<>();

@ManyToMany
@JoinTable(
name = "user_skill_tag",
joinColumns = @JoinColumn(name = "user_id"),
inverseJoinColumns = @JoinColumn(name = "skill_tag_id"))
List<SkillTag> userSkills = new ArrayList<>();

@Builder
public User(String email, String nickname, String password, AuthProvider provider) {
this.email = email;
Expand All @@ -90,4 +64,31 @@ public User(String email, String nickname, String password, AuthProvider provide
this.provider = provider;
}

public void updatePassword(String password) {
this.password = password;
}

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;
}
}

0 comments on commit ebfae5e

Please sign in to comment.