diff --git a/src/main/java/org/camelia/studio/gachamelia/models/Element.java b/src/main/java/org/camelia/studio/gachamelia/models/Element.java new file mode 100644 index 0000000..3a9c774 --- /dev/null +++ b/src/main/java/org/camelia/studio/gachamelia/models/Element.java @@ -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 users; + + public Long getId() { + return id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public List getUsers() { + return users; + } + + public Element() { + } + + public Element(String name) { + this.name = name; + } +} diff --git a/src/main/java/org/camelia/studio/gachamelia/models/Role.java b/src/main/java/org/camelia/studio/gachamelia/models/Role.java new file mode 100644 index 0000000..263fa87 --- /dev/null +++ b/src/main/java/org/camelia/studio/gachamelia/models/Role.java @@ -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 users; + + public List 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; + } +} diff --git a/src/main/java/org/camelia/studio/gachamelia/models/Stat.java b/src/main/java/org/camelia/studio/gachamelia/models/Stat.java new file mode 100644 index 0000000..9bcbdd6 --- /dev/null +++ b/src/main/java/org/camelia/studio/gachamelia/models/Stat.java @@ -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; + } +} diff --git a/src/main/java/org/camelia/studio/gachamelia/models/User.java b/src/main/java/org/camelia/studio/gachamelia/models/User.java index d0c769d..2251486 100644 --- a/src/main/java/org/camelia/studio/gachamelia/models/User.java +++ b/src/main/java/org/camelia/studio/gachamelia/models/User.java @@ -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() { }