Files
fiscad/src/main/java/io/gmss/fiscad/entities/user/Profile.java
Aurince AKAKPO c65fd8a450
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 32s
gestion de profil, secteur, section et arbre decoupage
2026-01-27 09:37:11 +01:00

79 lines
2.0 KiB
Java
Executable File

package io.gmss.fiscad.entities.user;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.gmss.fiscad.entities.BaseEntity;
import io.gmss.fiscad.enums.UserProfile;
import io.gmss.fiscad.enums.UserRole;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;
//@EqualsAndHashCode(callSuper = true)
@Data
@AllArgsConstructor
@NoArgsConstructor
@Entity
public class Profile extends BaseEntity implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Enumerated(EnumType.STRING)
private UserProfile nom;
private String description;
public Profile(UserProfile name, String description) {
this.nom = name;
this.description = description;
}
@ManyToMany(fetch = FetchType.LAZY)
@JoinTable(name = "profile_role",
joinColumns = @JoinColumn(name = "profile_id"),
inverseJoinColumns = @JoinColumn(name = "role_id")
)
private Set<Role> roles = new HashSet<>();
@Override
public boolean equals(Object o) {
// If the object is compared with itself then return true
if (o == this) {
return true;
}
/* Check if o is an instance of Complex or not
"null instanceof [type]" also returns false */
if (!(o instanceof Profile)) {
return false;
}
// typecast o to Complex so that we can compare data members
Profile r = (Profile) o;
// Compare the data members and return accordingly
return r.getNom().equals(this.getNom());
}
@Override
public int hashCode() {
return Objects.hash(id, nom, description);
}
@JsonIgnore
public Long getExternalKey() {
return super.getExternalKey();
}
@JsonIgnore
public Long getEnqueteExternalKey() {
return super.getEnqueteExternalKey();
}
}