|
|
@@ -1,13 +1,13 @@
|
|
|
package pl.dmcs.eldarmuk.backend_springboot.model;
|
|
|
|
|
|
+import jakarta.persistence.*;
|
|
|
import org.hibernate.validator.constraints.Length;
|
|
|
|
|
|
-import jakarta.persistence.Entity;
|
|
|
-import jakarta.persistence.GeneratedValue;
|
|
|
-import jakarta.persistence.GenerationType;
|
|
|
-import jakarta.persistence.Id;
|
|
|
import jakarta.validation.constraints.NotBlank;
|
|
|
|
|
|
+import java.util.HashSet;
|
|
|
+import java.util.Set;
|
|
|
+
|
|
|
@Entity
|
|
|
public class Account {
|
|
|
@Id
|
|
|
@@ -22,6 +22,9 @@ public class Account {
|
|
|
@Length(min = 6, max = 100)
|
|
|
private String password;
|
|
|
|
|
|
+ @ManyToMany(fetch = FetchType.EAGER)
|
|
|
+ private Set<Role> roles = new HashSet<>();
|
|
|
+
|
|
|
public Account() {}
|
|
|
|
|
|
public Account(@NotBlank @Length(min = 3, max = 50) String username, @NotBlank @Length(min = 6, max = 100) String password) {
|
|
|
@@ -52,4 +55,12 @@ public class Account {
|
|
|
public void setPassword(String password) {
|
|
|
this.password = password;
|
|
|
}
|
|
|
+
|
|
|
+ public Set<Role> getRoles() {
|
|
|
+ return roles;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setRoles(Set<Role> roles) {
|
|
|
+ this.roles = roles;
|
|
|
+ }
|
|
|
}
|