Database creation (Tables)
This commit is contained in:
parent
9e0db361b8
commit
cb750b8505
@ -16,6 +16,8 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
compileOnly("org.projectlombok:lombok")
|
||||||
|
annotationProcessor("org.projectlombok:lombok")
|
||||||
implementation("org.springframework.boot:spring-boot-starter-jdbc")
|
implementation("org.springframework.boot:spring-boot-starter-jdbc")
|
||||||
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
|
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
|
||||||
implementation("org.springframework.boot:spring-boot-starter-mail")
|
implementation("org.springframework.boot:spring-boot-starter-mail")
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
package ovh.herisson.Clyde.Tables;
|
package ovh.herisson.Clyde.Tables;
|
||||||
|
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
|
import ovh.herisson.Clyde.Tables.Msg.Forum;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.hibernate.annotations.OnDelete;
|
import org.hibernate.annotations.OnDelete;
|
||||||
import org.hibernate.annotations.OnDeleteAction;
|
import org.hibernate.annotations.OnDeleteAction;
|
||||||
|
|
||||||
@ -17,6 +21,11 @@ public class Course {
|
|||||||
@JoinColumn(name = "Users")
|
@JoinColumn(name = "Users")
|
||||||
private User owner;
|
private User owner;
|
||||||
|
|
||||||
|
//// Extension Messagerie /////
|
||||||
|
@OneToMany
|
||||||
|
private List<Forum> forums;
|
||||||
|
///////////////////////////////
|
||||||
|
|
||||||
public Course(int credits, String title, User owner){
|
public Course(int credits, String title, User owner){
|
||||||
this.credits = credits;
|
this.credits = credits;
|
||||||
this.title = title;
|
this.title = title;
|
||||||
|
@ -0,0 +1,32 @@
|
|||||||
|
package ovh.herisson.Clyde.Tables.Msg;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import org.hibernate.annotations.CreationTimestamp;
|
||||||
|
|
||||||
|
import jakarta.persistence.*;
|
||||||
|
import lombok.Data;
|
||||||
|
import ovh.herisson.Clyde.Tables.User;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Data
|
||||||
|
public class Answers {
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||||
|
private int id;
|
||||||
|
|
||||||
|
@CreationTimestamp
|
||||||
|
private Date creation;
|
||||||
|
|
||||||
|
@ManyToOne
|
||||||
|
private Topic topic;
|
||||||
|
|
||||||
|
private String content;
|
||||||
|
|
||||||
|
@OneToOne
|
||||||
|
private User author;
|
||||||
|
|
||||||
|
private boolean anonymous;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
package ovh.herisson.Clyde.Tables.Msg;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import jakarta.persistence.*;
|
||||||
|
import lombok.Data;
|
||||||
|
import ovh.herisson.Clyde.Tables.Course;
|
||||||
|
import ovh.herisson.Clyde.Tables.User;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Data
|
||||||
|
public class Forum {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||||
|
private int id;
|
||||||
|
|
||||||
|
@ManyToOne(cascade = CascadeType.ALL)
|
||||||
|
private Course course;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@OneToMany
|
||||||
|
private List<User> writers; // User who are authorized to create a post
|
||||||
|
|
||||||
|
@OneToMany
|
||||||
|
private List<User> register;
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
package ovh.herisson.Clyde.Tables.Msg;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import jakarta.persistence.*;
|
||||||
|
import lombok.Data;
|
||||||
|
import ovh.herisson.Clyde.Tables.User;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Data
|
||||||
|
public class Topic {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||||
|
private int id;
|
||||||
|
|
||||||
|
private String subject, content;
|
||||||
|
|
||||||
|
@OneToOne
|
||||||
|
private User author;
|
||||||
|
|
||||||
|
@OneToMany(mappedBy = "topic", cascade = CascadeType.ALL)
|
||||||
|
private List<Answers> answers;
|
||||||
|
|
||||||
|
private boolean locked; // true if new messages can be posted
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user