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

[feat] 엔티티 클래스 매핑 #7

Merged
merged 6 commits into from
Jan 4, 2024
Merged
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
24 changes: 24 additions & 0 deletions doorip-domain/src/main/java/org/doorip/todo/domain/Allocator.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package org.doorip.todo.domain;

import jakarta.persistence.*;
import lombok.*;
import org.doorip.common.BaseTimeEntity;
import org.doorip.trip.domain.Participant;

@NoArgsConstructor(access = AccessLevel.PROTECTED)
@AllArgsConstructor(access = AccessLevel.PRIVATE)
@Builder(access = AccessLevel.PRIVATE)
@Getter
@Entity
public class Allocator extends BaseTimeEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "allocator_id")
private Long id;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "participant_id")
private Todo todo;
@OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "todo_id")
private Participant participant;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package org.doorip.todo.domain;

public enum Progress {
INCOMPLETE, COMPLETE
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package org.doorip.todo.domain;

public enum Secret {
OUR, MY
}
38 changes: 38 additions & 0 deletions doorip-domain/src/main/java/org/doorip/todo/domain/Todo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package org.doorip.todo.domain;

import jakarta.persistence.*;
import lombok.*;
import org.doorip.common.BaseTimeEntity;
import org.doorip.trip.domain.Trip;

import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;

@NoArgsConstructor(access = AccessLevel.PROTECTED)
@AllArgsConstructor(access = AccessLevel.PRIVATE)
@Builder(access = AccessLevel.PRIVATE)
@Getter
@Entity
public class Todo extends BaseTimeEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "todo_id")
private Long id;
@Column(nullable = false)
private String title;
private LocalDate endDate;
private String memo;
@Column(nullable = false)
@Enumerated(EnumType.STRING)
private Secret secret;
@Column(nullable = false)
@Enumerated(EnumType.STRING)
private Progress progress;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "trip_id")
private Trip trip;
@Builder.Default
@OneToMany(mappedBy = "todo", cascade = CascadeType.REMOVE)
private List<Allocator> allocators = new ArrayList<>();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package org.doorip.trip.domain;

import jakarta.persistence.*;
import lombok.*;
import org.doorip.common.BaseTimeEntity;
import org.doorip.todo.domain.Allocator;
import org.doorip.user.domain.User;

@NoArgsConstructor(access = AccessLevel.PROTECTED)
@AllArgsConstructor(access = AccessLevel.PRIVATE)
@Builder(access = AccessLevel.PRIVATE)
@Getter
@Entity
public class Participant extends BaseTimeEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "participant_id")
private Long id;
@Column(nullable = false)
@Enumerated(EnumType.STRING)
private Role role;
@Column(nullable = false)
private Integer styleA;
@Column(nullable = false)
private Integer styleB;
@Column(nullable = false)
private Integer styleC;
@Column(nullable = false)
private Integer styleD;
@Column(nullable = false)
private Integer styleE;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "user_id")
private User user;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "trip_id")
private Trip trip;
@OneToOne(mappedBy = "participant", fetch = FetchType.LAZY, cascade = CascadeType.REMOVE)
private Allocator allocator;
}
5 changes: 5 additions & 0 deletions doorip-domain/src/main/java/org/doorip/trip/domain/Role.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package org.doorip.trip.domain;

public enum Role {
HOST, PARTICIPATION
}
36 changes: 36 additions & 0 deletions doorip-domain/src/main/java/org/doorip/trip/domain/Trip.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package org.doorip.trip.domain;

import jakarta.persistence.*;
import lombok.*;
import org.doorip.common.BaseTimeEntity;
import org.doorip.todo.domain.Todo;

import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;

@NoArgsConstructor(access = AccessLevel.PROTECTED)
@AllArgsConstructor(access = AccessLevel.PRIVATE)
@Builder(access = AccessLevel.PRIVATE)
@Getter
@Entity
public class Trip extends BaseTimeEntity {
@Id
@GeneratedValue
@Column(name = "trip_id")
private Long id;
@Column(nullable = false)
private String title;
@Column(nullable = false)
private LocalDate startDate;
@Column(nullable = false)
private LocalDate endDate;
@Column(nullable = false)
private String code;
@Builder.Default
@OneToMany(mappedBy = "trip", cascade = CascadeType.REMOVE)
private List<Participant> participants = new ArrayList<>();
@Builder.Default
@OneToMany(mappedBy = "trip", cascade = CascadeType.REMOVE)
private List<Todo> todos = new ArrayList<>();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package org.doorip.user.domain;

public enum Platform {
KAKAO, APPLE
}
36 changes: 36 additions & 0 deletions doorip-domain/src/main/java/org/doorip/user/domain/User.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package org.doorip.user.domain;

import jakarta.persistence.*;
import lombok.*;
import org.doorip.common.BaseTimeEntity;
import org.doorip.trip.domain.Participant;

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

@NoArgsConstructor(access = AccessLevel.PROTECTED)
@AllArgsConstructor(access = AccessLevel.PRIVATE)
@Builder(access = AccessLevel.PRIVATE)
@Getter
@Table(name = "users")
@Entity
public class User extends BaseTimeEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "user_id")
private Long id;
@Column(nullable = false)
private String name;
@Column(nullable = false)
private String intro;
private Integer result;
@Column(nullable = false)
private String platformId;
@Column(nullable = false)
@Enumerated(EnumType.STRING)
private Platform platform;
private String refreshToken;
@Builder.Default
@OneToMany(mappedBy = "user", cascade = CascadeType.REMOVE)
private List<Participant> participants = new ArrayList<>();
}