models

package
v0.0.0-...-71e74fa Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Définit la structure de la base de données.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConnectDB

func ConnectDB(credences logs.SQL) (*sql.DB, error)

func InsertManyCommandeProduits

func InsertManyCommandeProduits(tx *sql.Tx, items ...CommandeProduit) error

Insert the links CommandeProduit in the database.

func InsertManyDefautProduits

func InsertManyDefautProduits(tx *sql.Tx, items ...DefautProduit) error

Insert the links DefautProduit in the database.

func InsertManyIngredientProduits

func InsertManyIngredientProduits(tx *sql.Tx, items ...IngredientProduit) error

Insert the links IngredientProduit in the database.

func InsertManyLienIngredients

func InsertManyLienIngredients(tx *sql.Tx, items ...LienIngredient) error

Insert the links LienIngredient in the database.

func InsertManyMenuIngredients

func InsertManyMenuIngredients(tx *sql.Tx, items ...MenuIngredient) error

Insert the links MenuIngredient in the database.

func InsertManyMenuRecettes

func InsertManyMenuRecettes(tx *sql.Tx, items ...MenuRecette) error

Insert the links MenuRecette in the database.

func InsertManyRecetteIngredients

func InsertManyRecetteIngredients(tx *sql.Tx, items ...RecetteIngredient) error

Insert the links RecetteIngredient in the database.

func InsertManyRepasGroupes

func InsertManyRepasGroupes(tx *sql.Tx, items ...RepasGroupe) error

Insert the links RepasGroupe in the database.

func InsertManyRepasIngredients

func InsertManyRepasIngredients(tx *sql.Tx, items ...RepasIngredient) error

Insert the links RepasIngredient in the database.

func InsertManyRepasRecettes

func InsertManyRepasRecettes(tx *sql.Tx, items ...RepasRecette) error

Insert the links RepasRecette in the database.

func InsertManySejourFournisseurs

func InsertManySejourFournisseurs(tx *sql.Tx, items ...SejourFournisseur) error

Insert the links SejourFournisseur in the database.

func InsertManyUtilisateurFournisseurs

func InsertManyUtilisateurFournisseurs(tx *sql.Tx, items ...UtilisateurFournisseur) error

Insert the links UtilisateurFournisseur in the database.

func NullableId

func NullableId(id int64) sql.NullInt64

------------------- Helpers --------------------------------

func ScanIds

func ScanIds(rs *sql.Rows) ([]int64, error)

Types

type Callories

type Callories struct{}

func (*Callories) Scan

func (s *Callories) Scan(src interface{}) error

func (Callories) Value

func (s Callories) Value() (driver.Value, error)

type Categorie

type Categorie string

Categorie permet de classer les ingrédients

type Commande

type Commande struct {
	Id            int64     `json:"id"`
	IdUtilisateur int64     `json:"id_utilisateur"`
	DateEmission  time.Time `json:"date_emission"`
	Tag           string    `json:"tag"`
}

func DeleteCommandeById

func DeleteCommandeById(tx DB, id int64) (Commande, error)

Deletes the Commande and returns the item

func ScanCommande

func ScanCommande(row *sql.Row) (Commande, error)

func SelectCommande

func SelectCommande(tx DB, id int64) (Commande, error)

SelectCommande returns the entry matching id.

func (Commande) Insert

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

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

func (Commande) Update

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

Update Commande in the database and returns the new version.

type CommandeProduit

type CommandeProduit struct {
	IdCommande int64 `json:"id_commande"`
	IdProduit  int64 `json:"id_produit"`
	Quantite   int64 `json:"quantite"`
}

sql: ADD UNIQUE(id_commande, id_produit)

func ScanCommandeProduit

func ScanCommandeProduit(row *sql.Row) (CommandeProduit, error)

func (CommandeProduit) Delete

func (item CommandeProduit) Delete(tx DB) error

Delete the link CommandeProduit in the database. Only the 'IdCommande' 'IdProduit' fields are used.

type CommandeProduits

type CommandeProduits []CommandeProduit

func DeleteCommandeProduitsByIdCommandes

func DeleteCommandeProduitsByIdCommandes(tx DB, idCommandes ...int64) (CommandeProduits, error)

func DeleteCommandeProduitsByIdProduits

func DeleteCommandeProduitsByIdProduits(tx DB, idProduits ...int64) (CommandeProduits, error)

func ScanCommandeProduits

func ScanCommandeProduits(rs *sql.Rows) (CommandeProduits, error)

func SelectAllCommandeProduits

func SelectAllCommandeProduits(tx DB) (CommandeProduits, error)

func SelectCommandeProduitsByIdCommandes

func SelectCommandeProduitsByIdCommandes(tx DB, idCommandes ...int64) (CommandeProduits, error)

func SelectCommandeProduitsByIdProduits

func SelectCommandeProduitsByIdProduits(tx DB, idProduits ...int64) (CommandeProduits, error)

func (CommandeProduits) ByIdCommande

func (items CommandeProduits) ByIdCommande() map[int64]CommandeProduits

ByIdCommande returns a map with 'IdCommande' as keys.

func (CommandeProduits) ByIdProduit

func (items CommandeProduits) ByIdProduit() map[int64]CommandeProduits

ByIdProduit returns a map with 'IdProduit' as keys.

type Commandes

type Commandes map[int64]Commande

func ScanCommandes

func ScanCommandes(rs *sql.Rows) (Commandes, error)

func SelectAllCommandes

func SelectAllCommandes(tx DB) (Commandes, error)

func SelectCommandes

func SelectCommandes(tx DB, ids ...int64) (Commandes, error)

SelectCommandes returns the entry matching the given ids.

func SelectCommandesByIdUtilisateurs

func SelectCommandesByIdUtilisateurs(tx DB, idUtilisateurs ...int64) (Commandes, error)

func (Commandes) Ids

func (m Commandes) Ids() Ids

type Conditionnement

type Conditionnement struct {
	Quantite float64 `json:"quantite"`
	Unite    Unite   `json:"unite"`
}

func (Conditionnement) IsNull

func (c Conditionnement) IsNull() bool

func (*Conditionnement) Scan

func (s *Conditionnement) Scan(src interface{}) error

func (Conditionnement) String

func (c Conditionnement) String() string

func (Conditionnement) Value

