github.com/benoitkugler/goacve@v0.0.0-20201217100549-151ce6e55dc8/server/vote/models.go (about) 1 package vote 2 3 import "time" 4 5 // Vote QCM 6 type Vote struct { 7 Id int64 `json:"id,omitempty"` 8 Nom string `json:"nom,omitempty"` 9 Description string `json:"description,omitempty"` 10 IsQCM bool `json:"is_qcm,omitempty"` 11 IsLocked bool `json:"is_locked,omitempty"` 12 } 13 14 // sql:ADD UNIQUE(id, id_vote) 15 type Candidat struct { 16 Id int64 `json:"id"` 17 IdVote int64 `json:"id_vote"` 18 Label string `json:"label"` 19 } 20 21 // VotePersonne enregistre une action de vote pour 22 // une personne. 23 // Cette table est nécessaire pour distinguer 24 // un vote ne choisissant aucun candidat d'une absence de vote 25 // sql:ADD UNIQUE(id_personne, id_vote) 26 type VotePersonne struct { 27 IdVote int64 `json:"id_vote"` 28 IdPersonne int64 `json:"id_personne"` 29 Time time.Time `json:"time"` 30 } 31 32 // sql:ADD FOREIGN KEY(id_vote, id_personne) REFERENCES vote_personnes(id_vote, id_personne) 33 // sql:ADD FOREIGN KEY(id_vote, id_candidat) REFERENCES candidats(id_vote, id) 34 // sql:ADD UNIQUE(id_vote, id_personne, id_candidat) 35 type VotePersonneCandidat struct { 36 IdVote int64 `json:"id_vote"` 37 IdPersonne int64 `json:"id_personne"` 38 IdCandidat int64 `json:"id_candidat"` 39 } 40 41 type Ids []int64