Skip to content
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

Create default entities - mk3058 #14

Open
wants to merge 19 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
a280750
feat(domain): college, invite, user, relation, tag, attachment 관련 엔티티 추가
mk3058 Aug 21, 2023
c65be37
feat(domain): add default entities
mk3058 Aug 22, 2023
45b31eb
refactor: 일부 잘못된 패키지 경로 수정. 패키지/클래스 이름 수정
mk3058 Aug 23, 2023
ffc3874
refactor(entity): 문자열 컬럼 길이 지정, 일부 생성자 값 검즘 추가
mk3058 Aug 23, 2023
3b13bba
refactor(dto): Request Dto protected 생성자 추가
mk3058 Aug 26, 2023
deb1214
refactor: domain계층이 presentation계층에 의존하지 않도록 수정
mk3058 Aug 26, 2023
a241e1a
fix(user): 유저의 나이가 20-30 범위로 제한되도록 수정
mk3058 Aug 27, 2023
b650a6e
refactor(dto): dto 이름 수정
mk3058 Aug 27, 2023
da54071
fix(User): 참조 타입에 대한 값 검증 추가
mk3058 Aug 27, 2023
34ce3d8
refactor(matchpost): 패키지 이름 수정
mk3058 Aug 27, 2023
37bfa4e
fix(User): 나이 검증 조건 수정
mk3058 Aug 27, 2023
65fdd5c
feat(chat): 기본 클래스 추가
mk3058 Sep 4, 2023
5746534
feat(college): 기본 클래스 추가
mk3058 Sep 4, 2023
6205617
feat(invite): 기본 클래스 추가
mk3058 Sep 4, 2023
2a734f1
feat(matchPost): 기본 클래스 추가
mk3058 Sep 4, 2023
2e41c43
feat(relation): 기본 클래스 추가
mk3058 Sep 4, 2023
26a257c
fix(matchPost): MatchServicePost 클래스를 순환 참조하던 문제 수정
mk3058 Sep 4, 2023
426437b
feat(tag): 기본 클래스 추가
mk3058 Sep 4, 2023
bffdf80
feat(user): 기본 클래스 추가
mk3058 Sep 4, 2023
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
32 changes: 32 additions & 0 deletions src/main/java/com/sequence/anonymous/chat/domain/Chat.java
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;
}
}
42 changes: 42 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,42 @@
package com.sequence.anonymous.college.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 lombok.Getter;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.data.geo.Point;

@Entity
@Getter
public class College {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@Column(length = 20, nullable = false, unique = true)
private String name;

private Point location;
Copy link
Member

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을 달아주셔야 합니다.


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 update(String name, Point location) {
this.name = ObjectUtils.defaultIfNull(name, this.name);
this.location = ObjectUtils.defaultIfNull(location, this.location);
}
}
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 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;
import org.apache.commons.lang3.ObjectUtils;

@Entity
@Getter
public class Department {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@Column(length = 30, 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 update(String name) {
this.name = ObjectUtils.defaultIfNull(name, this.name);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.sequence.anonymous.college.presentation.dto;

import lombok.Getter;

@Getter
public class DepartmentUpdateDto {

private String name;

protected DepartmentUpdateDto() {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.sequence.anonymous.college.presentation.dto;

import lombok.Getter;
import org.springframework.data.geo.Point;

@Getter
public class UpdateDto {
Copy link
Member

Choose a reason for hiding this comment

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

해당 DTO가 서버에 요청되는 Request인지 응답에 이용되는 Response인지 구분할 수 있게 네이밍되면 좋을 것 같습니다!

ex) UpdateRequest, UpdateResponse


private String name;

private Point location;

protected UpdateDto() {
}
}
23 changes: 23 additions & 0 deletions src/main/java/com/sequence/anonymous/common/BaseTimeEntity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.sequence.anonymous.common;

import jakarta.persistence.Column;
import jakarta.persistence.EntityListeners;
import jakarta.persistence.MappedSuperclass;
import java.time.LocalDateTime;
import lombok.Getter;
import org.springframework.data.annotation.CreatedDate;
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;
}
64 changes: 64 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,64 @@
package com.sequence.anonymous.invite.domain;

import com.google.common.base.Preconditions;
import com.sequence.anonymous.user.domain.User;
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.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import lombok.Getter;
import org.apache.commons.lang3.ObjectUtils;

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

@Column(length = 10)
@Enumerated(EnumType.STRING)
private Status status;


@Column(length = 15)
@Enumerated(EnumType.STRING)
private Kind kind;

protected Invite() {
}

public Invite(User inviter, User invitee, Kind kind) {
this(inviter, invitee, kind, Status.WAIT);
}

private Invite(User inviter, User invitee, Kind kind, Status 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");
Preconditions.checkArgument(status != null, "status must be provided");

this.inviter = inviter;
this.invitee = invitee;
this.kind = kind;
this.status = status;
}

public void update(Status status) {
this.status = ObjectUtils.defaultIfNull(status, this.status);
}
}
5 changes: 5 additions & 0 deletions src/main/java/com/sequence/anonymous/invite/domain/Kind.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.sequence.anonymous.invite.domain;

public enum Kind {
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 Status {
WAIT, DONE
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.sequence.anonymous.invite.presentation.dto;

import com.sequence.anonymous.invite.domain.Status;
import lombok.Getter;

@Getter
public class UpdateDto {

private Status status;

protected UpdateDto() {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package com.sequence.anonymous.matchpost.domain;

import com.google.common.base.Preconditions;
import com.sequence.anonymous.common.BaseTimeEntity;
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;
import org.apache.commons.lang3.ObjectUtils;

@Entity
@Getter
public class MatchPost extends BaseTimeEntity {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@Column(length = 40, nullable = false)
private String title;

@Column(columnDefinition = "TEXT", nullable = false)
private String introduce;

@Column(length = 50)
private String appeal;

@Column(length = 10)
@Enumerated(EnumType.STRING)
private Status 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, Status.RECRUIT);
}

protected MatchPost(Long id, String title, String introduce, String appeal,
Status 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
Preconditions.checkArgument(appeal != null, "appeal must be provided");
Preconditions.checkArgument(status != null, "status must be provided");

this.id = id;
this.title = title;
this.introduce = introduce;
this.appeal = appeal;
this.status = status;
}

public void update(String title, String introduce, String appeal, Status status) {
this.title = ObjectUtils.defaultIfNull(title, this.title);
this.introduce = ObjectUtils.defaultIfNull(introduce, this.introduce);
this.appeal = ObjectUtils.defaultIfNull(appeal, this.appeal);
this.status = ObjectUtils.defaultIfNull(status, this.status);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.sequence.anonymous.matchpost.domain;

public enum Status {
RECRUIT, DONE
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.sequence.anonymous.matchpost.presentation.dto;

import com.sequence.anonymous.matchpost.domain.Status;
import lombok.Getter;

@Getter
public class UpdateDto {

private String title;

private String introduce;

private String appeal;

private Status status;

protected UpdateDto() {
}
}
Loading