-
Notifications
You must be signed in to change notification settings - Fork 0
Create default entities - eunseobb #16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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; | ||
|
|
||
| @Column | ||
| private String name; | ||
| } | ||
| 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; | ||
| } |
| 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
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 아무런 설정도 필요 없으시면 @column 어노테이션은 지우셔도 될 것 같습니다!
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 모든 |
||
| } | ||
| 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 | ||
| } |
| 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
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 아무런 설정도 필요 없으시면 @column 어노테이션은 지우셔도 될 것 같습니다! |
||
|
|
||
| public Chat(UUID chatIdentifier) { | ||
| this.chatIdentifier = chatIdentifier; | ||
| } | ||
| } | ||
| 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") | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| 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
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 모든 |
||
|
|
||
| @Column | ||
| @Enumerated(EnumType.STRING) | ||
| private MatchPostStatus status; | ||
|
Comment on lines
+27
to
+29
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 아무런 설정도 필요 없으면 |
||
|
|
||
| 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
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| } | ||
| 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 | ||
| } | ||
|
|
| 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
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 만약 연관관계 객체 자체가 아닌 |
||
|
|
||
| @Column | ||
| private RelationStatus status; | ||
|
Comment on lines
+22
to
+23
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
| } |
| 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
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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,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
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 아무런 설정도 필요 없으시면 @column 어노테이션은 지우셔도 될 것 같습니다!
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 모든 |
||
|
|
||
| } | ||
| 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 | ||
| } |
| 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 | ||
| } |
| 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 | ||
| } | ||
|
|
| 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 | ||
|
|
@@ -17,7 +10,12 @@ public class User { | |
|
|
||
| @Id | ||
| @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| private Long id; | ||
| @Column(name = "user_id") | ||
| private static Long id; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 프로퍼티가 |
||
| public Long getId() { | ||
| return id; | ||
| } | ||
|
Comment on lines
+15
to
+17
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 메소드의 위치가 잘못된 것 같습니다! |
||
|
|
||
|
|
||
| private String providerId; | ||
|
|
||
|
|
@@ -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; | ||
| } | ||
|
|
||
|
|
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
만약 연관관계 객체 자체가 아닌 id만을 저장할 때는 jpa의 기능을 이용할 필요가 없습니다~