vote

package
v0.0.0-...-151ce6e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 17, 2020 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const EndpointVote = "/vote"

Variables

This section is empty.

Functions

func InsertManyVotePersonneCandidats

func InsertManyVotePersonneCandidats(tx DB, items ...VotePersonneCandidat) error

Insert the links VotePersonneCandidat in the database.

func InsertManyVotePersonnes

func InsertManyVotePersonnes(tx DB, items ...VotePersonne) error

Insert the links VotePersonne in the database.

func PageAdmin

func PageAdmin(c echo.Context) error

Types

type Candidat

type Candidat struct {
	Id     int64  `json:"id"`
	IdVote int64  `json:"id_vote"`
	Label  string `json:"label"`
}

sql:ADD UNIQUE(id, id_vote)

func ScanCandidat

func ScanCandidat(row *sql.Row) (Candidat, error)

func SelectCandidat

func SelectCandidat(tx DB, id int64) (Candidat, error)

SelectCandidat returns the entry matching id.

func (Candidat) Delete

func (item Candidat) Delete(tx DB) (Candidat, error)

Deletes Candidat in the database and returns the item. Only the field 'Id' is used.

func (Candidat) Insert

func (item Candidat) Insert(tx DB) (out Candidat, err error)

Insert Candidat in the database and returns the item with id filled.

func (Candidat) Update

func (item Candidat) Update(tx DB) (out Candidat, err error)

Update Candidat in the database and returns the new version.

type Candidats

type Candidats map[int64]Candidat

func ScanCandidats

func ScanCandidats(rs *sql.Rows) (Candidats, error)

func SelectAllCandidats

func SelectAllCandidats(tx DB) (Candidats, error)

func (Candidats) Ids

func (m Candidats) Ids() Ids

type Controller

type Controller struct {
	// contains filtered or unexported fields
}

func NewController

func NewController(db *sql.DB, smtp logs.SMTP, rootPath string) (Controller, error)

func (Controller) ClearVote

func (ct Controller) ClearVote(c echo.Context) error

ClearVote supprime les voix exprimées sur le vote donné.

func (Controller) CreateVote

func (ct Controller) CreateVote(c echo.Context) error

func (Controller) DeleteVote

func (ct Controller) DeleteVote(c echo.Context) error

func (Controller) EffectueVote

func (ct Controller) EffectueVote(c echo.Context) error

func (Controller) ExportBilanPersonne

func (ct Controller) ExportBilanPersonne(c echo.Context) error

func (Controller) ExportBilanVotes

func (ct Controller) ExportBilanVotes(c echo.Context) error

func (Controller) GetMembres

func (ct Controller) GetMembres(c echo.Context) error

func (Controller) GetVotes

func (ct Controller) GetVotes(c echo.Context) error

func (Controller) InviteAll

func (ct Controller) InviteAll(c echo.Context) error

func (Controller) InviteOne

func (ct Controller) InviteOne(c echo.Context) error

func (Controller) LoadVotes

func (ct Controller) LoadVotes(c echo.Context) error

func (Controller) LockVote

func (ct Controller) LockVote(c echo.Context) error

func (Controller) PageVote

func (ct Controller) PageVote(c echo.Context) error

func (Controller) ResetVote

func (ct Controller) ResetVote(c echo.Context) error

