-
Notifications
You must be signed in to change notification settings - Fork 0
Create default entities - mk3058 #14
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 2 commits
a280750
c65be37
45b31eb
ffc3874
3b13bba
deb1214
a241e1a
b650a6e
da54071
34ce3d8
37bfa4e
65fdd5c
5746534
6205617
2a734f1
2e41c43
26a257c
426437b
bffdf80
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,32 @@ | ||
| package com.sequence.anonymous.chat.domain; | ||
|
|
||
| import com.google.common.base.Preconditions; | ||
| import jakarta.persistence.Column; | ||
| import jakarta.persistence.Entity; | ||
| import jakarta.persistence.GeneratedValue; | ||
| import jakarta.persistence.GenerationType; | ||
| import jakarta.persistence.Id; | ||
| import java.util.UUID; | ||
| import lombok.Getter; | ||
|
|
||
| @Entity | ||
| @Getter | ||
| public class Chat { | ||
|
|
||
| @Id | ||
| @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| private Long id; | ||
|
|
||
| @Column(nullable = false, unique = true) | ||
| private UUID chatIdentifier; | ||
|
|
||
| protected Chat() { | ||
| } | ||
|
|
||
| public Chat(UUID chatIdentifier) { | ||
| Preconditions.checkArgument(chatIdentifier != null, "chatIdentifier must be provided"); | ||
|
|
||
| this.id = null; | ||
| this.chatIdentifier = chatIdentifier; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| package com.sequence.anonymous.college.domain; | ||
|
|
||
| import com.google.common.base.Preconditions; | ||
| import com.sequence.anonymous.college.domain.presentation.dto.CollegeUpdateDto; | ||
| import jakarta.persistence.Column; | ||
| import jakarta.persistence.Entity; | ||
| import jakarta.persistence.GeneratedValue; | ||
| import jakarta.persistence.GenerationType; | ||
| import jakarta.persistence.Id; | ||
| import lombok.Getter; | ||
| import org.springframework.data.geo.Point; | ||
|
|
||
| @Entity | ||
| @Getter | ||
| public class College { | ||
|
|
||
| @Id | ||
| @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| private Long id; | ||
|
|
||
| @Column(nullable = false, unique = true) | ||
| private String name; | ||
|
|
||
| private Point location; | ||
|
|
||
| protected College() { | ||
| } | ||
|
|
||
| public College(String name, Point location) { | ||
| Preconditions.checkArgument(name != null, "name must be provided"); | ||
| Preconditions.checkArgument(location != null, "location must be provided"); | ||
|
|
||
| this.id = null; | ||
| this.name = name; | ||
| this.location = location; | ||
| } | ||
|
|
||
| public void updateName(CollegeUpdateDto dto) { | ||
|
||
| this.name = dto.getName(); | ||
| this.location = dto.getLocation(); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| package com.sequence.anonymous.college.domain; | ||
|
|
||
| import com.google.common.base.Preconditions; | ||
| import com.sequence.anonymous.college.domain.presentation.dto.DepartmentUpdateDto; | ||
| import jakarta.persistence.Column; | ||
| import jakarta.persistence.Entity; | ||
| import jakarta.persistence.GeneratedValue; | ||
| import jakarta.persistence.GenerationType; | ||
| import jakarta.persistence.Id; | ||
| import jakarta.persistence.JoinColumn; | ||
| import jakarta.persistence.ManyToOne; | ||
| import lombok.Getter; | ||
|
|
||
| @Entity | ||
| @Getter | ||
| public class Department { | ||
|
|
||
| @Id | ||
| @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| private Long id; | ||
|
|
||
| @Column(nullable = false) | ||
| private String name; | ||
|
|
||
| @ManyToOne | ||
| @JoinColumn(name = "college_id") | ||
| private College college; | ||
|
|
||
| protected Department() { | ||
| } | ||
|
|
||
| public Department(String name, College college) { | ||
| Preconditions.checkArgument(name != null, "name must be provided"); | ||
| Preconditions.checkArgument(college != null, "college must be provided"); | ||
|
|
||
| this.id = null; | ||
| this.name = name; | ||
| this.college = college; | ||
| } | ||
|
|
||
| public void updateName(DepartmentUpdateDto dto) { | ||
|
||
| this.name = dto.getName(); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| package com.sequence.anonymous.college.domain.presentation.dto; | ||
|
||
|
|
||
| import lombok.Getter; | ||
| import org.springframework.data.geo.Point; | ||
|
|
||
| @Getter | ||
| public class CollegeUpdateDto { | ||
|
||
|
|
||
| private String name; | ||
|
|
||
| private Point location; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| package com.sequence.anonymous.college.domain.presentation.dto; | ||
|
|
||
| import java.awt.Point; | ||
| import lombok.Getter; | ||
|
|
||
| @Getter | ||
| public class DepartmentUpdateDto { | ||
|
||
|
|
||
| private String name; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| package com.sequence.anonymous.common; | ||
|
|
||
| import jakarta.persistence.Column; | ||
| import jakarta.persistence.EntityListeners; | ||
| import jakarta.persistence.MappedSuperclass; | ||
| import java.time.LocalDate; | ||
| import java.time.LocalDateTime; | ||
| import lombok.Getter; | ||
| import org.springframework.context.event.EventListener; | ||
| import org.springframework.data.annotation.CreatedDate; | ||
| import org.springframework.data.annotation.LastModifiedBy; | ||
| import org.springframework.data.annotation.LastModifiedDate; | ||
| import org.springframework.data.jpa.domain.support.AuditingEntityListener; | ||
|
|
||
| @Getter | ||
| @MappedSuperclass | ||
| @EntityListeners(AuditingEntityListener.class) | ||
| public abstract class BaseTimeEntity{ | ||
|
|
||
| @CreatedDate | ||
| @Column(updatable = false) | ||
| private LocalDateTime createdAt; | ||
|
|
||
| @LastModifiedDate | ||
| private LocalDateTime updatedAt; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| package com.sequence.anonymous.invite.domain; | ||
|
|
||
| import com.google.common.base.Preconditions; | ||
| import com.sequence.anonymous.invite.presentation.dto.InviteUpdateDto; | ||
| import com.sequence.anonymous.user.domain.User; | ||
| 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.persistence.JoinColumn; | ||
| import jakarta.persistence.ManyToOne; | ||
| import lombok.Getter; | ||
|
|
||
| @Entity | ||
| @Getter | ||
| public class Invite { | ||
|
|
||
| @Id | ||
| @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| private Long id; | ||
|
|
||
| @ManyToOne | ||
| @JoinColumn(name = "inviter_id") | ||
| private User inviter; | ||
|
|
||
| @ManyToOne | ||
| @JoinColumn(name = "invitee_id") | ||
| private User invitee; | ||
|
|
||
| @Enumerated(EnumType.STRING) | ||
| private InviteStatus status; | ||
|
|
||
| @Enumerated(EnumType.STRING) | ||
| private InviteKind kind; | ||
|
|
||
| protected Invite() { | ||
| } | ||
|
|
||
| public Invite(User inviter, User invitee, InviteKind kind) { | ||
| this(inviter, invitee, kind, InviteStatus.WAIT); | ||
| } | ||
|
|
||
| private Invite(User inviter, User invitee, InviteKind kind, InviteStatus status) { | ||
| Preconditions.checkArgument(inviter != null, "inviter must be provided"); | ||
| Preconditions.checkArgument(invitee != null, "invitee must be provided"); | ||
| Preconditions.checkArgument(kind != null, "kind must be provided"); | ||
|
|
||
|
||
| this.inviter = inviter; | ||
| this.invitee = invitee; | ||
| this.kind = kind; | ||
| this.status = status; | ||
| } | ||
|
|
||
| public void updateStatus(InviteUpdateDto dto) { | ||
| this.status = dto.getStatus(); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| 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,5 @@ | ||
| package com.sequence.anonymous.invite.domain; | ||
|
|
||
| public enum InviteStatus { | ||
| WAIT, DONE | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| package com.sequence.anonymous.invite.presentation.dto; | ||
|
|
||
| import com.sequence.anonymous.invite.domain.InviteStatus; | ||
| import lombok.Getter; | ||
|
|
||
| @Getter | ||
| public class InviteUpdateDto { | ||
|
|
||
| private InviteStatus status; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| package com.sequence.anonymous.matchPost.domain; | ||
|
|
||
| import com.fasterxml.jackson.databind.deser.DataFormatReaders.Match; | ||
| import com.google.common.base.Preconditions; | ||
| import com.sequence.anonymous.common.BaseTimeEntity; | ||
| import com.sequence.anonymous.matchPost.presentation.dto.MatchPostUpdateDto; | ||
| 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 lombok.Getter; | ||
|
|
||
| @Entity | ||
| @Getter | ||
| public class MatchPost extends BaseTimeEntity { | ||
|
|
||
| @Id | ||
| @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| private Long id; | ||
|
|
||
| @Column(nullable = false) | ||
| private String title; | ||
|
|
||
| @Column(columnDefinition = "TEXT", nullable = false) | ||
| private String introduce; | ||
|
|
||
| private String appeal; | ||
|
|
||
| @Enumerated(EnumType.STRING) | ||
| private MatchPostStatus status; | ||
|
||
|
|
||
| protected MatchPost() { | ||
| } | ||
|
|
||
| public MatchPost(String title, String introduce) { | ||
| this(title, introduce, "No Data"); | ||
| } | ||
|
|
||
| public MatchPost(String title, String introduce, String appeal) { | ||
| this(null, title, introduce, appeal, MatchPostStatus.RECRUIT); | ||
| } | ||
|
|
||
| protected 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"); | ||
ckyeon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| this.id = id; | ||
| this.title = title; | ||
| this.introduce = introduce; | ||
| this.appeal = appeal; | ||
| this.status = status; | ||
| } | ||
|
|
||
| public void updateMatchPost(MatchPostUpdateDto dto) { | ||
| this.title = dto.getTitle(); | ||
| this.introduce = dto.getIntroduce(); | ||
| this.appeal = dto.getAppeal(); | ||
| this.status = dto.getStatus(); | ||
| } | ||
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| package com.sequence.anonymous.matchPost.domain; | ||
|
|
||
| public enum MatchPostStatus { | ||
| RECRUIT, DONE | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| package com.sequence.anonymous.matchPost.presentation.dto; | ||
|
|
||
| import com.sequence.anonymous.matchPost.domain.MatchPostStatus; | ||
| import lombok.Getter; | ||
|
|
||
| @Getter | ||
| public class MatchPostUpdateDto { | ||
|
|
||
| private String title; | ||
|
|
||
| private String introduce; | ||
|
|
||
| private String appeal; | ||
|
|
||
| private MatchPostStatus status; | ||
| } | ||
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| package com.sequence.anonymous.relation.domain; | ||
|
|
||
| import com.google.common.base.Preconditions; | ||
| import com.sequence.anonymous.invite.domain.InviteStatus; | ||
| import com.sequence.anonymous.relation.presentation.dto.RelationUpdateDto; | ||
| import com.sequence.anonymous.user.domain.User; | ||
| 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.persistence.JoinColumn; | ||
| import jakarta.persistence.ManyToOne; | ||
| import lombok.Getter; | ||
|
|
||
| @Entity | ||
| @Getter | ||
| public class Relation { | ||
|
|
||
| @Id | ||
| @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| private Long id; | ||
|
|
||
| @ManyToOne | ||
| @JoinColumn(name = "user1_id") | ||
| private User user1; | ||
|
|
||
| @ManyToOne | ||
| @JoinColumn(name = "user2_id") | ||
| private User user2; | ||
|
|
||
| @Enumerated(EnumType.STRING) | ||
| private RelationStatus status; | ||
|
|
||
| protected Relation() { | ||
| } | ||
|
|
||
| public Relation(User user1, User user2, RelationStatus status) { | ||
| Preconditions.checkArgument(user1 != null, "user1 must be provided"); | ||
| Preconditions.checkArgument(user2 != null, "user2 must be provided"); | ||
| Preconditions.checkArgument(status != null, "status must be provided"); | ||
|
|
||
| this.user1 = user1; | ||
| this.user2 = user2; | ||
| this.status = status; | ||
| } | ||
|
|
||
| public void updateStatus(RelationUpdateDto dto) { | ||
| this.status = dto.getStatus(); | ||
| } | ||
| } |
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.
Point와 같은Value Object를 사용하시려면 사용하는 엔티티 프로퍼티에@Embedded를 달아주시고,Point클래스에@Embeddable을 달아주셔야 합니다.