Refactoring
This commit is contained in:
@@ -0,0 +1,524 @@
|
||||
import '../../domain/entities/demande_aide.dart';
|
||||
|
||||
/// Modèle de données pour les demandes d'aide
|
||||
///
|
||||
/// Ce modèle fait la conversion entre les DTOs de l'API REST
|
||||
/// et les entités du domaine pour les demandes d'aide.
|
||||
class DemandeAideModel extends DemandeAide {
|
||||
const DemandeAideModel({
|
||||
required super.id,
|
||||
required super.numeroReference,
|
||||
required super.titre,
|
||||
required super.description,
|
||||
required super.typeAide,
|
||||
required super.statut,
|
||||
required super.priorite,
|
||||
required super.demandeurId,
|
||||
required super.nomDemandeur,
|
||||
required super.organisationId,
|
||||
super.montantDemande,
|
||||
super.montantApprouve,
|
||||
super.montantVerse,
|
||||
required super.dateCreation,
|
||||
required super.dateModification,
|
||||
super.dateSoumission,
|
||||
super.dateEvaluation,
|
||||
super.dateApprobation,
|
||||
super.dateLimiteTraitement,
|
||||
super.evaluateurId,
|
||||
super.commentairesEvaluateur,
|
||||
super.motifRejet,
|
||||
super.informationsRequises,
|
||||
super.justificationUrgence,
|
||||
super.contactUrgence,
|
||||
super.localisation,
|
||||
super.beneficiaires,
|
||||
super.piecesJustificatives,
|
||||
super.historiqueStatuts,
|
||||
super.commentaires,
|
||||
super.donneesPersonnalisees,
|
||||
super.estModifiable,
|
||||
super.estUrgente,
|
||||
super.delaiDepasse,
|
||||
super.estTerminee,
|
||||
});
|
||||
|
||||
/// Crée un modèle à partir d'un JSON (API Response)
|
||||
factory DemandeAideModel.fromJson(Map<String, dynamic> json) {
|
||||
return DemandeAideModel(
|
||||
id: json['id'] as String,
|
||||
numeroReference: json['numeroReference'] as String,
|
||||
titre: json['titre'] as String,
|
||||
description: json['description'] as String,
|
||||
typeAide: _parseTypeAide(json['typeAide'] as String),
|
||||
statut: _parseStatutAide(json['statut'] as String),
|
||||
priorite: _parsePrioriteAide(json['priorite'] as String),
|
||||
demandeurId: json['demandeurId'] as String,
|
||||
nomDemandeur: json['nomDemandeur'] as String,
|
||||
organisationId: json['organisationId'] as String,
|
||||
montantDemande: json['montantDemande']?.toDouble(),
|
||||
montantApprouve: json['montantApprouve']?.toDouble(),
|
||||
montantVerse: json['montantVerse']?.toDouble(),
|
||||
dateCreation: DateTime.parse(json['dateCreation'] as String),
|
||||
dateModification: DateTime.parse(json['dateModification'] as String),
|
||||
dateSoumission: json['dateSoumission'] != null
|
||||
? DateTime.parse(json['dateSoumission'] as String)
|
||||
: null,
|
||||
dateEvaluation: json['dateEvaluation'] != null
|
||||
? DateTime.parse(json['dateEvaluation'] as String)
|
||||
: null,
|
||||
dateApprobation: json['dateApprobation'] != null
|
||||
? DateTime.parse(json['dateApprobation'] as String)
|
||||
: null,
|
||||
dateLimiteTraitement: json['dateLimiteTraitement'] != null
|
||||
? DateTime.parse(json['dateLimiteTraitement'] as String)
|
||||
: null,
|
||||
evaluateurId: json['evaluateurId'] as String?,
|
||||
commentairesEvaluateur: json['commentairesEvaluateur'] as String?,
|
||||
motifRejet: json['motifRejet'] as String?,
|
||||
informationsRequises: json['informationsRequises'] as String?,
|
||||
justificationUrgence: json['justificationUrgence'] as String?,
|
||||
contactUrgence: json['contactUrgence'] != null
|
||||
? ContactUrgenceModel.fromJson(json['contactUrgence'] as Map<String, dynamic>)
|
||||
: null,
|
||||
localisation: json['localisation'] != null
|
||||
? LocalisationModel.fromJson(json['localisation'] as Map<String, dynamic>)
|
||||
: null,
|
||||
beneficiaires: (json['beneficiaires'] as List<dynamic>?)
|
||||
?.map((e) => BeneficiaireAideModel.fromJson(e as Map<String, dynamic>))
|
||||
.toList() ?? [],
|
||||
piecesJustificatives: (json['piecesJustificatives'] as List<dynamic>?)
|
||||
?.map((e) => PieceJustificativeModel.fromJson(e as Map<String, dynamic>))
|
||||
.toList() ?? [],
|
||||
historiqueStatuts: (json['historiqueStatuts'] as List<dynamic>?)
|
||||
?.map((e) => HistoriqueStatutModel.fromJson(e as Map<String, dynamic>))
|
||||
.toList() ?? [],
|
||||
commentaires: (json['commentaires'] as List<dynamic>?)
|
||||
?.map((e) => CommentaireAideModel.fromJson(e as Map<String, dynamic>))
|
||||
.toList() ?? [],
|
||||
donneesPersonnalisees: Map<String, dynamic>.from(json['donneesPersonnalisees'] ?? {}),
|
||||
estModifiable: json['estModifiable'] as bool? ?? false,
|
||||
estUrgente: json['estUrgente'] as bool? ?? false,
|
||||
delaiDepasse: json['delaiDepasse'] as bool? ?? false,
|
||||
estTerminee: json['estTerminee'] as bool? ?? false,
|
||||
);
|
||||
}
|
||||
|
||||
/// Convertit le modèle en JSON (API Request)
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'id': id,
|
||||
'numeroReference': numeroReference,
|
||||
'titre': titre,
|
||||
'description': description,
|
||||
'typeAide': typeAide.name,
|
||||
'statut': statut.name,
|
||||
'priorite': priorite.name,
|
||||
'demandeurId': demandeurId,
|
||||
'nomDemandeur': nomDemandeur,
|
||||
'organisationId': organisationId,
|
||||
'montantDemande': montantDemande,
|
||||
'montantApprouve': montantApprouve,
|
||||
'montantVerse': montantVerse,
|
||||
'dateCreation': dateCreation.toIso8601String(),
|
||||
'dateModification': dateModification.toIso8601String(),
|
||||
'dateSoumission': dateSoumission?.toIso8601String(),
|
||||
'dateEvaluation': dateEvaluation?.toIso8601String(),
|
||||
'dateApprobation': dateApprobation?.toIso8601String(),
|
||||
'dateLimiteTraitement': dateLimiteTraitement?.toIso8601String(),
|
||||
'evaluateurId': evaluateurId,
|
||||
'commentairesEvaluateur': commentairesEvaluateur,
|
||||
'motifRejet': motifRejet,
|
||||
'informationsRequises': informationsRequises,
|
||||
'justificationUrgence': justificationUrgence,
|
||||
'contactUrgence': contactUrgence != null
|
||||
? (contactUrgence as ContactUrgenceModel).toJson()
|
||||
: null,
|
||||
'localisation': localisation != null
|
||||
? (localisation as LocalisationModel).toJson()
|
||||
: null,
|
||||
'beneficiaires': beneficiaires
|
||||
.map((e) => (e as BeneficiaireAideModel).toJson())
|
||||
.toList(),
|
||||
'piecesJustificatives': piecesJustificatives
|
||||
.map((e) => (e as PieceJustificativeModel).toJson())
|
||||
.toList(),
|
||||
'historiqueStatuts': historiqueStatuts
|
||||
.map((e) => (e as HistoriqueStatutModel).toJson())
|
||||
.toList(),
|
||||
'commentaires': commentaires
|
||||
.map((e) => (e as CommentaireAideModel).toJson())
|
||||
.toList(),
|
||||
'donneesPersonnalisees': donneesPersonnalisees,
|
||||
'estModifiable': estModifiable,
|
||||
'estUrgente': estUrgente,
|
||||
'delaiDepasse': delaiDepasse,
|
||||
'estTerminee': estTerminee,
|
||||
};
|
||||
}
|
||||
|
||||
/// Crée un modèle à partir d'une entité du domaine
|
||||
factory DemandeAideModel.fromEntity(DemandeAide entity) {
|
||||
return DemandeAideModel(
|
||||
id: entity.id,
|
||||
numeroReference: entity.numeroReference,
|
||||
titre: entity.titre,
|
||||
description: entity.description,
|
||||
typeAide: entity.typeAide,
|
||||
statut: entity.statut,
|
||||
priorite: entity.priorite,
|
||||
demandeurId: entity.demandeurId,
|
||||
nomDemandeur: entity.nomDemandeur,
|
||||
organisationId: entity.organisationId,
|
||||
montantDemande: entity.montantDemande,
|
||||
montantApprouve: entity.montantApprouve,
|
||||
montantVerse: entity.montantVerse,
|
||||
dateCreation: entity.dateCreation,
|
||||
dateModification: entity.dateModification,
|
||||
dateSoumission: entity.dateSoumission,
|
||||
dateEvaluation: entity.dateEvaluation,
|
||||
dateApprobation: entity.dateApprobation,
|
||||
dateLimiteTraitement: entity.dateLimiteTraitement,
|
||||
evaluateurId: entity.evaluateurId,
|
||||
commentairesEvaluateur: entity.commentairesEvaluateur,
|
||||
motifRejet: entity.motifRejet,
|
||||
informationsRequises: entity.informationsRequises,
|
||||
justificationUrgence: entity.justificationUrgence,
|
||||
contactUrgence: entity.contactUrgence != null
|
||||
? ContactUrgenceModel.fromEntity(entity.contactUrgence!)
|
||||
: null,
|
||||
localisation: entity.localisation != null
|
||||
? LocalisationModel.fromEntity(entity.localisation!)
|
||||
: null,
|
||||
beneficiaires: entity.beneficiaires
|
||||
.map((e) => BeneficiaireAideModel.fromEntity(e))
|
||||
.toList(),
|
||||
piecesJustificatives: entity.piecesJustificatives
|
||||
.map((e) => PieceJustificativeModel.fromEntity(e))
|
||||
.toList(),
|
||||
historiqueStatuts: entity.historiqueStatuts
|
||||
.map((e) => HistoriqueStatutModel.fromEntity(e))
|
||||
.toList(),
|
||||
commentaires: entity.commentaires
|
||||
.map((e) => CommentaireAideModel.fromEntity(e))
|
||||
.toList(),
|
||||
donneesPersonnalisees: Map<String, dynamic>.from(entity.donneesPersonnalisees),
|
||||
estModifiable: entity.estModifiable,
|
||||
estUrgente: entity.estUrgente,
|
||||
delaiDepasse: entity.delaiDepasse,
|
||||
estTerminee: entity.estTerminee,
|
||||
);
|
||||
}
|
||||
|
||||
/// Convertit le modèle en entité du domaine
|
||||
DemandeAide toEntity() {
|
||||
return DemandeAide(
|
||||
id: id,
|
||||
numeroReference: numeroReference,
|
||||
titre: titre,
|
||||
description: description,
|
||||
typeAide: typeAide,
|
||||
statut: statut,
|
||||
priorite: priorite,
|
||||
demandeurId: demandeurId,
|
||||
nomDemandeur: nomDemandeur,
|
||||
organisationId: organisationId,
|
||||
montantDemande: montantDemande,
|
||||
montantApprouve: montantApprouve,
|
||||
montantVerse: montantVerse,
|
||||
dateCreation: dateCreation,
|
||||
dateModification: dateModification,
|
||||
dateSoumission: dateSoumission,
|
||||
dateEvaluation: dateEvaluation,
|
||||
dateApprobation: dateApprobation,
|
||||
dateLimiteTraitement: dateLimiteTraitement,
|
||||
evaluateurId: evaluateurId,
|
||||
commentairesEvaluateur: commentairesEvaluateur,
|
||||
motifRejet: motifRejet,
|
||||
informationsRequises: informationsRequises,
|
||||
justificationUrgence: justificationUrgence,
|
||||
contactUrgence: contactUrgence,
|
||||
localisation: localisation,
|
||||
beneficiaires: beneficiaires,
|
||||
piecesJustificatives: piecesJustificatives,
|
||||
historiqueStatuts: historiqueStatuts,
|
||||
commentaires: commentaires,
|
||||
donneesPersonnalisees: donneesPersonnalisees,
|
||||
estModifiable: estModifiable,
|
||||
estUrgente: estUrgente,
|
||||
delaiDepasse: delaiDepasse,
|
||||
estTerminee: estTerminee,
|
||||
);
|
||||
}
|
||||
|
||||
// Méthodes utilitaires de parsing
|
||||
static TypeAide _parseTypeAide(String value) {
|
||||
return TypeAide.values.firstWhere(
|
||||
(e) => e.name == value,
|
||||
orElse: () => TypeAide.autre,
|
||||
);
|
||||
}
|
||||
|
||||
static StatutAide _parseStatutAide(String value) {
|
||||
return StatutAide.values.firstWhere(
|
||||
(e) => e.name == value,
|
||||
orElse: () => StatutAide.brouillon,
|
||||
);
|
||||
}
|
||||
|
||||
static PrioriteAide _parsePrioriteAide(String value) {
|
||||
return PrioriteAide.values.firstWhere(
|
||||
(e) => e.name == value,
|
||||
orElse: () => PrioriteAide.normale,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Modèles pour les classes auxiliaires
|
||||
class ContactUrgenceModel extends ContactUrgence {
|
||||
const ContactUrgenceModel({
|
||||
required super.nom,
|
||||
required super.telephone,
|
||||
super.email,
|
||||
required super.relation,
|
||||
});
|
||||
|
||||
factory ContactUrgenceModel.fromJson(Map<String, dynamic> json) {
|
||||
return ContactUrgenceModel(
|
||||
nom: json['nom'] as String,
|
||||
telephone: json['telephone'] as String,
|
||||
email: json['email'] as String?,
|
||||
relation: json['relation'] as String,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'nom': nom,
|
||||
'telephone': telephone,
|
||||
'email': email,
|
||||
'relation': relation,
|
||||
};
|
||||
}
|
||||
|
||||
factory ContactUrgenceModel.fromEntity(ContactUrgence entity) {
|
||||
return ContactUrgenceModel(
|
||||
nom: entity.nom,
|
||||
telephone: entity.telephone,
|
||||
email: entity.email,
|
||||
relation: entity.relation,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class LocalisationModel extends Localisation {
|
||||
const LocalisationModel({
|
||||
required super.adresse,
|
||||
required super.ville,
|
||||
super.codePostal,
|
||||
super.pays,
|
||||
super.latitude,
|
||||
super.longitude,
|
||||
});
|
||||
|
||||
factory LocalisationModel.fromJson(Map<String, dynamic> json) {
|
||||
return LocalisationModel(
|
||||
adresse: json['adresse'] as String,
|
||||
ville: json['ville'] as String,
|
||||
codePostal: json['codePostal'] as String?,
|
||||
pays: json['pays'] as String?,
|
||||
latitude: json['latitude']?.toDouble(),
|
||||
longitude: json['longitude']?.toDouble(),
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'adresse': adresse,
|
||||
'ville': ville,
|
||||
'codePostal': codePostal,
|
||||
'pays': pays,
|
||||
'latitude': latitude,
|
||||
'longitude': longitude,
|
||||
};
|
||||
}
|
||||
|
||||
factory LocalisationModel.fromEntity(Localisation entity) {
|
||||
return LocalisationModel(
|
||||
adresse: entity.adresse,
|
||||
ville: entity.ville,
|
||||
codePostal: entity.codePostal,
|
||||
pays: entity.pays,
|
||||
latitude: entity.latitude,
|
||||
longitude: entity.longitude,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class BeneficiaireAideModel extends BeneficiaireAide {
|
||||
const BeneficiaireAideModel({
|
||||
required super.nom,
|
||||
required super.prenom,
|
||||
required super.age,
|
||||
required super.relation,
|
||||
super.telephone,
|
||||
});
|
||||
|
||||
factory BeneficiaireAideModel.fromJson(Map<String, dynamic> json) {
|
||||
return BeneficiaireAideModel(
|
||||
nom: json['nom'] as String,
|
||||
prenom: json['prenom'] as String,
|
||||
age: json['age'] as int,
|
||||
relation: json['relation'] as String,
|
||||
telephone: json['telephone'] as String?,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'nom': nom,
|
||||
'prenom': prenom,
|
||||
'age': age,
|
||||
'relation': relation,
|
||||
'telephone': telephone,
|
||||
};
|
||||
}
|
||||
|
||||
factory BeneficiaireAideModel.fromEntity(BeneficiaireAide entity) {
|
||||
return BeneficiaireAideModel(
|
||||
nom: entity.nom,
|
||||
prenom: entity.prenom,
|
||||
age: entity.age,
|
||||
relation: entity.relation,
|
||||
telephone: entity.telephone,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class PieceJustificativeModel extends PieceJustificative {
|
||||
const PieceJustificativeModel({
|
||||
required super.id,
|
||||
required super.nom,
|
||||
required super.type,
|
||||
required super.url,
|
||||
required super.taille,
|
||||
required super.dateAjout,
|
||||
});
|
||||
|
||||
factory PieceJustificativeModel.fromJson(Map<String, dynamic> json) {
|
||||
return PieceJustificativeModel(
|
||||
id: json['id'] as String,
|
||||
nom: json['nom'] as String,
|
||||
type: json['type'] as String,
|
||||
url: json['url'] as String,
|
||||
taille: json['taille'] as int,
|
||||
dateAjout: DateTime.parse(json['dateAjout'] as String),
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'id': id,
|
||||
'nom': nom,
|
||||
'type': type,
|
||||
'url': url,
|
||||
'taille': taille,
|
||||
'dateAjout': dateAjout.toIso8601String(),
|
||||
};
|
||||
}
|
||||
|
||||
factory PieceJustificativeModel.fromEntity(PieceJustificative entity) {
|
||||
return PieceJustificativeModel(
|
||||
id: entity.id,
|
||||
nom: entity.nom,
|
||||
type: entity.type,
|
||||
url: entity.url,
|
||||
taille: entity.taille,
|
||||
dateAjout: entity.dateAjout,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class HistoriqueStatutModel extends HistoriqueStatut {
|
||||
const HistoriqueStatutModel({
|
||||
required super.ancienStatut,
|
||||
required super.nouveauStatut,
|
||||
required super.dateChangement,
|
||||
super.commentaire,
|
||||
super.utilisateurId,
|
||||
});
|
||||
|
||||
factory HistoriqueStatutModel.fromJson(Map<String, dynamic> json) {
|
||||
return HistoriqueStatutModel(
|
||||
ancienStatut: DemandeAideModel._parseStatutAide(json['ancienStatut'] as String),
|
||||
nouveauStatut: DemandeAideModel._parseStatutAide(json['nouveauStatut'] as String),
|
||||
dateChangement: DateTime.parse(json['dateChangement'] as String),
|
||||
commentaire: json['commentaire'] as String?,
|
||||
utilisateurId: json['utilisateurId'] as String?,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'ancienStatut': ancienStatut.name,
|
||||
'nouveauStatut': nouveauStatut.name,
|
||||
'dateChangement': dateChangement.toIso8601String(),
|
||||
'commentaire': commentaire,
|
||||
'utilisateurId': utilisateurId,
|
||||
};
|
||||
}
|
||||
|
||||
factory HistoriqueStatutModel.fromEntity(HistoriqueStatut entity) {
|
||||
return HistoriqueStatutModel(
|
||||
ancienStatut: entity.ancienStatut,
|
||||
nouveauStatut: entity.nouveauStatut,
|
||||
dateChangement: entity.dateChangement,
|
||||
commentaire: entity.commentaire,
|
||||
utilisateurId: entity.utilisateurId,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class CommentaireAideModel extends CommentaireAide {
|
||||
const CommentaireAideModel({
|
||||
required super.id,
|
||||
required super.contenu,
|
||||
required super.auteurId,
|
||||
required super.nomAuteur,
|
||||
required super.dateCreation,
|
||||
super.estPrive,
|
||||
});
|
||||
|
||||
factory CommentaireAideModel.fromJson(Map<String, dynamic> json) {
|
||||
return CommentaireAideModel(
|
||||
id: json['id'] as String,
|
||||
contenu: json['contenu'] as String,
|
||||
auteurId: json['auteurId'] as String,
|
||||
nomAuteur: json['nomAuteur'] as String,
|
||||
dateCreation: DateTime.parse(json['dateCreation'] as String),
|
||||
estPrive: json['estPrive'] as bool? ?? false,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'id': id,
|
||||
'contenu': contenu,
|
||||
'auteurId': auteurId,
|
||||
'nomAuteur': nomAuteur,
|
||||
'dateCreation': dateCreation.toIso8601String(),
|
||||
'estPrive': estPrive,
|
||||
};
|
||||
}
|
||||
|
||||
factory CommentaireAideModel.fromEntity(CommentaireAide entity) {
|
||||
return CommentaireAideModel(
|
||||
id: entity.id,
|
||||
contenu: entity.contenu,
|
||||
auteurId: entity.auteurId,
|
||||
nomAuteur: entity.nomAuteur,
|
||||
dateCreation: entity.dateCreation,
|
||||
estPrive: entity.estPrive,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,388 @@
|
||||
import '../../domain/entities/evaluation_aide.dart';
|
||||
|
||||
/// Modèle de données pour les évaluations d'aide
|
||||
///
|
||||
/// Ce modèle fait la conversion entre les DTOs de l'API REST
|
||||
/// et les entités du domaine pour les évaluations d'aide.
|
||||
class EvaluationAideModel extends EvaluationAide {
|
||||
const EvaluationAideModel({
|
||||
required super.id,
|
||||
required super.demandeId,
|
||||
super.propositionId,
|
||||
required super.evaluateurId,
|
||||
required super.nomEvaluateur,
|
||||
required super.typeEvaluateur,
|
||||
required super.statut,
|
||||
required super.noteGlobale,
|
||||
super.noteDelaiReponse,
|
||||
super.noteCommunication,
|
||||
super.noteProfessionnalisme,
|
||||
super.noteRespectEngagements,
|
||||
required super.commentairePrincipal,
|
||||
super.pointsPositifs,
|
||||
super.pointsAmelioration,
|
||||
super.recommandations,
|
||||
super.recommande,
|
||||
required super.dateCreation,
|
||||
required super.dateModification,
|
||||
super.dateValidation,
|
||||
super.validateurId,
|
||||
super.motifSignalement,
|
||||
super.nombreSignalements,
|
||||
super.estModeree,
|
||||
super.estPublique,
|
||||
super.donneesPersonnalisees,
|
||||
});
|
||||
|
||||
/// Crée un modèle à partir d'un JSON (API Response)
|
||||
factory EvaluationAideModel.fromJson(Map<String, dynamic> json) {
|
||||
return EvaluationAideModel(
|
||||
id: json['id'] as String,
|
||||
demandeId: json['demandeId'] as String,
|
||||
propositionId: json['propositionId'] as String?,
|
||||
evaluateurId: json['evaluateurId'] as String,
|
||||
nomEvaluateur: json['nomEvaluateur'] as String,
|
||||
typeEvaluateur: _parseTypeEvaluateur(json['typeEvaluateur'] as String),
|
||||
statut: _parseStatutEvaluation(json['statut'] as String),
|
||||
noteGlobale: json['noteGlobale'].toDouble(),
|
||||
noteDelaiReponse: json['noteDelaiReponse']?.toDouble(),
|
||||
noteCommunication: json['noteCommunication']?.toDouble(),
|
||||
noteProfessionnalisme: json['noteProfessionnalisme']?.toDouble(),
|
||||
noteRespectEngagements: json['noteRespectEngagements']?.toDouble(),
|
||||
commentairePrincipal: json['commentairePrincipal'] as String,
|
||||
pointsPositifs: json['pointsPositifs'] as String?,
|
||||
pointsAmelioration: json['pointsAmelioration'] as String?,
|
||||
recommandations: json['recommandations'] as String?,
|
||||
recommande: json['recommande'] as bool?,
|
||||
dateCreation: DateTime.parse(json['dateCreation'] as String),
|
||||
dateModification: DateTime.parse(json['dateModification'] as String),
|
||||
dateValidation: json['dateValidation'] != null
|
||||
? DateTime.parse(json['dateValidation'] as String)
|
||||
: null,
|
||||
validateurId: json['validateurId'] as String?,
|
||||
motifSignalement: json['motifSignalement'] as String?,
|
||||
nombreSignalements: json['nombreSignalements'] as int? ?? 0,
|
||||
estModeree: json['estModeree'] as bool? ?? false,
|
||||
estPublique: json['estPublique'] as bool? ?? true,
|
||||
donneesPersonnalisees: Map<String, dynamic>.from(json['donneesPersonnalisees'] ?? {}),
|
||||
);
|
||||
}
|
||||
|
||||
/// Convertit le modèle en JSON (API Request)
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'id': id,
|
||||
'demandeId': demandeId,
|
||||
'propositionId': propositionId,
|
||||
'evaluateurId': evaluateurId,
|
||||
'nomEvaluateur': nomEvaluateur,
|
||||
'typeEvaluateur': typeEvaluateur.name,
|
||||
'statut': statut.name,
|
||||
'noteGlobale': noteGlobale,
|
||||
'noteDelaiReponse': noteDelaiReponse,
|
||||
'noteCommunication': noteCommunication,
|
||||
'noteProfessionnalisme': noteProfessionnalisme,
|
||||
'noteRespectEngagements': noteRespectEngagements,
|
||||
'commentairePrincipal': commentairePrincipal,
|
||||
'pointsPositifs': pointsPositifs,
|
||||
'pointsAmelioration': pointsAmelioration,
|
||||
'recommandations': recommandations,
|
||||
'recommande': recommande,
|
||||
'dateCreation': dateCreation.toIso8601String(),
|
||||
'dateModification': dateModification.toIso8601String(),
|
||||
'dateValidation': dateValidation?.toIso8601String(),
|
||||
'validateurId': validateurId,
|
||||
'motifSignalement': motifSignalement,
|
||||
'nombreSignalements': nombreSignalements,
|
||||
'estModeree': estModeree,
|
||||
'estPublique': estPublique,
|
||||
'donneesPersonnalisees': donneesPersonnalisees,
|
||||
};
|
||||
}
|
||||
|
||||
/// Crée un modèle à partir d'une entité du domaine
|
||||
factory EvaluationAideModel.fromEntity(EvaluationAide entity) {
|
||||
return EvaluationAideModel(
|
||||
id: entity.id,
|
||||
demandeId: entity.demandeId,
|
||||
propositionId: entity.propositionId,
|
||||
evaluateurId: entity.evaluateurId,
|
||||
nomEvaluateur: entity.nomEvaluateur,
|
||||
typeEvaluateur: entity.typeEvaluateur,
|
||||
statut: entity.statut,
|
||||
noteGlobale: entity.noteGlobale,
|
||||
noteDelaiReponse: entity.noteDelaiReponse,
|
||||
noteCommunication: entity.noteCommunication,
|
||||
noteProfessionnalisme: entity.noteProfessionnalisme,
|
||||
noteRespectEngagements: entity.noteRespectEngagements,
|
||||
commentairePrincipal: entity.commentairePrincipal,
|
||||
pointsPositifs: entity.pointsPositifs,
|
||||
pointsAmelioration: entity.pointsAmelioration,
|
||||
recommandations: entity.recommandations,
|
||||
recommande: entity.recommande,
|
||||
dateCreation: entity.dateCreation,
|
||||
dateModification: entity.dateModification,
|
||||
dateValidation: entity.dateValidation,
|
||||
validateurId: entity.validateurId,
|
||||
motifSignalement: entity.motifSignalement,
|
||||
nombreSignalements: entity.nombreSignalements,
|
||||
estModeree: entity.estModeree,
|
||||
estPublique: entity.estPublique,
|
||||
donneesPersonnalisees: Map<String, dynamic>.from(entity.donneesPersonnalisees),
|
||||
);
|
||||
}
|
||||
|
||||
/// Convertit le modèle en entité du domaine
|
||||
EvaluationAide toEntity() {
|
||||
return EvaluationAide(
|
||||
id: id,
|
||||
demandeId: demandeId,
|
||||
propositionId: propositionId,
|
||||
evaluateurId: evaluateurId,
|
||||
nomEvaluateur: nomEvaluateur,
|
||||
typeEvaluateur: typeEvaluateur,
|
||||
statut: statut,
|
||||
noteGlobale: noteGlobale,
|
||||
noteDelaiReponse: noteDelaiReponse,
|
||||
noteCommunication: noteCommunication,
|
||||
noteProfessionnalisme: noteProfessionnalisme,
|
||||
noteRespectEngagements: noteRespectEngagements,
|
||||
commentairePrincipal: commentairePrincipal,
|
||||
pointsPositifs: pointsPositifs,
|
||||
pointsAmelioration: pointsAmelioration,
|
||||
recommandations: recommandations,
|
||||
recommande: recommande,
|
||||
dateCreation: dateCreation,
|
||||
dateModification: dateModification,
|
||||
dateValidation: dateValidation,
|
||||
validateurId: validateurId,
|
||||
motifSignalement: motifSignalement,
|
||||
nombreSignalements: nombreSignalements,
|
||||
estModeree: estModeree,
|
||||
estPublique: estPublique,
|
||||
donneesPersonnalisees: donneesPersonnalisees,
|
||||
);
|
||||
}
|
||||
|
||||
// Méthodes utilitaires de parsing
|
||||
static TypeEvaluateur _parseTypeEvaluateur(String value) {
|
||||
return TypeEvaluateur.values.firstWhere(
|
||||
(e) => e.name == value,
|
||||
orElse: () => TypeEvaluateur.beneficiaire,
|
||||
);
|
||||
}
|
||||
|
||||
static StatutEvaluation _parseStatutEvaluation(String value) {
|
||||
return StatutEvaluation.values.firstWhere(
|
||||
(e) => e.name == value,
|
||||
orElse: () => StatutEvaluation.brouillon,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Modèle pour les statistiques d'évaluation
|
||||
class StatistiquesEvaluationModel {
|
||||
final double noteMoyenne;
|
||||
final int nombreEvaluations;
|
||||
final Map<int, int> repartitionNotes;
|
||||
final double pourcentageRecommandations;
|
||||
final List<EvaluationAideModel> evaluationsRecentes;
|
||||
final DateTime dateCalcul;
|
||||
|
||||
const StatistiquesEvaluationModel({
|
||||
required this.noteMoyenne,
|
||||
required this.nombreEvaluations,
|
||||
required this.repartitionNotes,
|
||||
required this.pourcentageRecommandations,
|
||||
required this.evaluationsRecentes,
|
||||
required this.dateCalcul,
|
||||
});
|
||||
|
||||
/// Crée un modèle à partir d'un JSON (API Response)
|
||||
factory StatistiquesEvaluationModel.fromJson(Map<String, dynamic> json) {
|
||||
return StatistiquesEvaluationModel(
|
||||
noteMoyenne: json['noteMoyenne'].toDouble(),
|
||||
nombreEvaluations: json['nombreEvaluations'] as int,
|
||||
repartitionNotes: Map<int, int>.from(json['repartitionNotes']),
|
||||
pourcentageRecommandations: json['pourcentageRecommandations'].toDouble(),
|
||||
evaluationsRecentes: (json['evaluationsRecentes'] as List<dynamic>)
|
||||
.map((e) => EvaluationAideModel.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
dateCalcul: DateTime.parse(json['dateCalcul'] as String),
|
||||
);
|
||||
}
|
||||
|
||||
/// Convertit le modèle en JSON
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'noteMoyenne': noteMoyenne,
|
||||
'nombreEvaluations': nombreEvaluations,
|
||||
'repartitionNotes': repartitionNotes,
|
||||
'pourcentageRecommandations': pourcentageRecommandations,
|
||||
'evaluationsRecentes': evaluationsRecentes
|
||||
.map((e) => e.toJson())
|
||||
.toList(),
|
||||
'dateCalcul': dateCalcul.toIso8601String(),
|
||||
};
|
||||
}
|
||||
|
||||
/// Convertit le modèle en entité du domaine
|
||||
StatistiquesEvaluation toEntity() {
|
||||
return StatistiquesEvaluation(
|
||||
noteMoyenne: noteMoyenne,
|
||||
nombreEvaluations: nombreEvaluations,
|
||||
repartitionNotes: repartitionNotes,
|
||||
pourcentageRecommandations: pourcentageRecommandations,
|
||||
evaluationsRecentes: evaluationsRecentes
|
||||
.map((e) => e.toEntity())
|
||||
.toList(),
|
||||
dateCalcul: dateCalcul,
|
||||
);
|
||||
}
|
||||
|
||||
/// Crée un modèle à partir d'une entité du domaine
|
||||
factory StatistiquesEvaluationModel.fromEntity(StatistiquesEvaluation entity) {
|
||||
return StatistiquesEvaluationModel(
|
||||
noteMoyenne: entity.noteMoyenne,
|
||||
nombreEvaluations: entity.nombreEvaluations,
|
||||
repartitionNotes: Map<int, int>.from(entity.repartitionNotes),
|
||||
pourcentageRecommandations: entity.pourcentageRecommandations,
|
||||
evaluationsRecentes: entity.evaluationsRecentes
|
||||
.map((e) => EvaluationAideModel.fromEntity(e))
|
||||
.toList(),
|
||||
dateCalcul: entity.dateCalcul,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Modèle pour les réponses de recherche d'évaluations
|
||||
class RechercheEvaluationsResponse {
|
||||
final List<EvaluationAideModel> evaluations;
|
||||
final int totalElements;
|
||||
final int totalPages;
|
||||
final int currentPage;
|
||||
final int pageSize;
|
||||
final bool hasNext;
|
||||
final bool hasPrevious;
|
||||
|
||||
const RechercheEvaluationsResponse({
|
||||
required this.evaluations,
|
||||
required this.totalElements,
|
||||
required this.totalPages,
|
||||
required this.currentPage,
|
||||
required this.pageSize,
|
||||
required this.hasNext,
|
||||
required this.hasPrevious,
|
||||
});
|
||||
|
||||
/// Crée un modèle à partir d'un JSON (API Response)
|
||||
factory RechercheEvaluationsResponse.fromJson(Map<String, dynamic> json) {
|
||||
return RechercheEvaluationsResponse(
|
||||
evaluations: (json['content'] as List<dynamic>)
|
||||
.map((e) => EvaluationAideModel.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
totalElements: json['totalElements'] as int,
|
||||
totalPages: json['totalPages'] as int,
|
||||
currentPage: json['number'] as int,
|
||||
pageSize: json['size'] as int,
|
||||
hasNext: !(json['last'] as bool),
|
||||
hasPrevious: !(json['first'] as bool),
|
||||
);
|
||||
}
|
||||
|
||||
/// Convertit le modèle en JSON
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'content': evaluations.map((e) => e.toJson()).toList(),
|
||||
'totalElements': totalElements,
|
||||
'totalPages': totalPages,
|
||||
'number': currentPage,
|
||||
'size': pageSize,
|
||||
'last': !hasNext,
|
||||
'first': !hasPrevious,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/// Modèle pour les requêtes de création d'évaluation
|
||||
class CreerEvaluationRequest {
|
||||
final String demandeId;
|
||||
final String? propositionId;
|
||||
final String evaluateurId;
|
||||
final TypeEvaluateur typeEvaluateur;
|
||||
final double noteGlobale;
|
||||
final double? noteDelaiReponse;
|
||||
final double? noteCommunication;
|
||||
final double? noteProfessionnalisme;
|
||||
final double? noteRespectEngagements;
|
||||
final String commentairePrincipal;
|
||||
final String? pointsPositifs;
|
||||
final String? pointsAmelioration;
|
||||
final String? recommandations;
|
||||
final bool? recommande;
|
||||
final bool estPublique;
|
||||
final Map<String, dynamic> donneesPersonnalisees;
|
||||
|
||||
const CreerEvaluationRequest({
|
||||
required this.demandeId,
|
||||
this.propositionId,
|
||||
required this.evaluateurId,
|
||||
required this.typeEvaluateur,
|
||||
required this.noteGlobale,
|
||||
this.noteDelaiReponse,
|
||||
this.noteCommunication,
|
||||
this.noteProfessionnalisme,
|
||||
this.noteRespectEngagements,
|
||||
required this.commentairePrincipal,
|
||||
this.pointsPositifs,
|
||||
this.pointsAmelioration,
|
||||
this.recommandations,
|
||||
this.recommande,
|
||||
this.estPublique = true,
|
||||
this.donneesPersonnalisees = const {},
|
||||
});
|
||||
|
||||
/// Convertit la requête en JSON
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'demandeId': demandeId,
|
||||
'propositionId': propositionId,
|
||||
'evaluateurId': evaluateurId,
|
||||
'typeEvaluateur': typeEvaluateur.name,
|
||||
'noteGlobale': noteGlobale,
|
||||
'noteDelaiReponse': noteDelaiReponse,
|
||||
'noteCommunication': noteCommunication,
|
||||
'noteProfessionnalisme': noteProfessionnalisme,
|
||||
'noteRespectEngagements': noteRespectEngagements,
|
||||
'commentairePrincipal': commentairePrincipal,
|
||||
'pointsPositifs': pointsPositifs,
|
||||
'pointsAmelioration': pointsAmelioration,
|
||||
'recommandations': recommandations,
|
||||
'recommande': recommande,
|
||||
'estPublique': estPublique,
|
||||
'donneesPersonnalisees': donneesPersonnalisees,
|
||||
};
|
||||
}
|
||||
|
||||
/// Crée une requête à partir d'une entité d'évaluation
|
||||
factory CreerEvaluationRequest.fromEntity(EvaluationAide entity) {
|
||||
return CreerEvaluationRequest(
|
||||
demandeId: entity.demandeId,
|
||||
propositionId: entity.propositionId,
|
||||
evaluateurId: entity.evaluateurId,
|
||||
typeEvaluateur: entity.typeEvaluateur,
|
||||
noteGlobale: entity.noteGlobale,
|
||||
noteDelaiReponse: entity.noteDelaiReponse,
|
||||
noteCommunication: entity.noteCommunication,
|
||||
noteProfessionnalisme: entity.noteProfessionnalisme,
|
||||
noteRespectEngagements: entity.noteRespectEngagements,
|
||||
commentairePrincipal: entity.commentairePrincipal,
|
||||
pointsPositifs: entity.pointsPositifs,
|
||||
pointsAmelioration: entity.pointsAmelioration,
|
||||
recommandations: entity.recommandations,
|
||||
recommande: entity.recommande,
|
||||
estPublique: entity.estPublique,
|
||||
donneesPersonnalisees: entity.donneesPersonnalisees,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,335 @@
|
||||
import '../../domain/entities/proposition_aide.dart';
|
||||
import '../../domain/entities/demande_aide.dart';
|
||||
|
||||
/// Modèle de données pour les propositions d'aide
|
||||
///
|
||||
/// Ce modèle fait la conversion entre les DTOs de l'API REST
|
||||
/// et les entités du domaine pour les propositions d'aide.
|
||||
class PropositionAideModel extends PropositionAide {
|
||||
const PropositionAideModel({
|
||||
required super.id,
|
||||
required super.titre,
|
||||
required super.description,
|
||||
required super.typeAide,
|
||||
required super.statut,
|
||||
required super.proposantId,
|
||||
required super.nomProposant,
|
||||
required super.organisationId,
|
||||
required super.nombreMaxBeneficiaires,
|
||||
super.montantMaximum,
|
||||
super.montantMinimum,
|
||||
required super.delaiReponseHeures,
|
||||
required super.dateCreation,
|
||||
required super.dateModification,
|
||||
super.dateExpiration,
|
||||
super.dateActivation,
|
||||
super.dateDesactivation,
|
||||
required super.contactProposant,
|
||||
super.zonesGeographiques,
|
||||
super.creneauxDisponibilite,
|
||||
super.criteresSelection,
|
||||
super.conditionsSpeciales,
|
||||
super.nombreBeneficiairesAides,
|
||||
super.nombreVues,
|
||||
super.nombreCandidatures,
|
||||
super.noteMoyenne,
|
||||
super.nombreEvaluations,
|
||||
super.donneesPersonnalisees,
|
||||
super.estVerifiee,
|
||||
super.estPromue,
|
||||
});
|
||||
|
||||
/// Crée un modèle à partir d'un JSON (API Response)
|
||||
factory PropositionAideModel.fromJson(Map<String, dynamic> json) {
|
||||
return PropositionAideModel(
|
||||
id: json['id'] as String,
|
||||
titre: json['titre'] as String,
|
||||
description: json['description'] as String,
|
||||
typeAide: _parseTypeAide(json['typeAide'] as String),
|
||||
statut: _parseStatutProposition(json['statut'] as String),
|
||||
proposantId: json['proposantId'] as String,
|
||||
nomProposant: json['nomProposant'] as String,
|
||||
organisationId: json['organisationId'] as String,
|
||||
nombreMaxBeneficiaires: json['nombreMaxBeneficiaires'] as int,
|
||||
montantMaximum: json['montantMaximum']?.toDouble(),
|
||||
montantMinimum: json['montantMinimum']?.toDouble(),
|
||||
delaiReponseHeures: json['delaiReponseHeures'] as int,
|
||||
dateCreation: DateTime.parse(json['dateCreation'] as String),
|
||||
dateModification: DateTime.parse(json['dateModification'] as String),
|
||||
dateExpiration: json['dateExpiration'] != null
|
||||
? DateTime.parse(json['dateExpiration'] as String)
|
||||
: null,
|
||||
dateActivation: json['dateActivation'] != null
|
||||
? DateTime.parse(json['dateActivation'] as String)
|
||||
: null,
|
||||
dateDesactivation: json['dateDesactivation'] != null
|
||||
? DateTime.parse(json['dateDesactivation'] as String)
|
||||
: null,
|
||||
contactProposant: ContactProposantModel.fromJson(
|
||||
json['contactProposant'] as Map<String, dynamic>
|
||||
),
|
||||
zonesGeographiques: (json['zonesGeographiques'] as List<dynamic>?)
|
||||
?.cast<String>() ?? [],
|
||||
creneauxDisponibilite: (json['creneauxDisponibilite'] as List<dynamic>?)
|
||||
?.map((e) => CreneauDisponibiliteModel.fromJson(e as Map<String, dynamic>))
|
||||
.toList() ?? [],
|
||||
criteresSelection: (json['criteresSelection'] as List<dynamic>?)
|
||||
?.map((e) => CritereSelectionModel.fromJson(e as Map<String, dynamic>))
|
||||
.toList() ?? [],
|
||||
conditionsSpeciales: (json['conditionsSpeciales'] as List<dynamic>?)
|
||||
?.cast<String>() ?? [],
|
||||
nombreBeneficiairesAides: json['nombreBeneficiairesAides'] as int? ?? 0,
|
||||
nombreVues: json['nombreVues'] as int? ?? 0,
|
||||
nombreCandidatures: json['nombreCandidatures'] as int? ?? 0,
|
||||
noteMoyenne: json['noteMoyenne']?.toDouble(),
|
||||
nombreEvaluations: json['nombreEvaluations'] as int? ?? 0,
|
||||
donneesPersonnalisees: Map<String, dynamic>.from(json['donneesPersonnalisees'] ?? {}),
|
||||
estVerifiee: json['estVerifiee'] as bool? ?? false,
|
||||
estPromue: json['estPromue'] as bool? ?? false,
|
||||
);
|
||||
}
|
||||
|
||||
/// Convertit le modèle en JSON (API Request)
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'id': id,
|
||||
'titre': titre,
|
||||
'description': description,
|
||||
'typeAide': typeAide.name,
|
||||
'statut': statut.name,
|
||||
'proposantId': proposantId,
|
||||
'nomProposant': nomProposant,
|
||||
'organisationId': organisationId,
|
||||
'nombreMaxBeneficiaires': nombreMaxBeneficiaires,
|
||||
'montantMaximum': montantMaximum,
|
||||
'montantMinimum': montantMinimum,
|
||||
'delaiReponseHeures': delaiReponseHeures,
|
||||
'dateCreation': dateCreation.toIso8601String(),
|
||||
'dateModification': dateModification.toIso8601String(),
|
||||
'dateExpiration': dateExpiration?.toIso8601String(),
|
||||
'dateActivation': dateActivation?.toIso8601String(),
|
||||
'dateDesactivation': dateDesactivation?.toIso8601String(),
|
||||
'contactProposant': (contactProposant as ContactProposantModel).toJson(),
|
||||
'zonesGeographiques': zonesGeographiques,
|
||||
'creneauxDisponibilite': creneauxDisponibilite
|
||||
.map((e) => (e as CreneauDisponibiliteModel).toJson())
|
||||
.toList(),
|
||||
'criteresSelection': criteresSelection
|
||||
.map((e) => (e as CritereSelectionModel).toJson())
|
||||
.toList(),
|
||||
'conditionsSpeciales': conditionsSpeciales,
|
||||
'nombreBeneficiairesAides': nombreBeneficiairesAides,
|
||||
'nombreVues': nombreVues,
|
||||
'nombreCandidatures': nombreCandidatures,
|
||||
'noteMoyenne': noteMoyenne,
|
||||
'nombreEvaluations': nombreEvaluations,
|
||||
'donneesPersonnalisees': donneesPersonnalisees,
|
||||
'estVerifiee': estVerifiee,
|
||||
'estPromue': estPromue,
|
||||
};
|
||||
}
|
||||
|
||||
/// Crée un modèle à partir d'une entité du domaine
|
||||
factory PropositionAideModel.fromEntity(PropositionAide entity) {
|
||||
return PropositionAideModel(
|
||||
id: entity.id,
|
||||
titre: entity.titre,
|
||||
description: entity.description,
|
||||
typeAide: entity.typeAide,
|
||||
statut: entity.statut,
|
||||
proposantId: entity.proposantId,
|
||||
nomProposant: entity.nomProposant,
|
||||
organisationId: entity.organisationId,
|
||||
nombreMaxBeneficiaires: entity.nombreMaxBeneficiaires,
|
||||
montantMaximum: entity.montantMaximum,
|
||||
montantMinimum: entity.montantMinimum,
|
||||
delaiReponseHeures: entity.delaiReponseHeures,
|
||||
dateCreation: entity.dateCreation,
|
||||
dateModification: entity.dateModification,
|
||||
dateExpiration: entity.dateExpiration,
|
||||
dateActivation: entity.dateActivation,
|
||||
dateDesactivation: entity.dateDesactivation,
|
||||
contactProposant: ContactProposantModel.fromEntity(entity.contactProposant),
|
||||
zonesGeographiques: List<String>.from(entity.zonesGeographiques),
|
||||
creneauxDisponibilite: entity.creneauxDisponibilite
|
||||
.map((e) => CreneauDisponibiliteModel.fromEntity(e))
|
||||
.toList(),
|
||||
criteresSelection: entity.criteresSelection
|
||||
.map((e) => CritereSelectionModel.fromEntity(e))
|
||||
.toList(),
|
||||
conditionsSpeciales: List<String>.from(entity.conditionsSpeciales),
|
||||
nombreBeneficiairesAides: entity.nombreBeneficiairesAides,
|
||||
nombreVues: entity.nombreVues,
|
||||
nombreCandidatures: entity.nombreCandidatures,
|
||||
noteMoyenne: entity.noteMoyenne,
|
||||
nombreEvaluations: entity.nombreEvaluations,
|
||||
donneesPersonnalisees: Map<String, dynamic>.from(entity.donneesPersonnalisees),
|
||||
estVerifiee: entity.estVerifiee,
|
||||
estPromue: entity.estPromue,
|
||||
);
|
||||
}
|
||||
|
||||
/// Convertit le modèle en entité du domaine
|
||||
PropositionAide toEntity() {
|
||||
return PropositionAide(
|
||||
id: id,
|
||||
titre: titre,
|
||||
description: description,
|
||||
typeAide: typeAide,
|
||||
statut: statut,
|
||||
proposantId: proposantId,
|
||||
nomProposant: nomProposant,
|
||||
organisationId: organisationId,
|
||||
nombreMaxBeneficiaires: nombreMaxBeneficiaires,
|
||||
montantMaximum: montantMaximum,
|
||||
montantMinimum: montantMinimum,
|
||||
delaiReponseHeures: delaiReponseHeures,
|
||||
dateCreation: dateCreation,
|
||||
dateModification: dateModification,
|
||||
dateExpiration: dateExpiration,
|
||||
dateActivation: dateActivation,
|
||||
dateDesactivation: dateDesactivation,
|
||||
contactProposant: contactProposant,
|
||||
zonesGeographiques: zonesGeographiques,
|
||||
creneauxDisponibilite: creneauxDisponibilite,
|
||||
criteresSelection: criteresSelection,
|
||||
conditionsSpeciales: conditionsSpeciales,
|
||||
nombreBeneficiairesAides: nombreBeneficiairesAides,
|
||||
nombreVues: nombreVues,
|
||||
nombreCandidatures: nombreCandidatures,
|
||||
noteMoyenne: noteMoyenne,
|
||||
nombreEvaluations: nombreEvaluations,
|
||||
donneesPersonnalisees: donneesPersonnalisees,
|
||||
estVerifiee: estVerifiee,
|
||||
estPromue: estPromue,
|
||||
);
|
||||
}
|
||||
|
||||
// Méthodes utilitaires de parsing
|
||||
static TypeAide _parseTypeAide(String value) {
|
||||
return TypeAide.values.firstWhere(
|
||||
(e) => e.name == value,
|
||||
orElse: () => TypeAide.autre,
|
||||
);
|
||||
}
|
||||
|
||||
static StatutProposition _parseStatutProposition(String value) {
|
||||
return StatutProposition.values.firstWhere(
|
||||
(e) => e.name == value,
|
||||
orElse: () => StatutProposition.brouillon,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Modèles pour les classes auxiliaires
|
||||
class ContactProposantModel extends ContactProposant {
|
||||
const ContactProposantModel({
|
||||
required super.nom,
|
||||
required super.telephone,
|
||||
super.email,
|
||||
super.adresse,
|
||||
super.heuresDisponibilite,
|
||||
});
|
||||
|
||||
factory ContactProposantModel.fromJson(Map<String, dynamic> json) {
|
||||
return ContactProposantModel(
|
||||
nom: json['nom'] as String,
|
||||
telephone: json['telephone'] as String,
|
||||
email: json['email'] as String?,
|
||||
adresse: json['adresse'] as String?,
|
||||
heuresDisponibilite: json['heuresDisponibilite'] as String?,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'nom': nom,
|
||||
'telephone': telephone,
|
||||
'email': email,
|
||||
'adresse': adresse,
|
||||
'heuresDisponibilite': heuresDisponibilite,
|
||||
};
|
||||
}
|
||||
|
||||
factory ContactProposantModel.fromEntity(ContactProposant entity) {
|
||||
return ContactProposantModel(
|
||||
nom: entity.nom,
|
||||
telephone: entity.telephone,
|
||||
email: entity.email,
|
||||
adresse: entity.adresse,
|
||||
heuresDisponibilite: entity.heuresDisponibilite,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class CreneauDisponibiliteModel extends CreneauDisponibilite {
|
||||
const CreneauDisponibiliteModel({
|
||||
required super.jourSemaine,
|
||||
required super.heureDebut,
|
||||
required super.heureFin,
|
||||
super.commentaire,
|
||||
});
|
||||
|
||||
factory CreneauDisponibiliteModel.fromJson(Map<String, dynamic> json) {
|
||||
return CreneauDisponibiliteModel(
|
||||
jourSemaine: json['jourSemaine'] as String,
|
||||
heureDebut: json['heureDebut'] as String,
|
||||
heureFin: json['heureFin'] as String,
|
||||
commentaire: json['commentaire'] as String?,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'jourSemaine': jourSemaine,
|
||||
'heureDebut': heureDebut,
|
||||
'heureFin': heureFin,
|
||||
'commentaire': commentaire,
|
||||
};
|
||||
}
|
||||
|
||||
factory CreneauDisponibiliteModel.fromEntity(CreneauDisponibilite entity) {
|
||||
return CreneauDisponibiliteModel(
|
||||
jourSemaine: entity.jourSemaine,
|
||||
heureDebut: entity.heureDebut,
|
||||
heureFin: entity.heureFin,
|
||||
commentaire: entity.commentaire,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class CritereSelectionModel extends CritereSelection {
|
||||
const CritereSelectionModel({
|
||||
required super.nom,
|
||||
required super.description,
|
||||
required super.obligatoire,
|
||||
super.valeurAttendue,
|
||||
});
|
||||
|
||||
factory CritereSelectionModel.fromJson(Map<String, dynamic> json) {
|
||||
return CritereSelectionModel(
|
||||
nom: json['nom'] as String,
|
||||
description: json['description'] as String,
|
||||
obligatoire: json['obligatoire'] as bool,
|
||||
valeurAttendue: json['valeurAttendue'] as String?,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'nom': nom,
|
||||
'description': description,
|
||||
'obligatoire': obligatoire,
|
||||
'valeurAttendue': valeurAttendue,
|
||||
};
|
||||
}
|
||||
|
||||
factory CritereSelectionModel.fromEntity(CritereSelection entity) {
|
||||
return CritereSelectionModel(
|
||||
nom: entity.nom,
|
||||
description: entity.description,
|
||||
obligatoire: entity.obligatoire,
|
||||
valeurAttendue: entity.valeurAttendue,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user