func (s Conditionnement) Value() (driver.Value, 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 DefautProduit

type DefautProduit struct {
	IdUtilisateur int64 `json:"id_utilisateur"`
	IdIngredient  int64 `json:"id_ingredient"`
	IdFournisseur int64 `json:"id_fournisseur"`
	IdProduit     int64 `json:"id_produit" sql_on_delete:"CASCADE"`
}

sql: ADD UNIQUE(id_utilisateur, id_ingredient, id_fournisseur) sql: ADD FOREIGN KEY (id_utilisateur, id_fournisseur) REFERENCES utilisateur_fournisseurs (id_utilisateur, id_fournisseur) sql: ADD FOREIGN KEY (id_ingredient, id_produit) REFERENCES ingredient_produits (id_ingredient, id_produit)

func ScanDefautProduit

func ScanDefautProduit(row *sql.Row) (DefautProduit, error)

func (DefautProduit) Delete

func (item DefautProduit) Delete(tx DB) error

Delete the link DefautProduit in the database. Only the 'IdUtilisateur' 'IdIngredient' 'IdFournisseur' 'IdProduit' fields are used.

type DefautProduits

type DefautProduits []DefautProduit

func DeleteDefautProduitsByIdFournisseurs

func DeleteDefautProduitsByIdFournisseurs(tx DB, idFournisseurs ...int64) (DefautProduits, error)

func DeleteDefautProduitsByIdIngredients

func DeleteDefautProduitsByIdIngredients(tx DB, idIngredients ...int64) (DefautProduits, error)

func DeleteDefautProduitsByIdProduits

func DeleteDefautProduitsByIdProduits(tx DB, idProduits ...int64) (DefautProduits, error)

func DeleteDefautProduitsByIdUtilisateurs

func DeleteDefautProduitsByIdUtilisateurs(tx DB, idUtilisateurs ...int64) (DefautProduits, error)

func ScanDefautProduits

func ScanDefautProduits(rs *sql.Rows) (DefautProduits, error)

func SelectAllDefautProduits

func SelectAllDefautProduits(tx DB) (DefautProduits, error)

func SelectDefautProduitsByIdFournisseurs

func SelectDefautProduitsByIdFournisseurs(tx DB, idFournisseurs ...int64) (DefautProduits, error)

func SelectDefautProduitsByIdIngredients

func SelectDefautProduitsByIdIngredients(tx DB, idIngredients ...int64) (DefautProduits, error)

func SelectDefautProduitsByIdProduits

func SelectDefautProduitsByIdProduits(tx DB, idProduits ...int64) (DefautProduits, error)

func SelectDefautProduitsByIdUtilisateurs

func SelectDefautProduitsByIdUtilisateurs(tx DB, idUtilisateurs ...int64) (DefautProduits, error)

func (DefautProduits) ByIdFournisseur

func (items DefautProduits) ByIdFournisseur() map[int64]DefautProduits

ByIdFournisseur returns a map with 'IdFournisseur' as keys.

func (DefautProduits) ByIdIngredient

func (items DefautProduits) ByIdIngredient() map[int64]DefautProduits

ByIdIngredient returns a map with 'IdIngredient' as keys.

func (DefautProduits) ByIdProduit

func (items DefautProduits) ByIdProduit() map[int64]DefautProduits

ByIdProduit returns a map with 'IdProduit' as keys.

func (DefautProduits) ByIdUtilisateur

func (items DefautProduits) ByIdUtilisateur() map[int64]DefautProduits

ByIdUtilisateur returns a map with 'IdUtilisateur' as keys.

type Fournisseur

type Fournisseur struct {
	Id   int64  `json:"id"`
	Nom  string `json:"nom"`
	Lieu string `json:"lieu"`
}

Fournisseur définit un fournisseur. Chaque fournisseur possède au moins une contrainte de livraison (voir `Livraison`), et peut en posséder plusieurs.

func DeleteFournisseurById

func DeleteFournisseurById(tx DB, id int64) (Fournisseur, error)

Deletes the Fournisseur and returns the item

func ScanFournisseur

func ScanFournisseur(row *sql.Row) (Fournisseur, error)

func SelectFournisseur

func SelectFournisseur(tx DB, id int64) (Fournisseur, error)

SelectFournisseur returns the entry matching id.

func (Fournisseur) Insert

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

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

func (Fournisseur) Update

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

Update Fournisseur in the database and returns the new version.

type Fournisseurs

type Fournisseurs map[int64]Fournisseur

func ScanFournisseurs

func ScanFournisseurs(rs *sql.Rows) (Fournisseurs, error)

func SelectAllFournisseurs

func SelectAllFournisseurs(tx DB) (Fournisseurs, error)

func SelectFournisseurs

func SelectFournisseurs(tx DB, ids ...int64) (Fournisseurs, error)

SelectFournisseurs returns the entry matching the given ids.

func (Fournisseurs) Ids

func (m Fournisseurs) Ids() Ids

type Groupe

type Groupe struct {
	Id          int64  `json:"id"`
	IdSejour    int64  `json:"id_sejour"`
	Nom         string `json:"nom"`
	NbPersonnes int64  `json:"nb_personnes"`
	Couleur     string `json:"couleur"`
}

Groupe est un groupe de personnes lié à un séjour

func DeleteGroupeById

func DeleteGroupeById(tx DB, id int64) (Groupe, error)

Deletes the Groupe and returns the item

func ScanGroupe

func ScanGroupe(row *sql.Row) (Groupe, error)

func SelectGroupe

func SelectGroupe(tx DB, id int64) (Groupe, error)

SelectGroupe returns the entry matching id.

func (Groupe) Insert

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

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

func (Groupe) Update

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

Update Groupe in the database and returns the new version.

type Groupes

type Groupes map[int64]Groupe

func ScanGroupes

func ScanGroupes(rs *sql.Rows) (Groupes, error)

func SelectAllGroupes

func SelectAllGroupes(tx DB) (Groupes, error)

func SelectGroupes

func SelectGroupes(tx DB, ids ...int64) (Groupes, error)

SelectGroupes returns the entry matching the given ids.

func SelectGroupesByIdSejours

func SelectGroupesByIdSejours(tx DB, idSejours ...int64) (Groupes, error)

func (Groupes) Ids

func (m Groupes) Ids() Ids

type Horaire

type Horaire uint8

Horaire définie l'horaire d'un repas.

const (
	PetitDejeuner Horaire = iota // Petit déjeuner
	Midi                         // Midi
	Gouter                       // Goûter
	Diner                        // Dîner
	Cinquieme                    // Cinquième
)

type Ids

type Ids []int64

----------------------------------------------------

func DeleteCommandesByIdUtilisateurs

func DeleteCommandesByIdUtilisateurs(tx DB, idUtilisateurs ...int64) (Ids, error)

func DeleteCommandesByIds

func DeleteCommandesByIds(tx DB, ids ...int64) (Ids, error)

Deletes the Commande in the database and returns the ids.

func DeleteFournisseursByIds

func DeleteFournisseursByIds(tx DB, ids ...int64) (Ids, error)

Deletes the Fournisseur in the database and returns the ids.

func DeleteGroupesByIdSejours

func DeleteGroupesByIdSejours(tx DB, idSejours ...int64) (Ids, error)

func DeleteGroupesByIds

func DeleteGroupesByIds(tx DB, ids ...int64) (Ids, error)

Deletes the Groupe in the database and returns the ids.

func DeleteIngredientsByIds

func DeleteIngredientsByIds(tx DB, ids ...int64) (Ids, error)

Deletes the Ingredient in the database and returns the ids.

func DeleteLivraisonsByIdFournisseurs

func DeleteLivraisonsByIdFournisseurs(tx DB, idFournisseurs ...int64) (Ids, error)

func DeleteLivraisonsByIds

func DeleteLivraisonsByIds(tx DB, ids ...int64) (Ids, error)

Deletes the Livraison in the database and returns the ids.

func DeleteMenusByIdUtilisateurs

func DeleteMenusByIdUtilisateurs(tx DB, idUtilisateurs ...int64) (Ids, error)

func DeleteMenusByIds

func DeleteMenusByIds(tx DB, ids ...int64) (Ids, error)

Deletes the Menu in the database and returns the ids.

func DeleteProduitsByIdLivraisons

func DeleteProduitsByIdLivraisons(tx DB, idLivraisons ...int64) (Ids, error)

func DeleteProduitsByIds

func DeleteProduitsByIds(tx DB, ids ...int64) (Ids, error)

Deletes the Produit in the database and returns the ids.

func DeleteRecettesByIdUtilisateurs

func DeleteRecettesByIdUtilisateurs(tx DB, idUtilisateurs ...int64) (Ids, error)

func DeleteRecettesByIds

func DeleteRecettesByIds(tx DB, ids ...int64) (Ids, error)

Deletes the Recette in the database and returns the ids.

func DeleteRepassByIdSejours

func DeleteRepassByIdSejours(tx DB, idSejours ...int64) (Ids, error)

func DeleteRepassByIds

func DeleteRepassByIds(tx DB, ids ...int64) (Ids, error)

Deletes the Repas in the database and returns the ids.

func DeleteSejoursByIdUtilisateurs

func DeleteSejoursByIdUtilisateurs(tx DB, idUtilisateurs ...int64) (Ids, error)

func DeleteSejoursByIds

func DeleteSejoursByIds(tx DB, ids ...int64) (Ids, error)

Deletes the Sejour in the database and returns the ids.

func DeleteUtilisateursByIds

func DeleteUtilisateursByIds(tx DB, ids ...int64) (Ids, error)

Deletes the Utilisateur in the database and returns the ids.

func (Ids) AsMenuRecettes

func (ids Ids) AsMenuRecettes(idMenu int64) []MenuRecette

func (Ids) AsRepasRecettes

func (ids Ids) AsRepasRecettes(idRepas int64) []RepasRecette

func (Ids) AsSQL

func (ids Ids) AsSQL() pq.Int64Array

func (Ids) AsSet

func (ids Ids) AsSet() Set

type Ingredient

type Ingredient struct {
	Id    int64  `json:"id"`
	Nom   string `json:"nom"`
	Unite Unite  `json:"unite"`

	Categorie Categorie `json:"categorie"`
	Callories Callories `json:"callories"`
	// optionnel, zero signifie pas de contrainte
	Conditionnement Conditionnement `json:"conditionnement,omitempty"`
}

Les ingrédients sont _partagés_ : n'importe quel intendant peut utiliser un ingrédient déjà défini, et ajouter un produit lié. En revanche, les recettes et menus ne sont modifiables que par son _propriétaire_ (mais copiables libremement). En cas de modification par le propriétaire, les intendants utilisant la ressource sont notifiés par mail et peuvent choisir d'accepter la modification ou de s'approprier la ressource en la copiant. Les recettes et menus peuvent n'être liés à aucun propriétaire, et sont alors éditable par tout le monde.

sql: ADD UNIQUE(nom) sql: ADD CHECK(conditionnement->>'unite' = ” OR conditionnement->>'unite' = unite) sql: ADD CHECK(conditionnement->>'unite' != ” OR (conditionnement->'quantite')::real = 0) sql: ADD CHECK(conditionnement->>'unite' = ” OR unite = 'P')

func DeleteIngredientById

func DeleteIngredientById(tx DB, id int64) (Ingredient, error)

Deletes the Ingredient and returns the item

func ScanIngredient

func ScanIngredient(row *sql.Row) (Ingredient, error)

func SelectIngredient

func SelectIngredient(tx DB, id int64) (Ingredient, error)

SelectIngredient returns the entry matching id.

func (Ingredient) GetProduits

func (ig Ingredient) GetProduits(tx DB, fournisseurs Fournisseurs) (Produits, error)

GetProduits renvoie les produits associé à l'ingrédient. Si `fournisseurs` est non nil, seul les produits de ces fournisseurs sont renvoyés Seul le champ 'Id' est utilisé.

func (Ingredient) Insert

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

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

func (Ingredient) Update

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

Update Ingredient in the database and returns the new version.

type IngredientProduit

type IngredientProduit struct {
	IdIngredient int64 `json:"id_ingredient"`
	IdProduit    int64 `json:"id_produit" sql_on_delete:"CASCADE"`

	IdUtilisateur int64 `json:"id_utilisateur"` // ajouteur
}

sql: ADD UNIQUE(id_ingredient, id_produit)

func ScanIngredientProduit

func ScanIngredientProduit(row *sql.Row) (IngredientProduit, error)

func (IngredientProduit) Delete

func (item IngredientProduit) Delete(tx DB) error

Delete the link IngredientProduit in the database. Only the 'IdIngredient' 'IdProduit' 'IdUtilisateur' fields are used.

type IngredientProduits

type IngredientProduits []IngredientProduit

func DeleteIngredientProduitsByIdIngredients

func DeleteIngredientProduitsByIdIngredients(tx DB, idIngredients ...int64) (IngredientProduits, error)

func DeleteIngredientProduitsByIdProduits

func DeleteIngredientProduitsByIdProduits(tx DB, idProduits ...int64) (IngredientProduits, error)

func DeleteIngredientProduitsByIdUtilisateurs

func DeleteIngredientProduitsByIdUtilisateurs(tx DB, idUtilisateurs ...int64) (IngredientProduits, error)

func ScanIngredientProduits

func ScanIngredientProduits(rs *sql.Rows) (IngredientProduits, error)

func SelectAllIngredientProduits

func SelectAllIngredientProduits(tx DB) (IngredientProduits, error)

func SelectIngredientProduitsByIdIngredients

func SelectIngredientProduitsByIdIngredients(tx DB, idIngredients ...int64) (IngredientProduits, error)

func SelectIngredientProduitsByIdProduits

func SelectIngredientProduitsByIdProduits(tx DB, idProduits ...int64) (IngredientProduits, error)

func SelectIngredientProduitsByIdUtilisateurs

func SelectIngredientProduitsByIdUtilisateurs(tx DB, idUtilisateurs ...int64) (IngredientProduits, error)

func (IngredientProduits) ByIdIngredient

func (items IngredientProduits) ByIdIngredient() map[int64]IngredientProduits

ByIdIngredient returns a map with 'IdIngredient' as keys.

func (IngredientProduits) ByIdProduit

func (items IngredientProduits) ByIdProduit() map[int64]IngredientProduits

ByIdProduit returns a map with 'IdProduit' as keys.

func (IngredientProduits) ByIdUtilisateur

func (items IngredientProduits) ByIdUtilisateur() map[int64]IngredientProduits

ByIdUtilisateur returns a map with 'IdUtilisateur' as keys.

type Ingredients

type Ingredients map[int64]Ingredient

func ScanIngredients

func ScanIngredients(rs *sql.Rows) (Ingredients, error)

func SelectAllIngredients

func SelectAllIngredients(tx DB) (Ingredients, error)

func SelectIngredients

func SelectIngredients(tx DB, ids ...int64) (Ingredients, error)

SelectIngredients returns the entry matching the given ids.

func (Ingredients) Ids

func (m Ingredients) Ids() Ids

type JoursLivraison

type JoursLivraison [7]bool

Lundi = 0, Mardi = 1 , etc...

func (JoursLivraison) BestJour

func (js JoursLivraison) BestJour(dateLivraison time.Time) time.Time

BestJour remonte jusqu'au premier jour de livraison possible (incluant `date`).

func (*JoursLivraison) Scan

func (s *JoursLivraison) Scan(src interface{}) error

func (JoursLivraison) Value

func (s JoursLivraison) Value() (driver.Value, error)

type LienIngredient

type LienIngredient struct {
	IdIngredient int64   `json:"id_ingredient"`
	Quantite     float64 `json:"quantite"`
	Cuisson      string  `json:"cuisson"`
}

func ScanLienIngredient

func ScanLienIngredient(row *sql.Row) (LienIngredient, error)

func (LienIngredient) Delete

func (item LienIngredient) Delete(tx DB) error

Delete the link LienIngredient in the database. Only the 'IdIngredient' fields are used.

type LienIngredients

type LienIngredients []LienIngredient

func DeleteLienIngredientsByIdIngredients

func DeleteLienIngredientsByIdIngredients(tx DB, idIngredients ...int64) (LienIngredients, error)

func ScanLienIngredients

func ScanLienIngredients(rs *sql.Rows) (LienIngredients, error)

func SelectAllLienIngredients

func SelectAllLienIngredients(tx DB) (LienIngredients, error)

func SelectLienIngredientsByIdIngredients

func SelectLienIngredientsByIdIngredients(tx DB, idIngredients ...int64) (LienIngredients, error)

func (LienIngredients) AsMenuIngredients

func (ls LienIngredients) AsMenuIngredients(idMenu int64) []MenuIngredient

AsMenuIngredients lie les ingrédients au menu donné

func (LienIngredients) AsRecetteIngredients

func (ls LienIngredients) AsRecetteIngredients(idRecette int64) []RecetteIngredient

AsRecetteIngredients lie les ingrédients au menu donné

func (LienIngredients) AsRepasIngredients

func (ls LienIngredients) AsRepasIngredients(idRepas int64) []RepasIngredient

AsRepasIngredients lie les ingrédients au menu donné

func (LienIngredients) ByIdIngredient

func (items LienIngredients) ByIdIngredient() map[int64]LienIngredients

ByIdIngredient returns a map with 'IdIngredient' as keys.

type Livraison

type Livraison struct {
	Id            int64 `json:"id"`
	IdFournisseur int64 `json:"id_fournisseur" sql_on_delete:"CASCADE"`

	Nom            string         `json:"nom"`
	JoursLivraison JoursLivraison `json:"jours_livraison"` // jours possibles de livraison
	DelaiCommande  int64          `json:"delai_commande"`  // nombre de jours à anticiper par rapport au jour de livraison
	Anticipation   int64          `json:"anticipation"`    // nombre de jours entre la livraison et l'utilisation (défaut : 1)
}

Livraison enregistre les contraintes d'un fournisseur quant à la livraison d'une gamme de produit.

sql: ADD CHECK(anticipation >= 0) sql: ADD CHECK(delai_commande >= 0) sql: ADD UNIQUE(id_fournisseur, nom)

func DeleteLivraisonById

func DeleteLivraisonById(tx DB, id int64) (Livraison, error)

Deletes the Livraison and returns the item

func ScanLivraison

func ScanLivraison(row *sql.Row) (Livraison, error)

func SelectLivraison

func SelectLivraison(tx DB, id int64) (Livraison, error)

SelectLivraison returns the entry matching id.

func (Livraison) DateCommande

func (l Livraison) DateCommande(dateDemande time.Time) (commande time.Time, livraison time.Time)

DateCommande calcule la date conseillée de commande la plus proche possible de `dateDemande` en tenant compte des contraintes. Renvoie la quantités intermédiaire 'dateLivraison'

func (Livraison) Insert

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

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

func (Livraison) Update

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

Update Livraison in the database and returns the new version.

type Livraisons

type Livraisons map[int64]Livraison

func ScanLivraisons

func ScanLivraisons(rs *sql.Rows) (Livraisons, error)

func SelectAllLivraisons

func SelectAllLivraisons(tx DB) (Livraisons, error)

func SelectLivraisons

func SelectLivraisons(tx DB, ids ...int64) (Livraisons, error)

SelectLivraisons returns the entry matching the given ids.

func SelectLivraisonsByIdFournisseurs

func SelectLivraisonsByIdFournisseurs(tx DB, idFournisseurs ...int64) (Livraisons, error)

func (Livraisons) Ids

func (m Livraisons) Ids() Ids
type Menu struct {
	Id            int64         `json:"id"`
	IdUtilisateur sql.NullInt64 `json:"id_utilisateur"`

	Commentaire string `json:"commentaire"`
}

Menu définit un raccourci pour organiser recettes et ingrédients Voir `Repas` pour un repas effectif.

func DeleteMenuById

func DeleteMenuById(tx DB, id int64) (Menu, error)

Deletes the Menu and returns the item

func ScanMenu

func ScanMenu(row *sql.Row) (Menu, error)

func SelectMenu

func SelectMenu(tx DB, id int64) (Menu, error)

SelectMenu returns the entry matching id.

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

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

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

Update Menu in the database and returns the new version.

type MenuIngredient struct {
	IdMenu int64 `json:"id_menu"`
	LienIngredient
}

sql: ADD UNIQUE(id_menu, id_ingredient)

func ScanMenuIngredient

func ScanMenuIngredient(row *sql.Row) (MenuIngredient, error)
func (item MenuIngredient) Delete(tx DB) error

Delete the link MenuIngredient in the database. Only the 'IdMenu' 'IdIngredient' fields are used.

type MenuIngredients []MenuIngredient

func DeleteMenuIngredientsByIdIngredients

func DeleteMenuIngredientsByIdIngredients(tx DB, idIngredients ...int64) (MenuIngredients, error)

func DeleteMenuIngredientsByIdMenus

func DeleteMenuIngredientsByIdMenus(tx DB, idMenus ...int64) (MenuIngredients, error)

func ScanMenuIngredients

func ScanMenuIngredients(rs *sql.Rows) (MenuIngredients, error)

func SelectAllMenuIngredients

func SelectAllMenuIngredients(tx DB) (MenuIngredients, error)

func SelectMenuIngredientsByIdIngredients

func SelectMenuIngredientsByIdIngredients(tx DB, idIngredients ...int64) (MenuIngredients, error)

func SelectMenuIngredientsByIdMenus

func SelectMenuIngredientsByIdMenus(tx DB, idMenus ...int64) (MenuIngredients, error)
func (items MenuIngredients) ByIdIngredient() map[int64]MenuIngredients

ByIdIngredient returns a map with 'IdIngredient' as keys.

func (items MenuIngredients) ByIdMenu() map[int64]MenuIngredients

ByIdMenu returns a map with 'IdMenu' as keys.

type MenuRecette struct {
	IdMenu    int64 `json:"id_menu"`
	IdRecette int64 `json:"id_recette"`
}

sql: ADD UNIQUE(id_menu, id_recette)

func ScanMenuRecette

func ScanMenuRecette(row *sql.Row) (MenuRecette, error)
func (item MenuRecette) Delete(tx DB) error

Delete the link MenuRecette in the database. Only the 'IdMenu' 'IdRecette' fields are used.

type MenuRecettes []MenuRecette

func DeleteMenuRecettesByIdMenus

func DeleteMenuRecettesByIdMenus(tx DB, idMenus ...int64) (MenuRecettes, error)

func DeleteMenuRecettesByIdRecettes

func DeleteMenuRecettesByIdRecettes(tx DB, idRecettes ...int64) (MenuRecettes, error)

func ScanMenuRecettes

func ScanMenuRecettes(rs *sql.Rows) (MenuRecettes, error)

func SelectAllMenuRecettes

func SelectAllMenuRecettes(tx DB) (MenuRecettes, error)

func SelectMenuRecettesByIdMenus

func SelectMenuRecettesByIdMenus(tx DB, idMenus ...int64) (MenuRecettes, error)

func SelectMenuRecettesByIdRecettes

func SelectMenuRecettesByIdRecettes(tx DB, idRecettes ...int64) (MenuRecettes, error)
func (items MenuRecettes) ByIdMenu() map[int64]MenuRecettes

ByIdMenu returns a map with 'IdMenu' as keys.

func (items MenuRecettes) ByIdRecette() map[int64]MenuRecettes

ByIdRecette returns a map with 'IdRecette' as keys.

type Menus map[int64]Menu

func ScanMenus

func ScanMenus(rs *sql.Rows) (Menus, error)

func SelectAllMenus

func SelectAllMenus(tx DB) (Menus, error)

func SelectMenus

func SelectMenus(tx DB, ids ...int64) (Menus, error)

SelectMenus returns the entry matching the given ids.

func SelectMenusByIdUtilisateurs

func SelectMenusByIdUtilisateurs(tx DB, idUtilisateurs ...int64) (Menus, error)
func (m Menus) Ids() Ids

type Produit

type Produit struct {
	Id          int64 `json:"id"`
	IdLivraison int64 `json:"id_livraison"`

	Nom             string          `json:"nom"`
	Conditionnement Conditionnement `json:"conditionnement"`
	Prix            float64         `json:"prix"`

	ReferenceFournisseur string `json:"reference_fournisseur"`
	// zero signifie pas de contrainte
	Colisage int64 `json:"colisage"`
}

sql: ADD CHECK(prix >= 0) sql: ADD UNIQUE(id_livraison, nom)

func DeleteProduitById

func DeleteProduitById(tx DB, id int64) (Produit, error)

Deletes the Produit and returns the item

func ScanProduit

func ScanProduit(row *sql.Row) (Produit, error)

func SelectProduit

func SelectProduit(tx DB, id int64) (Produit, error)

SelectProduit returns the entry matching id.

func (Produit) ColisageNeeded

func (p Produit) ColisageNeeded(quantite float64, isUnitePieces bool) int64

ColisageNeeded renvoie le nombre nécessaire d'exemplaire du produit pour obtenir (au mieux) `quantite` (exprimée dans l'unité du produit). Le cas particulier des ingrédients à la pièce est indiqué par `isUnitePieces`. Si oui, `quantite` est interprétée directement comme le nombre de produits à utiliser. Le colisage est pris en compte (c'est à dire que le résultat est un multiple du colisage du produit).

func (Produit) Insert

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

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

func (Produit) Match

func (p Produit) Match(pattern string) int

Match renvoie la pertinence du produit pour la recherche donnée (higher is better, 0 == non match)

func (Produit) Update

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

Update Produit in the database and returns the new version.

type Produits

type Produits map[int64]Produit

func ScanProduits

func ScanProduits(rs *sql.Rows) (Produits, error)

func SelectAllProduits

func SelectAllProduits(tx DB) (Produits, error)

func SelectProduits

func SelectProduits(tx DB, ids ...int64) (Produits, error)

SelectProduits returns the entry matching the given ids.

func SelectProduitsByIdLivraisons

func SelectProduitsByIdLivraisons(tx DB, idLivraisons ...int64) (Produits, error)

func (Produits) Ids

func (m Produits) Ids() Ids

type Recette

type Recette struct {
	Id            int64         `json:"id"`
	IdUtilisateur sql.NullInt64 `json:"id_utilisateur"`
	Nom           string        `json:"nom"`

	ModeEmploi string `json:"mode_emploi"`
}

func DeleteRecetteById

func DeleteRecetteById(tx DB, id int64) (Recette, error)

Deletes the Recette and returns the item

func ScanRecette

func ScanRecette(row *sql.Row) (Recette, error)

func SelectRecette

func SelectRecette(tx DB, id int64) (Recette, error)

SelectRecette returns the entry matching id.

func (Recette) Insert

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

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

func (Recette) Update

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

Update Recette in the database and returns the new version.

type RecetteIngredient

type RecetteIngredient struct {
	IdRecette int64 `json:"id_recette"`
	LienIngredient
}

sql: ADD UNIQUE(id_recette, id_ingredient)

func ScanRecetteIngredient

func ScanRecetteIngredient(row *sql.Row) (RecetteIngredient, error)

func (RecetteIngredient) Delete

func (item RecetteIngredient) Delete(tx DB) error

Delete the link RecetteIngredient in the database. Only the 'IdRecette' 'IdIngredient' fields are used.

type RecetteIngredients

type RecetteIngredients []RecetteIngredient

func DeleteRecetteIngredientsByIdIngredients

func DeleteRecetteIngredientsByIdIngredients(tx DB, idIngredients ...int64) (RecetteIngredients, error)

func DeleteRecetteIngredientsByIdRecettes

func DeleteRecetteIngredientsByIdRecettes(tx DB, idRecettes ...int64) (RecetteIngredients, error)

func ScanRecetteIngredients

func ScanRecetteIngredients(rs *sql.Rows) (RecetteIngredients, error)

func SelectAllRecetteIngredients

func SelectAllRecetteIngredients(tx DB) (RecetteIngredients, error)

func SelectRecetteIngredientsByIdIngredients

func SelectRecetteIngredientsByIdIngredients(tx DB, idIngredients ...int64) (RecetteIngredients, error)

func SelectRecetteIngredientsByIdRecettes

func SelectRecetteIngredientsByIdRecettes(tx DB, idRecettes ...int64) (RecetteIngredients, error)

func (RecetteIngredients) ByIdIngredient

func (items RecetteIngredients) ByIdIngredient() map[int64]RecetteIngredients

ByIdIngredient returns a map with 'IdIngredient' as keys.

func (RecetteIngredients) ByIdRecette

func (items RecetteIngredients) ByIdRecette() map[int64]RecetteIngredients

ByIdRecette returns a map with 'IdRecette' as keys.

type Recettes

type Recettes map[int64]Recette

func ScanRecettes

func ScanRecettes(rs *sql.Rows) (Recettes, error)

func SelectAllRecettes

func SelectAllRecettes(tx DB) (Recettes, error)

func SelectRecettes

func SelectRecettes(tx DB, ids ...int64) (Recettes, error)

SelectRecettes returns the entry matching the given ids.

func SelectRecettesByIdUtilisateurs

func SelectRecettesByIdUtilisateurs(tx DB, idUtilisateurs ...int64) (Recettes, error)

func (Recettes) Ids

func (m Recettes) Ids() Ids

type Repas

type Repas struct {
	Id              int64   `json:"id"`
	IdSejour        int64   `json:"id_sejour"`
	OffsetPersonnes int64   `json:"offset_personnes"`
	JourOffset      int64   `json:"jour_offset"`
	Horaire         Horaire `json:"horaire"`
	Anticipation    int64   `json:"anticipation"` // commande les ingrédients en avance (en jours)
}

Le concept de journée nécessite d'être lié à la donnée du nombre de personnes pour chaque menu. Cela ne colle pas bien avec un schéma SQL classique. De plus, une journée n'a pas vraiment d'intérêt à être partagée : la modification sur une journée entrainerait celle sur une autre, ce qui est serait plutôt déroutant. On propose donc de ne pas utiliser de table "journée", mais de construire (dynamiquement) les journées à partir de la table _repas_ (voir ci dessous). En revanche, le concept de journée sera bien présent pour l'utilisateur, pour organiser son emploi du temps, ou pour copier des journées déjà existantes.

Repas représente un repas effectif, lié à un séjour. Il est constitué de recettes et d'ingrédients (de la même manière qu'un menu)

