mirror of
https://git.imnavajas.es/jjimenez/erp-imprimelibros.git
synced 2026-01-13 08:58:48 +00:00
70 lines
1.5 KiB
Java
70 lines
1.5 KiB
Java
package com.imprimelibros.erp.users;
|
|
|
|
import jakarta.persistence.Column;
|
|
import jakarta.persistence.Entity;
|
|
import jakarta.persistence.GeneratedValue;
|
|
import jakarta.persistence.GenerationType;
|
|
import jakarta.persistence.Id;
|
|
import jakarta.persistence.Table;
|
|
|
|
import java.util.HashSet;
|
|
import java.util.Set;
|
|
import org.hibernate.annotations.SQLRestriction;
|
|
import jakarta.persistence.OneToMany;
|
|
import jakarta.persistence.FetchType;
|
|
|
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
|
|
|
@Entity
|
|
@Table(name = "roles")
|
|
public class Role {
|
|
|
|
@Id
|
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
|
@Column(name = "id")
|
|
private Long id;
|
|
|
|
@Column(name = "name")
|
|
private String name;
|
|
|
|
@JsonIgnore
|
|
@SQLRestriction("deleted = false")
|
|
@OneToMany(mappedBy = "role", fetch = FetchType.LAZY)
|
|
private Set<UserRole> usersLink = new HashSet<>();
|
|
|
|
public Role() {
|
|
}
|
|
|
|
public Role(String name) {
|
|
this.name = name;
|
|
}
|
|
|
|
public Long getId() {
|
|
return id;
|
|
}
|
|
|
|
public void setId(Long id) {
|
|
this.id = id;
|
|
}
|
|
|
|
public String getName() {
|
|
return name;
|
|
}
|
|
|
|
public void setName(String name) {
|
|
this.name = name;
|
|
}
|
|
|
|
public Set<UserRole> getUsersLink() {
|
|
return usersLink;
|
|
}
|
|
|
|
public void setUsersLink(Set<UserRole> usersLink) {
|
|
this.usersLink = usersLink;
|
|
}
|
|
|
|
@Override
|
|
public String toString() {
|
|
return "Role{" + "id=" + id + ", name='" + name + '\'' + '}';
|
|
}
|
|
} |