Initial commit: GBCM Server API with DTOs, interfaces and enums
This commit is contained in:
107
src/main/java/com/gbcm/server/api/enums/UserRole.java
Normal file
107
src/main/java/com/gbcm/server/api/enums/UserRole.java
Normal file
@@ -0,0 +1,107 @@
|
||||
package com.gbcm.server.api.enums;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
/**
|
||||
* Énumération des rôles utilisateur dans GBCM
|
||||
*/
|
||||
public enum UserRole {
|
||||
|
||||
/**
|
||||
* Administrateur système - Accès complet
|
||||
*/
|
||||
ADMIN("ADMIN", "Administrateur", "Accès complet au système"),
|
||||
|
||||
/**
|
||||
* Coach/Consultant - Gestion des clients et programmes
|
||||
*/
|
||||
COACH("COACH", "Coach", "Gestion des clients et programmes de coaching"),
|
||||
|
||||
/**
|
||||
* Client - Accès aux services souscrits
|
||||
*/
|
||||
CLIENT("CLIENT", "Client", "Accès aux services et programmes souscrits"),
|
||||
|
||||
/**
|
||||
* Prospect - Accès limité pour découverte
|
||||
*/
|
||||
PROSPECT("PROSPECT", "Prospect", "Accès limité aux ressources de découverte"),
|
||||
|
||||
/**
|
||||
* Manager - Gestion opérationnelle
|
||||
*/
|
||||
MANAGER("MANAGER", "Manager", "Gestion opérationnelle et supervision");
|
||||
|
||||
private final String code;
|
||||
private final String displayName;
|
||||
private final String description;
|
||||
|
||||
UserRole(String code, String displayName, String description) {
|
||||
this.code = code;
|
||||
this.displayName = displayName;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
@JsonValue
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Trouve un rôle par son code
|
||||
*/
|
||||
public static UserRole fromCode(String code) {
|
||||
if (code == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
for (UserRole role : values()) {
|
||||
if (role.code.equalsIgnoreCase(code)) {
|
||||
return role;
|
||||
}
|
||||
}
|
||||
|
||||
throw new IllegalArgumentException("Rôle inconnu: " + code);
|
||||
}
|
||||
|
||||
/**
|
||||
* Vérifie si le rôle a des privilèges administrateur
|
||||
*/
|
||||
public boolean isAdmin() {
|
||||
return this == ADMIN;
|
||||
}
|
||||
|
||||
/**
|
||||
* Vérifie si le rôle peut gérer des clients
|
||||
*/
|
||||
public boolean canManageClients() {
|
||||
return this == ADMIN || this == COACH || this == MANAGER;
|
||||
}
|
||||
|
||||
/**
|
||||
* Vérifie si le rôle peut accéder aux services
|
||||
*/
|
||||
public boolean canAccessServices() {
|
||||
return this == CLIENT || this == COACH || this == ADMIN || this == MANAGER;
|
||||
}
|
||||
|
||||
/**
|
||||
* Vérifie si le rôle peut voir les rapports
|
||||
*/
|
||||
public boolean canViewReports() {
|
||||
return this == ADMIN || this == MANAGER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return displayName;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user