Skip to content

Commit

Permalink
Merge pull request #7 from Team-Going/feature/6
Browse files Browse the repository at this point in the history
[feat] 엔티티 클래스 매핑
  • Loading branch information
SunwoongH authored Jan 4, 2024
2 parents cc43dc3 + c05b969 commit b57de69
Show file tree
Hide file tree
Showing 9 changed files with 194 additions and 0 deletions.
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<>();
}

0 comments on commit b57de69

Please sign in to comment.