func DeleteRepasById

func DeleteRepasById(tx DB, id int64) (Repas, error)

Deletes the Repas and returns the item

func ScanRepas

func ScanRepas(row *sql.Row) (Repas, error)

func SelectRepas

func SelectRepas(tx DB, id int64) (Repas, error)

SelectRepas returns the entry matching id.

func (Repas) Insert

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

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

func (Repas) Update

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

Update Repas in the database and returns the new version.

type RepasGroupe

type RepasGroupe struct {
	IdRepas  int64 `json:"id_repas" sql_on_delete:"CASCADE"`
	IdGroupe int64 `json:"id_groupe" sql_on_delete:"CASCADE"`
}

sql: ADD UNIQUE(id_repas, id_groupe)

func ScanRepasGroupe

func ScanRepasGroupe(row *sql.Row) (RepasGroupe, error)

func (RepasGroupe) Delete

func (item RepasGroupe) Delete(tx DB) error

Delete the link RepasGroupe in the database. Only the 'IdRepas' 'IdGroupe' fields are used.

type RepasGroupes

type RepasGroupes []RepasGroupe

func DeleteRepasGroupesByIdGroupes

func DeleteRepasGroupesByIdGroupes(tx DB, idGroupes ...int64) (RepasGroupes, error)

func DeleteRepasGroupesByIdRepass

