Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/main/java/com/sequence/anonymous/college/domain/College.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.sequence.anonymous.college.domain;

import jakarta.persistence.*;
import lombok.Getter;

@Entity
@Getter
public class College {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "college_id")
private static Long id;

@Column
private String name;


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.sequence.anonymous.college.domain;

import jakarta.persistence.*;
import lombok.Getter;

@Entity
@Getter
public class Department {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "department_id")
private static Long id;

@OneToOne
@Column(name = "college_id")
private Long collegeId;
Comment on lines +14 to +16
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

만약 연관관계 객체 자체가 아닌 id만을 저장할 때는 jpa의 기능을 이용할 필요가 없습니다~


@Column
private String name;
}
22 changes: 22 additions & 0 deletions src/main/java/com/sequence/anonymous/common/BaseEntity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.sequence.anonymous.common;

import jakarta.persistence.Column;
import jakarta.persistence.EntityListeners;
import jakarta.persistence.MappedSuperclass;
import lombok.Getter;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import java.time.LocalDateTime;

@Getter @EntityListeners(AuditingEntityListener.class)
@MappedSuperclass
public class BaseEntity {
@CreatedDate
@Column(updatable = false)
private LocalDateTime createdAt;

@LastModifiedDate
private LocalDateTime updatedAt;
}
27 changes: 27 additions & 0 deletions src/main/java/com/sequence/anonymous/invite/domain/Invite.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.sequence.anonymous.invite.domain;

import jakarta.persistence.*;
import lombok.Getter;

@Entity
@Getter
public class Invite {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "invite_id")
private static Long id;

@OneToOne
@JoinColumn(name = "inviter_id")
private Long inviter;

@OneToMany
@JoinColumn(name = "invitee_id")
private Long invitee;

@Column
private InviteStatus status;

@Column
private InviteKind kind;
Comment on lines +22 to +26
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아무런 설정도 필요 없으시면 @column 어노테이션은 지우셔도 될 것 같습니다!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

모든 enum에는 필수적으로 @Enumerated(EnumType.STRING)을 필수적으로 추가해주시는 것이 좋습니다!

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.sequence.anonymous.invite.domain;

public enum InviteKind {
MATCH_POST,
FRIEND
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.sequence.anonymous.invite.domain;

public enum InviteStatus {
WAIT,
DONE
}
22 changes: 22 additions & 0 deletions src/main/java/com/sequence/anonymous/post/domain/Chat.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.sequence.anonymous.post.domain;

import jakarta.persistence.*;
import lombok.Getter;

import java.util.UUID;

@Entity
@Getter
public class Chat {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "chat_id")
private static Long id;

@Column
private UUID chatIdentifier;
Comment on lines +16 to +17
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아무런 설정도 필요 없으시면 @column 어노테이션은 지우셔도 될 것 같습니다!


public Chat(UUID chatIdentifier) {
this.chatIdentifier = chatIdentifier;
}
}
45 changes: 45 additions & 0 deletions src/main/java/com/sequence/anonymous/post/domain/MatchPost.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package com.sequence.anonymous.post.domain;

import com.google.common.base.Preconditions;
import com.sequence.anonymous.common.BaseEntity;
import jakarta.persistence.*;
import lombok.Getter;

import java.time.LocalDateTime;

@Entity
@Getter
public class MatchPost extends BaseEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "matchPost_id")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

column이름은 match_post_id가 더 적절한 것 같습니다!

private Long id;

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

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

@Column(name = "title", nullable = false)
private String appeal;
Comment on lines +18 to +25
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

모든 column의 이름이 title이네요!
수정 부탁드립니다~


@Column
@Enumerated(EnumType.STRING)
private MatchPostStatus status;
Comment on lines +27 to +29
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아무런 설정도 필요 없으면 @Column 어노테이션은 지우셔도 될 것 같습니다!


protected MatchPost() {
}

public MatchPost(Long id, String title, String introduce, String appeal, MatchPostStatus status) {
Preconditions.checkArgument(title != null, "title must be provided.");
Preconditions.checkArgument(introduce != null, "introduce must be provided.");
Preconditions.checkArgument(appeal != null, "appeal must be provided.");

this.id = id;
this.title = title;
this.introduce = introduce;
this.appeal = appeal;
this.status = status;
}
Comment on lines +34 to +44
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

status는 기본값이 정해져있기 때문에 생성자를 private으로 바꾸고, 다른 생성자를 만들어 constructor chaining을 하시면 좋을 것 같습니다!

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.sequence.anonymous.post.domain;

public enum MatchPostStatus {
RECRUIT,
DONE
}

24 changes: 24 additions & 0 deletions src/main/java/com/sequence/anonymous/relation/domain/Relation.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.sequence.anonymous.relation.domain;

import jakarta.persistence.*;
import lombok.Getter;

@Entity
@Getter
public class Relation {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "relation_id")
private static Long id;

@OneToOne
@JoinColumn(name = "user1_id")
private Long user1Id;

@OneToOne
@JoinColumn(name = "user2_id")
private Long user2Id;
Comment on lines +15 to +20
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