ResetVote supprime un éventuel vote actuel (aucune trace n'est gardée)

func (Controller) UpdateVote

func (ct Controller) UpdateVote(c echo.Context) error

type DB

type DB interface {
	Exec(query string, args ...interface{}) (sql.Result, error)
	Query(query string, args ...interface{}) (*sql.Rows, error)
	QueryRow(query string, args ...interface{}) *sql.Row
	Prepare(query string) (*sql.Stmt, error)
}

DB groups transaction like objects

type Ids

type Ids []int64

type LockVote

type LockVote struct {
	IdVote   int64 `json:"id_vote,omitempty"`
	IsLocked bool  `json:"is_locked,omitempty"`
}

type Membre

type Membre struct {
	NomPrenom     string        `json:"nom_prenom"`
	Mail          rd.String     `json:"mail"`
	Lien          string        `json:"lien"`
	Participation Participation `json:"participation"`
}

type MetaPersonne

type MetaPersonne struct {
	PrenomNom string `json:"prenom_nom,omitempty"`
}

type Participation

type Participation struct {
	Total   int       `json:"total"`
	Actuels int       `json:"actuels"`
	Last    time.Time `json:"last"`
}

type Vote

type Vote struct {
	Id          int64  `json:"id,omitempty"`
	Nom         string `json:"nom,omitempty"`
	Description string `json:"description,omitempty"`
	IsQCM       bool   `json:"is_qcm,omitempty"`
	IsLocked    bool   `json:"is_locked,omitempty"`
}

Vote QCM

func ScanVote

func ScanVote(row *sql.Row) (Vote, error)

func SelectVote

func SelectVote(tx DB, id int64) (Vote, error)

SelectVote returns the entry matching id.

func (Vote) Delete

func (item Vote) Delete(tx DB) (Vote, error)

Deletes Vote in the database and returns the item. Only the field 'Id' is used.

func (Vote) Insert

func (item Vote) Insert(tx DB) (out Vote, err error)

Insert Vote in the database and returns the item with id filled.

func (Vote) Update

func (item Vote) Update(tx DB) (out Vote, err error)

Update Vote in the database and returns the new version.

type VoteAdmin

type VoteAdmin struct {
	VoteCandidats

	Participation int           `json:"participation"` // nombre de vote effectués
	Voix          map[int64]int `json:"voix"`          // id candidat -> suffrages
}

type VoteCandidats

type VoteCandidats struct {
	Vote

	Candidats []Candidat `json:"candidats"`
}

type VotePersonne

type VotePersonne struct {
	IdVote     int64     `json:"id_vote"`
	IdPersonne int64     `json:"id_personne"`
	Time       time.Time `json:"time"`
}

VotePersonne enregistre une action de vote pour une personne. Cette table est nécessaire pour distinguer un vote ne choisissant aucun candidat d'une absence de vote sql:ADD UNIQUE(id_personne, id_vote)

func ScanVotePersonne

func ScanVotePersonne(row *sql.Row) (VotePersonne, error)

func (VotePersonne) Delete

func (item VotePersonne) Delete(tx DB) error

Delete the link VotePersonne in the database. Only the 'IdVote' 'IdPersonne' fields are used.

type VotePersonneCandidat

type VotePersonneCandidat struct {
	IdVote     int64 `json:"id_vote"`
	IdPersonne int64 `json:"id_personne"`
	IdCandidat int64 `json:"id_candidat"`
}

sql:ADD FOREIGN KEY(id_vote, id_personne) REFERENCES vote_personnes(id_vote, id_personne) sql:ADD FOREIGN KEY(id_vote, id_candidat) REFERENCES candidats(id_vote, id) sql:ADD UNIQUE(id_vote, id_personne, id_candidat)

func ScanVotePersonneCandidat

func ScanVotePersonneCandidat(row *sql.Row) (VotePersonneCandidat, error)

func (VotePersonneCandidat) Delete

func (item VotePersonneCandidat) Delete(tx DB) error

Delete the link VotePersonneCandidat in the database. Only the 'IdVote' 'IdPersonne' 'IdCandidat' fields are used.

type VotePersonneCandidats

type VotePersonneCandidats []VotePersonneCandidat

func ScanVotePersonneCandidats

func ScanVotePersonneCandidats(rs *sql.Rows) (VotePersonneCandidats, error)

func SelectAllVotePersonneCandidats

func SelectAllVotePersonneCandidats(tx DB) (VotePersonneCandidats, error)

func SelectVotePersonneCandidatByIdCandidat

func SelectVotePersonneCandidatByIdCandidat(tx DB, idCandidats ...int64) (VotePersonneCandidats, error)

func SelectVotePersonneCandidatByIdPersonne

func SelectVotePersonneCandidatByIdPersonne(tx DB, idPersonnes ...int64) (VotePersonneCandidats, error)

func SelectVotePersonneCandidatByIdVote

func SelectVotePersonneCandidatByIdVote(tx DB, idVotes ...int64) (VotePersonneCandidats, error)

func (VotePersonneCandidats) ByIdCandidat

func (items VotePersonneCandidats) ByIdCandidat() map[int64]VotePersonneCandidat

ByIdCandidat returns a map with 'IdCandidat' as keys. Collision may happen without uniqueness constraint.

func (VotePersonneCandidats) ByIdPersonne

func (items VotePersonneCandidats) ByIdPersonne() map[int64]VotePersonneCandidat

ByIdPersonne returns a map with 'IdPersonne' as keys. Collision may happen without uniqueness constraint.

func (VotePersonneCandidats) ByIdVote

func (items VotePersonneCandidats) ByIdVote() map[int64]VotePersonneCandidat

ByIdVote returns a map with 'IdVote' as keys. Collision may happen without uniqueness constraint.

type VotePersonneComplet

type VotePersonneComplet struct {
	VoteCandidats

	Time  time.Time `json:"time"`  // zero pour aucun note
	Choix Ids       `json:"choix"` // candidats choisis
}

VotePersonneComplet résume les choix possibles et les choix actuels

type VotePersonnes

type VotePersonnes []VotePersonne

func ScanVotePersonnes

func ScanVotePersonnes(rs *sql.Rows) (VotePersonnes, error)

func SelectAllVotePersonnes

func SelectAllVotePersonnes(tx DB) (VotePersonnes, error)

func SelectVotePersonneByIdPersonne

func SelectVotePersonneByIdPersonne(tx DB, idPersonnes ...int64) (VotePersonnes, error)

func SelectVotePersonneByIdVote

func SelectVotePersonneByIdVote(tx DB, idVotes ...int64) (VotePersonnes, error)

func (VotePersonnes) ByIdPersonne

func (items VotePersonnes) ByIdPersonne() map[int64]VotePersonne

ByIdPersonne returns a map with 'IdPersonne' as keys. Collision may happen without uniqueness constraint.

func (VotePersonnes) ByIdVote

func (items VotePersonnes) ByIdVote() map[int64]VotePersonne

ByIdVote returns a map with 'IdVote' as keys. Collision may happen without uniqueness constraint.

type Votes

type Votes map[int64]Vote

func ScanVotes

func ScanVotes(rs *sql.Rows) (Votes, error)

func SelectAllVotes

func SelectAllVotes(tx DB) (Votes, error)

func (Votes) Ids

func (m Votes) Ids() Ids

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL