Ajout des entités

This commit is contained in:
Melaine Gérard 2024-11-20 22:39:15 +01:00
parent 706c2a8e21
commit 305ddb6112
4 changed files with 145 additions and 0 deletions

View File

@ -0,0 +1,43 @@
package org.camelia.studio.gachamelia.models;
import jakarta.persistence.*;
import org.camelia.studio.gachamelia.interfaces.IEntity;
import java.util.List;
@Entity
@Table(name = "elements")
public class Element implements IEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(nullable = false)
private String name;
@OneToMany(mappedBy = "element")
private List<User> users;
public Long getId() {
return id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public List<User> getUsers() {
return users;
}
public Element() {
}
public Element(String name) {
this.name = name;
}
}

View File

@ -0,0 +1,55 @@
package org.camelia.studio.gachamelia.models;
import jakarta.persistence.*;
import org.camelia.studio.gachamelia.interfaces.IEntity;
import java.util.List;
@Entity
@Table(name = "roles")
public class Role implements IEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(nullable = false)
private String name;
@Column(nullable = false)
private int percentage;
@OneToMany(mappedBy = "role")
private List<User> users;
public List<User> getUsers() {
return users;
}
public Long getId() {
return id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getPercentage() {
return percentage;
}
public void setPercentage(int percentage) {
this.percentage = percentage;
}
public Role() {
}
public Role(String name, int percentage) {
this.name = name;
this.percentage = percentage;
}
}

View File

@ -0,0 +1,34 @@
package org.camelia.studio.gachamelia.models;
import jakarta.persistence.*;
import org.camelia.studio.gachamelia.interfaces.IEntity;
@Entity
@Table(name = "stats")
public class Stat implements IEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(nullable = false)
private String name;
public Long getId() {
return id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Stat() {
}
public Stat(String name) {
this.name = name;
}
}

View File

@ -28,6 +28,19 @@ public class User implements IEntity {
@Column(name = "updatedAt")
private LocalDateTime updatedAt;
@ManyToOne(fetch = FetchType.EAGER)
private Element element;
@ManyToOne(fetch = FetchType.EAGER)
private Role role;
public Element getElement() {
return element;
}
public Role getRole() {
return role;
}
public User() {
}