func DeleteRepasGroupesByIdRepass(tx DB, idRepass ...int64) (RepasGroupes, error)

func ScanRepasGroupes

func ScanRepasGroupes(rs *sql.Rows) (RepasGroupes, error)

func SelectAllRepasGroupes

func SelectAllRepasGroupes(tx DB) (RepasGroupes, error)

func SelectRepasGroupesByIdGroupes

func SelectRepasGroupesByIdGroupes(tx DB, idGroupes ...int64) (RepasGroupes, error)

func SelectRepasGroupesByIdRepass

func SelectRepasGroupesByIdRepass(tx DB, idRepass ...int64) (RepasGroupes, error)

func (RepasGroupes) ByIdGroupe

func (items RepasGroupes) ByIdGroupe() map[int64]RepasGroupes

ByIdGroupe returns a map with 'IdGroupe' as keys.

func (RepasGroupes) ByIdRepas

func (items RepasGroupes) ByIdRepas() map[int64]RepasGroupes

ByIdRepas returns a map with 'IdRepas' as keys.

type RepasIngredient

type RepasIngredient struct {
	IdRepas int64 `json:"id_repas" sql_on_delete:"CASCADE"`
	LienIngredient
}

sql: ADD UNIQUE(id_repas, id_ingredient)

func ScanRepasIngredient

