Skip to content

Commit

Permalink
Merge pull request #18 from Soongsil-CoffeeChat/init/#17
Browse files Browse the repository at this point in the history
init: Entities
  • Loading branch information
KimKyoHwee authored Mar 31, 2024
2 parents 458f3e5 + d310433 commit b9cff09
Show file tree
Hide file tree
Showing 7 changed files with 154 additions and 1 deletion.
35 changes: 35 additions & 0 deletions src/main/java/com/soongsil/CoffeeChat/entity/Application.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.soongsil.CoffeeChat.entity;

import jakarta.persistence.*;
import lombok.Getter;
import lombok.Setter;

@Entity
@Getter
@Setter
public class Application {
@Column(name = "application_id")
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@ManyToOne
@JoinColumn(name = "mentor_id")
private Mentor mentor;

@ManyToOne
@JoinColumn(name = "mentee_id")
private Mentee mentee;

@Column
private String date;

@Column
private String time;

@Column
private String question;

@Column
private boolean accept;
}
25 changes: 25 additions & 0 deletions src/main/java/com/soongsil/CoffeeChat/entity/Club.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.soongsil.CoffeeChat.entity;

import jakarta.persistence.*;
import lombok.Getter;
import lombok.Setter;

@Entity
@Getter
@Setter
public class Club {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name="club_id")
private Long id;

@ManyToOne
@JoinColumn(name = "mentor_id")
private Mentor mentor;

@Column
private String name;

@Column
private String position;
}
28 changes: 28 additions & 0 deletions src/main/java/com/soongsil/CoffeeChat/entity/Mentee.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.soongsil.CoffeeChat.entity;

import jakarta.persistence.CascadeType;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.OneToMany;
import lombok.Getter;
import lombok.Setter;

import java.util.HashSet;
import java.util.Set;

@Entity
@Getter
@Setter
public class Mentee extends User{
@Column(name = "phone_num")
private String phoneNum;

@Column
private String birth;

@Column
private String part;

@OneToMany(mappedBy = "mentee", cascade = CascadeType.ALL, orphanRemoval = true)
private Set<Application> applications = new HashSet<>();
}
34 changes: 34 additions & 0 deletions src/main/java/com/soongsil/CoffeeChat/entity/Mentor.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.soongsil.CoffeeChat.entity;

import jakarta.persistence.CascadeType;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.OneToMany;
import lombok.Getter;
import lombok.Setter;

import java.util.HashSet;
import java.util.Set;

@Entity
@Getter
@Setter
public class Mentor extends User{
@Column
private int grade;

@Column
private String major;

@Column
private String memo;

@OneToMany(mappedBy = "mentor", cascade = CascadeType.ALL, orphanRemoval = true)
private Set<Application> applications = new HashSet<>();

@OneToMany(mappedBy = "mentor", cascade = CascadeType.ALL, orphanRemoval = true)
private Set<Club> clubs = new HashSet<>();

@OneToMany(mappedBy = "mentor", cascade = CascadeType.ALL, orphanRemoval = true)
private Set<PossibleDate> possibleDates = new HashSet<>();
}
28 changes: 28 additions & 0 deletions src/main/java/com/soongsil/CoffeeChat/entity/PossibleDate.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.soongsil.CoffeeChat.entity;

import jakarta.persistence.*;
import lombok.Getter;
import lombok.Setter;

@Entity
@Getter
@Setter
public class PossibleDate {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "possible_date_id")
private Long id;

@ManyToOne
@JoinColumn(name = "mentor_id")
private Mentor mentor;

@Column
private String date;

@Column
private String time;

@Column
private boolean apply;
}
2 changes: 1 addition & 1 deletion src/main/java/com/soongsil/CoffeeChat/entity/Refresh.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
@Entity
@Getter
@Setter
public class Refresh {
public class Refresh { //사용 가능 Refresh토큰 DB저장용
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/com/soongsil/CoffeeChat/entity/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@
@Entity
@Getter
@Setter
@Inheritance(strategy = InheritanceType.JOINED) //자식 : Mentor, Mentee
@DiscriminatorColumn // 하위 테이블의 구분 컬럼 생성(default = DTYPE)
public class User {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "user_id")
private Long id;

@Column
Expand Down

0 comments on commit b9cff09

Please sign in to comment.