만약 연관관계 객체 자체가 아닌 id만을 저장할 때는 jpa의 기능을 이용할 필요가 없습니다~


@Column
private RelationStatus status;
Comment on lines +22 to +23
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아무런 설정도 필요 없으시면 @column 어노테이션은 지우셔도 될 것 같습니다!

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.sequence.anonymous.relation.domain;

public enum RelationStatus {
BAN,
FRIEND
}
18 changes: 18 additions & 0 deletions src/main/java/com/sequence/anonymous/tag/domain/Tag.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.sequence.anonymous.tag.domain;

import jakarta.persistence.*;
import lombok.Getter;

@Entity
@Getter
public class Tag {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "tag_id")
private static Long id;

@Column
private String name;
Comment on lines +14 to +15
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아무런 설정도 필요 없으시면 @column 어노테이션은 지우셔도 될 것 같습니다!



}
21 changes: 21 additions & 0 deletions src/main/java/com/sequence/anonymous/user/domain/Attachment.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.sequence.anonymous.user.domain;

import jakarta.persistence.*;
import lombok.Getter;

@Entity
@Getter
public class Attachment {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@ManyToOne
@JoinColumn(name = "user_id")
private Long userId;
Comment on lines +13 to +15
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

만약 연관관계 객체 자체가 아닌 id만을 저장할 때는 jpa의 기능을 이용할 필요가 없습니다~


@Column
@Enumerated
private FileType fileType;
Comment on lines +17 to +19
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아무런 설정도 필요 없으시면 @column 어노테이션은 지우셔도 될 것 같습니다!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

모든 enum에는 필수적으로 @Enumerated(EnumType.STRING)을 필수적으로 추가해주시는 것이 좋습니다!


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.sequence.anonymous.user.domain;

public enum FileType {
MP4,
MP3,
PNG,
JPEG
}
7 changes: 7 additions & 0 deletions src/main/java/com/sequence/anonymous/user/domain/Gender.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.sequence.anonymous.user.domain;

public enum Gender {

MALE,
FEMALE
}
15 changes: 3 additions & 12 deletions src/main/java/com/sequence/anonymous/user/domain/Role.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
package com.sequence.anonymous.user.domain;

public enum Role {
ROLE_USER("USER"),
ROLE_ADMIN("ADMIN");

private final String role;

Role(String role) {
this.role = role;
}

public String role() {
return role;
}
ROLE_USER,
ROLE_ADMIN
}

65 changes: 52 additions & 13 deletions src/main/java/com/sequence/anonymous/user/domain/User.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
package com.sequence.anonymous.user.domain;

import com.google.common.base.Preconditions;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.validation.constraints.Email;
import jakarta.persistence.*;
import lombok.Getter;

@Entity
Expand All @@ -17,7 +10,12 @@ public class User {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "user_id")
private static Long id;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

프로퍼티가 static이네요! 수정 부탁드립니다~

public Long getId() {
return id;
}
Comment on lines +15 to +17
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

메소드의 위치가 잘못된 것 같습니다!
가독성을 위해 정렬 부탁드려요~



private String providerId;

Expand All @@ -28,27 +26,68 @@ public class User {
@Column(length = 40)
private String email;

@OneToOne
@JoinColumn(name = "college_id")
private Long college;

@OneToOne
@JoinColumn(name = "department_id")
private Long department;

@Column(length = 20)
private String name;

private Integer age;

@Column(length = 10)
@Enumerated(EnumType.STRING)
private Gender gender;

@Column(length = 15)
@Enumerated(EnumType.STRING)
private Role role;

private Boolean withdrawal;

private Boolean profileInitialized;

protected User() {
}

public User(String providerId, OAuth2Provider provider, String email) {
this(null, providerId, provider, email, Role.ROLE_USER);
this(null, providerId, provider, email, null, null, null, Role.ROLE_USER, false, false);
}

private User(Long id, String providerId, OAuth2Provider provider, String email, Role role) {
private User(Long id, String providerId, OAuth2Provider provider, String email, String name, Integer age, Gender gender, Role role, Boolean withdrawal, Boolean profileInitialized) {
Preconditions.checkArgument(providerId != null, "providerId must be provided.");
Preconditions.checkArgument(provider != null, "provider must be provided.");
Preconditions.checkArgument(email != null, "email must be provided.");
Preconditions.checkArgument(role != null, "role must be provided.");
Preconditions.checkArgument(withdrawal != null, "withdrawal must be provided.");
Preconditions.checkArgument(profileInitialized != null, "initialized must be provided.");

this.id = id;
this.providerId = providerId;
this.provider = provider;
this.name = name;
this.age = age;
this.gender = gender;
this.email = email;
this.role = role;
this.withdrawal = withdrawal;
this.profileInitialized = profileInitialized;
}
}

public void initializeProfile(String name, Integer age, Gender gender) {
Preconditions.checkArgument(name != null, "name must be provided.");
Preconditions.checkArgument(age != null, "age must be provided.");
Preconditions.checkArgument(gender != null, "gender must be provided.");

this.name = name;
this.age = age;
this.gender = gender;

this.profileInitialized = true;
}


}
Loading