func ScanRepasIngredient(row *sql.Row) (RepasIngredient, error)

func (RepasIngredient) Delete

func (item RepasIngredient) Delete(tx DB) error

Delete the link RepasIngredient in the database. Only the 'IdRepas' 'IdIngredient' fields are used.

type RepasIngredients

type RepasIngredients []RepasIngredient

func DeleteRepasIngredientsByIdIngredients

func DeleteRepasIngredientsByIdIngredients(tx DB, idIngredients ...int64) (RepasIngredients, error)

func DeleteRepasIngredientsByIdRepass

func DeleteRepasIngredientsByIdRepass(tx DB, idRepass ...int64) (RepasIngredients, error)

func ScanRepasIngredients

func ScanRepasIngredients(rs *sql.Rows) (RepasIngredients, error)

func SelectAllRepasIngredients

func SelectAllRepasIngredients(tx DB) (RepasIngredients, error)

func SelectRepasIngredientsByIdIngredients

func SelectRepasIngredientsByIdIngredients(tx DB, idIngredients ...int64) (RepasIngredients, error)

func SelectRepasIngredientsByIdRepass

func SelectRepasIngredientsByIdRepass(tx DB, idRepass ...int64) (RepasIngredients, error)

func (RepasIngredients) ByIdIngredient

