github.com/benoitkugler/goacve@v0.0.0-20201217100549-151ce6e55dc8/server/core/rawdata/inscriptions.go (about) 1 package rawdata 2 3 const ( 4 IDateHeure Field = iota 5 IResponsable 6 INbParticipants 7 ) 8 9 type ResponsableLegal struct { 10 Lienid IdentificationId `json:"lienid,omitempty"` 11 Nom String `json:"nom,omitempty"` 12 Prenom String `json:"prenom,omitempty"` 13 Sexe Sexe `json:"sexe,omitempty"` 14 Mail String `json:"mail,omitempty"` 15 Adresse String `json:"adresse,omitempty"` 16 CodePostal String `json:"code_postal,omitempty"` 17 Ville String `json:"ville,omitempty"` 18 Tels Tels `json:"tels,omitempty"` 19 DateNaissance Date `json:"date_naissance,omitempty"` 20 Pays String `json:"pays,omitempty"` 21 } 22 23 type ParticipantInscription struct { 24 Lienid IdentificationId `json:"lienid"` 25 Nom String `json:"nom"` 26 Prenom String `json:"prenom"` 27 DateNaissance Date `json:"date_naissance"` 28 Sexe Sexe `json:"sexe"` 29 IdCamp int64 `json:"id_camp"` 30 Options OptionsParticipant `json:"options"` 31 OptionsPrix OptionPrixParticipant `json:"options_prix"` 32 } 33 34 type ParticipantInscriptions []ParticipantInscription 35 36 func (r ResponsableLegal) ToPersonne() Personne { 37 return Personne{BasePersonne: BasePersonne{ 38 Nom: r.Nom, 39 Prenom: r.Prenom, 40 Sexe: r.Sexe, 41 Mail: r.Mail, 42 Adresse: r.Adresse, 43 CodePostal: r.CodePostal, 44 Ville: r.Ville, 45 Tels: r.Tels, 46 DateNaissance: r.DateNaissance, 47 Pays: r.Pays, 48 }} 49 } 50 51 // ToInscription renvoie les champs de la personne 52 // vus comme le responsable d'une inscription 53 func (r Personne) ToInscription() ResponsableLegal { 54 return ResponsableLegal{ 55 Nom: r.Nom, 56 Prenom: r.Prenom, 57 Sexe: r.Sexe, 58 Mail: r.Mail, 59 Adresse: r.Adresse, 60 CodePostal: r.CodePostal, 61 Ville: r.Ville, 62 Tels: r.Tels, 63 DateNaissance: r.DateNaissance, 64 Pays: r.Pays, 65 } 66 } 67 68 func (r ParticipantInscription) ToPersonne() Personne { 69 return Personne{BasePersonne: BasePersonne{ 70 Nom: r.Nom, 71 Prenom: r.Prenom, 72 Sexe: r.Sexe, 73 DateNaissance: r.DateNaissance, 74 }} 75 } 76 77 // ToParticipantInscription renvoie la personne comme un 78 // participant d'une inscription 79 func (r Personne) ToParticipantInscription() ParticipantInscription { 80 return ParticipantInscription{ 81 Nom: r.Nom, 82 Prenom: r.Prenom, 83 Sexe: r.Sexe, 84 DateNaissance: r.DateNaissance, 85 } 86 } 87 88 func (r Inscription) AsItem() Item { 89 fields := F{IDateHeure: r.DateHeure, IResponsable: r.Responsable.ToPersonne().NomPrenom(), INbParticipants: Int(len(r.Participants))} 90 return Item{Id: Id(r.Id), Fields: fields} 91 }