diff --git a/doorip-domain/src/main/java/org/doorip/todo/domain/Allocator.java b/doorip-domain/src/main/java/org/doorip/todo/domain/Allocator.java new file mode 100644 index 0000000..e246c1d --- /dev/null +++ b/doorip-domain/src/main/java/org/doorip/todo/domain/Allocator.java @@ -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; +} diff --git a/doorip-domain/src/main/java/org/doorip/todo/domain/Progress.java b/doorip-domain/src/main/java/org/doorip/todo/domain/Progress.java new file mode 100644 index 0000000..d90b40d --- /dev/null +++ b/doorip-domain/src/main/java/org/doorip/todo/domain/Progress.java @@ -0,0 +1,5 @@ +package org.doorip.todo.domain; + +public enum Progress { + INCOMPLETE, COMPLETE +} diff --git a/doorip-domain/src/main/java/org/doorip/todo/domain/Secret.java b/doorip-domain/src/main/java/org/doorip/todo/domain/Secret.java new file mode 100644 index 0000000..2ec6a7b --- /dev/null +++ b/doorip-domain/src/main/java/org/doorip/todo/domain/Secret.java @@ -0,0 +1,5 @@ +package org.doorip.todo.domain; + +public enum Secret { + OUR, MY +} diff --git a/doorip-domain/src/main/java/org/doorip/todo/domain/Todo.java b/doorip-domain/src/main/java/org/doorip/todo/domain/Todo.java new file mode 100644 index 0000000..560fcf7 --- /dev/null +++ b/doorip-domain/src/main/java/org/doorip/todo/domain/Todo.java @@ -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 allocators = new ArrayList<>(); +} diff --git a/doorip-domain/src/main/java/org/doorip/trip/domain/Participant.java b/doorip-domain/src/main/java/org/doorip/trip/domain/Participant.java new file mode 100644 index 0000000..fd58ae8 --- /dev/null +++ b/doorip-domain/src/main/java/org/doorip/trip/domain/Participant.java @@ -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; +} diff --git a/doorip-domain/src/main/java/org/doorip/trip/domain/Role.java b/doorip-domain/src/main/java/org/doorip/trip/domain/Role.java new file mode 100644 index 0000000..cdbdfa7 --- /dev/null +++ b/doorip-domain/src/main/java/org/doorip/trip/domain/Role.java @@ -0,0 +1,5 @@ +package org.doorip.trip.domain; + +public enum Role { + HOST, PARTICIPATION +} diff --git a/doorip-domain/src/main/java/org/doorip/trip/domain/Trip.java b/doorip-domain/src/main/java/org/doorip/trip/domain/Trip.java new file mode 100644 index 0000000..265bf39 --- /dev/null +++ b/doorip-domain/src/main/java/org/doorip/trip/domain/Trip.java @@ -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 participants = new ArrayList<>(); + @Builder.Default + @OneToMany(mappedBy = "trip", cascade = CascadeType.REMOVE) + private List todos = new ArrayList<>(); +} diff --git a/doorip-domain/src/main/java/org/doorip/user/domain/Platform.java b/doorip-domain/src/main/java/org/doorip/user/domain/Platform.java new file mode 100644 index 0000000..c46c049 --- /dev/null +++ b/doorip-domain/src/main/java/org/doorip/user/domain/Platform.java @@ -0,0 +1,5 @@ +package org.doorip.user.domain; + +public enum Platform { + KAKAO, APPLE +} diff --git a/doorip-domain/src/main/java/org/doorip/user/domain/User.java b/doorip-domain/src/main/java/org/doorip/user/domain/User.java new file mode 100644 index 0000000..abd5ea8 --- /dev/null +++ b/doorip-domain/src/main/java/org/doorip/user/domain/User.java @@ -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 participants = new ArrayList<>(); +}