func (items RepasIngredients) ByIdIngredient() map[int64]RepasIngredients

ByIdIngredient returns a map with 'IdIngredient' as keys.

func (RepasIngredients) ByIdRepas

func (items RepasIngredients) ByIdRepas() map[int64]RepasIngredients

ByIdRepas returns a map with 'IdRepas' as keys.

type RepasRecette

type RepasRecette struct {
	IdRepas   int64 `json:"id_repas" sql_on_delete:"CASCADE"`
	IdRecette int64 `json:"id_recette"`
}

sql: ADD UNIQUE(id_repas, id_recette)

func ScanRepasRecette

func ScanRepasRecette(row *sql.Row) (RepasRecette, error)

func (RepasRecette) Delete

func (item RepasRecette) Delete(tx DB) error

Delete the link RepasRecette in the database. Only the 'IdRepas' 'IdRecette' fields are used.

type RepasRecettes

type RepasRecettes []RepasRecette

func DeleteRepasRecettesByIdRecettes

func DeleteRepasRecettesByIdRecettes(tx DB, idRecettes ...int64) (RepasRecettes, error)

func DeleteRepasRecettesByIdRepass

func DeleteRepasRecettesByIdRepass(tx DB, idRepass ...int64) (RepasRecettes, error)

func ScanRepasRecettes

func ScanRepasRecettes(rs *sql.Rows) (RepasRecettes, error)

func SelectAllRepasRecettes

func SelectAllRepasRecettes(tx DB) (RepasRecettes, error)

func SelectRepasRecettesByIdRecettes

func SelectRepasRecettesByIdRecettes(tx DB, idRecettes ...int64) (RepasRecettes, error)

func SelectRepasRecettesByIdRepass

func SelectRepasRecettesByIdRepass(tx DB, idRepass ...int64) (RepasRecettes, error)

func (RepasRecettes) ByIdRecette

func (items RepasRecettes) ByIdRecette() map[int64]RepasRecettes

ByIdRecette returns a map with 'IdRecette' as keys.

func (RepasRecettes) ByIdRepas

func (items RepasRecettes) ByIdRepas() map[int64]RepasRecettes

ByIdRepas returns a map with 'IdRepas' as keys.

type Repass

type Repass map[int64]Repas

func ScanRepass

func ScanRepass(rs *sql.Rows) (Repass, error)

func SelectAllRepass

func SelectAllRepass(tx DB) (Repass, error)

func SelectRepass

func SelectRepass(tx DB, ids ...int64) (Repass, error)

SelectRepass returns the entry matching the given ids.

func SelectRepassByIdSejours

func SelectRepassByIdSejours(tx DB, idSejours ...int64) (Repass, error)

func (Repass) Ids

func (m Repass) Ids() Ids

type Sejour

type Sejour struct {
	Id            int64 `json:"id"`
	IdUtilisateur int64 `json:"id_utilisateur"`

	// Fixe l'origine du séjour.
	// Une journée est déterminé par un "offset"
	// relatif à cette date.
	DateDebut time.Time `json:"date_debut"`
	Nom       string    `json:"nom"`
}

Les séjours sont _privés_, mais les journées formées peuvent être copiées. sql: ADD UNIQUE(id, id_utilisateur)

func DeleteSejourById

func DeleteSejourById(tx DB, id int64) (Sejour, error)

Deletes the Sejour and returns the item

func ScanSejour

func ScanSejour(row *sql.Row) (Sejour, error)

func SelectSejour

func SelectSejour(tx DB, id int64) (Sejour, error)

SelectSejour returns the entry matching id.

func (Sejour) DateFromOffset

func (s Sejour) DateFromOffset(jour int64) time.Time

func (Sejour) Insert

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

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

func (Sejour) Update

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

Update Sejour in the database and returns the new version.

type SejourFournisseur

type SejourFournisseur struct {
	IdUtilisateur int64 `json:"id_utilisateur,omitempty"`
	IdSejour      int64 `json:"id_sejour,omitempty"`
	IdFournisseur int64 `json:"id_fournisseur,omitempty"`
}

Enregistre les fournisseurs associés à un séjour. Note: Le champ `IdUtilisateur` permet d'assurer par une contrainte que les fournisseurs soient associés à l'utilisateur du séjour.

sql: ADD UNIQUE(id_sejour,id_fournisseur) sql: ADD FOREIGN KEY (id_utilisateur, id_sejour) REFERENCES sejours (id_utilisateur, id) sql: ADD FOREIGN KEY (id_utilisateur, id_fournisseur) REFERENCES utilisateur_fournisseurs (id_utilisateur, id_fournisseur)

func ScanSejourFournisseur

func ScanSejourFournisseur(row *sql.Row) (SejourFournisseur, error)

func (SejourFournisseur) Delete

func (item SejourFournisseur) Delete(tx DB) error

Delete the link SejourFournisseur in the database. Only the 'IdUtilisateur' 'IdSejour' 'IdFournisseur' fields are used.

type SejourFournisseurs

type SejourFournisseurs []SejourFournisseur

func DeleteSejourFournisseursByIdFournisseurs

func DeleteSejourFournisseursByIdFournisseurs(tx DB, idFournisseurs ...int64) (SejourFournisseurs, error)

func DeleteSejourFournisseursByIdSejours

func DeleteSejourFournisseursByIdSejours(tx DB, idSejours ...int64) (SejourFournisseurs, error)

func DeleteSejourFournisseursByIdUtilisateurs

func DeleteSejourFournisseursByIdUtilisateurs(tx DB, idUtilisateurs ...int64) (SejourFournisseurs, error)

func ScanSejourFournisseurs

func ScanSejourFournisseurs(rs *sql.Rows) (SejourFournisseurs, error)

func SelectAllSejourFournisseurs

func SelectAllSejourFournisseurs(tx DB) (SejourFournisseurs, error)

func SelectSejourFournisseursByIdFournisseurs

func SelectSejourFournisseursByIdFournisseurs(tx DB, idFournisseurs ...int64) (SejourFournisseurs, error)

func SelectSejourFournisseursByIdSejours

func SelectSejourFournisseursByIdSejours(tx DB, idSejours ...int64) (SejourFournisseurs, error)

func SelectSejourFournisseursByIdUtilisateurs

func SelectSejourFournisseursByIdUtilisateurs(tx DB, idUtilisateurs ...int64) (SejourFournisseurs, error)

func (SejourFournisseurs) ByIdFournisseur

func (items SejourFournisseurs) ByIdFournisseur() map[int64]SejourFournisseurs

ByIdFournisseur returns a map with 'IdFournisseur' as keys.

func (SejourFournisseurs) ByIdSejour

func (items SejourFournisseurs) ByIdSejour() map[int64]SejourFournisseurs

ByIdSejour returns a map with 'IdSejour' as keys.

func (SejourFournisseurs) ByIdUtilisateur

func (items SejourFournisseurs) ByIdUtilisateur() map[int64]SejourFournisseurs

ByIdUtilisateur returns a map with 'IdUtilisateur' as keys.

type Sejours

type Sejours map[int64]Sejour

func ScanSejours

func ScanSejours(rs *sql.Rows) (Sejours, error)

func SelectAllSejours

func SelectAllSejours(tx DB) (Sejours, error)

func SelectSejours

func SelectSejours(tx DB, ids ...int64) (Sejours, error)

SelectSejours returns the entry matching the given ids.

func SelectSejoursByIdUtilisateurs

func SelectSejoursByIdUtilisateurs(tx DB, idUtilisateurs ...int64) (Sejours, error)

func (Sejours) Ids

func (m Sejours) Ids() Ids

type Set

type Set map[int64]bool // on choisit bool pour l'interaction avec .js

func NewSet

func NewSet() Set

func NewSetFromSlice

func NewSetFromSlice(keys []int64) Set

func (Set) Add

func (s Set) Add(key int64)

func (Set) Has

func (s Set) Has(key int64) bool

func (Set) Keys

func (s Set) Keys() []int64

type Unite

type Unite string
const (
	Zero   Unite = ""   // Unité invalide
	Litres Unite = "L"  // Litres
	Kilos  Unite = "Kg" // Kilos
	Piece  Unite = "P"  // Pièce(s)
)

func (Unite) String

func (u Unite) String() string

type Utilisateur

type Utilisateur struct {
	Id       int64  `json:"id"`
	Password string `json:"password"`
	Mail     string `json:"mail"`

	PrenomNom string `json:"prenom_nom"`
}

Le logiciel est disponible sous la forme d'une **application web** accessible par mail/password. sql: ADD UNIQUE(mail)

func DeleteUtilisateurById

func DeleteUtilisateurById(tx DB, id int64) (Utilisateur, error)

Deletes the Utilisateur and returns the item

func ScanUtilisateur

func ScanUtilisateur(row *sql.Row) (Utilisateur, error)

func SelectUtilisateur

func SelectUtilisateur(tx DB, id int64) (Utilisateur, error)

SelectUtilisateur returns the entry matching id.

func (Utilisateur) Insert

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

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

func (Utilisateur) Update

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

Update Utilisateur in the database and returns the new version.

type UtilisateurFournisseur

type UtilisateurFournisseur struct {
	IdUtilisateur int64 `json:"id_utilisateur"`
	IdFournisseur int64 `json:"id_fournisseur"`
}

Enregistre les fournisseurs associés à chaque utilisateur sql: ADD UNIQUE(id_utilisateur,id_fournisseur)

func ScanUtilisateurFournisseur

func ScanUtilisateurFournisseur(row *sql.Row) (UtilisateurFournisseur, error)

func (UtilisateurFournisseur) Delete

func (item UtilisateurFournisseur) Delete(tx DB) error

Delete the link UtilisateurFournisseur in the database. Only the 'IdUtilisateur' 'IdFournisseur' fields are used.

type UtilisateurFournisseurs

type UtilisateurFournisseurs []UtilisateurFournisseur

func DeleteUtilisateurFournisseursByIdFournisseurs

func DeleteUtilisateurFournisseursByIdFournisseurs(tx DB, idFournisseurs ...int64) (UtilisateurFournisseurs, error)

func DeleteUtilisateurFournisseursByIdUtilisateurs

func DeleteUtilisateurFournisseursByIdUtilisateurs(tx DB, idUtilisateurs ...int64) (UtilisateurFournisseurs, error)

func ScanUtilisateurFournisseurs

func ScanUtilisateurFournisseurs(rs *sql.Rows) (UtilisateurFournisseurs, error)

func SelectAllUtilisateurFournisseurs

func SelectAllUtilisateurFournisseurs(tx DB) (UtilisateurFournisseurs, error)

func SelectUtilisateurFournisseursByIdFournisseurs

func SelectUtilisateurFournisseursByIdFournisseurs(tx DB, idFournisseurs ...int64) (UtilisateurFournisseurs, error)

func SelectUtilisateurFournisseursByIdUtilisateurs

func SelectUtilisateurFournisseursByIdUtilisateurs(tx DB, idUtilisateurs ...int64) (UtilisateurFournisseurs, error)

func (UtilisateurFournisseurs) ByIdFournisseur

func (items UtilisateurFournisseurs) ByIdFournisseur() map[int64]UtilisateurFournisseurs

ByIdFournisseur returns a map with 'IdFournisseur' as keys.

func (UtilisateurFournisseurs) ByIdUtilisateur

func (items UtilisateurFournisseurs) ByIdUtilisateur() map[int64]UtilisateurFournisseurs

ByIdUtilisateur returns a map with 'IdUtilisateur' as keys.

type Utilisateurs

type Utilisateurs map[int64]Utilisateur

func ScanUtilisateurs

func ScanUtilisateurs(rs *sql.Rows) (Utilisateurs, error)

func SelectAllUtilisateurs

func SelectAllUtilisateurs(tx DB) (Utilisateurs, error)

func SelectUtilisateurs

func SelectUtilisateurs(tx DB, ids ...int64) (Utilisateurs, error)

SelectUtilisateurs returns the entry matching the given ids.

func (Utilisateurs) Ids

func (m Utilisateurs) Ids() Ids

Jump to

Keyboard shortcuts

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