Documentation
¶
Index ¶
- Constants
- func ErrorAuth(err error) error
- func ErrorSQL(err error) error
- type CommandeCompleteItem
- type CommandeContraintes
- type CommandeSimpleItem
- type ContrainteIngredient
- type ContrainteIngredientProduit
- type ContrainteListeIngredients
- type ContrainteLivraison
- type ContrainteProduit
- type DateIngredientQuantites
- type ErrorIngredientUsed
- type InAjouteIngredientProduit
- type InAssistantCreateRepass
- type InAssocieIngredients
- type InCommandeComplete
- type InCommandeSimple
- type InLieIngredientProduit
- type InLoggin
- type InRechercheProduit
- type InResoudIngredients
- type InSejourFournisseurs
- type InSetDefautProduit
- type IngredientProduits
- type IngredientQuantite
- type IngredientQuantiteOrigines
- type Ingredients
- type IngredientsSejour
- type LivraisonsPossibles
- type MenuComplet
- type OptionsAssistantCreateRepass
- type OutCommandeComplete
- type OutCommandeSimple
- type OutDeleteGroupe
- type OutFournisseurs
- type OutLoggin
- type PreviewCommande
- type ProduitsPossibles
- type RecetteComplet
- type RepasComplet
- type RequeteContext
- func (ct RequeteContext) AjouteIngredientProduit(idIngredient int64, produit models.Produit) (models.Produit, error)
- func (ct RequeteContext) CreateFournisseur(fournisseur models.Fournisseur) (out models.Fournisseur, err error)
- func (ct RequeteContext) CreateGroupe(idSejour int64) (out models.Groupe, err error)
- func (ct RequeteContext) CreateIngredient() (out models.Ingredient, err error)
- func (ct RequeteContext) CreateLivraison(livraison models.Livraison) (models.Livraison, error)
- func (ct RequeteContext) CreateMenu() (out models.Menu, err error)
- func (ct RequeteContext) CreateRecette() (out models.Recette, err error)
- func (ct RequeteContext) CreateRepas(idSejour int64) (out models.Repas, err error)
- func (ct RequeteContext) CreateSejour() (out models.Sejour, err error)
- func (ct RequeteContext) DeleteFournisseur(idFournisseur int64) error
- func (ct RequeteContext) DeleteGroupe(id int64) (OutDeleteGroupe, error)
- func (ct RequeteContext) DeleteIngredient(id int64, checkProduits bool) error
- func (ct RequeteContext) DeleteLivraison(idLivraison int64) error
- func (ct RequeteContext) DeleteMenu(id int64) error
- func (ct RequeteContext) DeleteProduit(idProduit int64) error
- func (ct RequeteContext) DeleteRecette(id int64) error
- func (ct RequeteContext) DeleteRepas(id int64) error
- func (ct RequeteContext) DeleteSejour(id int64) error
- func (ct RequeteContext) EtablitCommandeComplete(params InCommandeComplete) (OutCommandeComplete, error)
- func (ct RequeteContext) EtablitCommandeSimple(params InCommandeSimple) (OutCommandeSimple, error)
- func (ct RequeteContext) GetIngredientProduits(idIngredient int64) (IngredientProduits, error)
- func (ct RequeteContext) InitiateRepas(params InAssistantCreateRepass) error
- func (ct RequeteContext) LoadFournisseurs() (OutFournisseurs, error)
- func (ct RequeteContext) LoadSejoursUtilisateur() (out Sejours, err error)
- func (ct RequeteContext) ProposeLienIngredientLivraison(params InAssocieIngredients) (LivraisonsPossibles, error)
- func (ct RequeteContext) ProposeLienIngredientProduit(params InAssocieIngredients) (ProduitsPossibles, error)
- func (ct RequeteContext) RechercheProduit(search InRechercheProduit) ([]models.Produit, error)
- func (ct RequeteContext) SetDefautProduit(idIngredient int64, idProduit int64, on bool) error
- func (ct RequeteContext) UpdateFournisseur(fournisseur models.Fournisseur) (models.Fournisseur, error)
- func (ct RequeteContext) UpdateGroupe(in models.Groupe) (models.Groupe, error)
- func (ct RequeteContext) UpdateIngredient(ig models.Ingredient) (models.Ingredient, error)
- func (ct RequeteContext) UpdateLivraison(livraison models.Livraison) (models.Livraison, error)
- func (ct RequeteContext) UpdateManyRepas(repass []RepasComplet) error
- func (ct RequeteContext) UpdateMenu(in MenuComplet) (MenuComplet, error)
- func (ct RequeteContext) UpdateProduit(produit models.Produit) (out models.Produit, err error)
- func (ct RequeteContext) UpdateRecette(in RecetteComplet) (RecetteComplet, error)
- func (ct RequeteContext) UpdateSejour(in models.Sejour) (models.Sejour, error)
- func (ct RequeteContext) UpdateSejourFournisseurs(idSejour int64, idsFournisseurs []int64) error
- type SejourRepas
- type Sejours
- type Server
- func (s Server) GetDevToken() (string, error)
- func (s Server) JWTMiddleware() echo.MiddlewareFunc
- func (s Server) LoadIngredients() (models.Ingredients, error)
- func (s Server) LoadMenus() (out map[int64]*MenuComplet, err error)
- func (s Server) LoadRecettes() (out map[int64]*RecetteComplet, err error)
- func (s Server) LoadUtilisateurs() (map[int64]Utilisateur, error)
- func (s Server) Loggin(mail, password string) (out OutLoggin, err error)
- func (s Server) NewRequeteContext(c echo.Context) RequeteContext
- func (s Server) ResoudIngredientsJournees(idSejour int64, journeesOffsets []int64) ([]DateIngredientQuantites, error)
- func (s Server) ResoudIngredientsRepas(idRepas, nbPersonnes int64) ([]IngredientQuantite, error)
- type TimedIngredientQuantite
- type Tx
- type UserMeta
- type Utilisateur
Constants ¶
const (
DeltaTokenJours = 3
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CommandeCompleteItem ¶
type CommandeCompleteItem struct {
Produit models.Produit `json:"produit"`
// jour conseillé de commande, prenant en compte les délais de livraison
JourCommande time.Time `json:"jour_commande"`
Quantite int64 `json:"quantite"`
// ingrédients liés à ce produit
Origines []TimedIngredientQuantite `json:"origines"`
}
CommandeCompleteItem représente la commande d'un produit.
type CommandeContraintes ¶
type CommandeContraintes struct {
// Précise la cible à utiliser pour un ingrédient (idIngredient -> idCible)
Associations map[int64]int64 `json:"associations"`
// Si `true`, regroupe toutes les commandes
// à la date courante (prototype)
Regroupe bool `json:"regroupe"`
}
CommandeContraintes paramétrise la requête de commande
type CommandeSimpleItem ¶
type CommandeSimpleItem struct {
Livraison models.Livraison `json:"livraison"`
// jour conseillé de commande, prenant en compte les délais de livraison
JourCommande time.Time `json:"jour_commande"`
// liste groupée des ingrédients à commander
// (un même ingrédient n'y apparait qu'une fois),
// avec les ingrédients donnant lieu à cet item
Ingredients []IngredientQuantiteOrigines `json:"ingredients"`
}
CommandeSimpleItem représente la commande d'un ingrédient (ou plusieurs ingrédient) chez un fournisseur. Alternative plus simple à `CommandeItem`
type ContrainteIngredient ¶
type ContrainteIngredient struct {
// contains filtered or unexported fields
}
func (ContrainteIngredient) Check ¶
func (c ContrainteIngredient) Check() error
type ContrainteIngredientProduit ¶
type ContrainteIngredientProduit struct {
// contains filtered or unexported fields
}
func (ContrainteIngredientProduit) Check ¶
func (c ContrainteIngredientProduit) Check() error
type ContrainteListeIngredients ¶
type ContrainteListeIngredients struct {
// contains filtered or unexported fields
}
func (ContrainteListeIngredients) Check ¶
func (c ContrainteListeIngredients) Check() error
type ContrainteLivraison ¶
type ContrainteLivraison struct {
// contains filtered or unexported fields
}
func (ContrainteLivraison) Check ¶
func (c ContrainteLivraison) Check() error
type ContrainteProduit ¶
type ContrainteProduit struct {
// contains filtered or unexported fields
}
func (ContrainteProduit) Check ¶
func (c ContrainteProduit) Check() error
type DateIngredientQuantites ¶
type DateIngredientQuantites struct {
Date time.Time `json:"date"`
Ingredients []IngredientQuantite `json:"ingredients"`
}
type ErrorIngredientUsed ¶
type ErrorIngredientUsed struct {
// contains filtered or unexported fields
}
func (ErrorIngredientUsed) Error ¶
func (e ErrorIngredientUsed) Error() string
type InAssistantCreateRepass ¶
type InAssistantCreateRepass struct {
IdSejour int64 `json:"id_sejour"`
Options OptionsAssistantCreateRepass `json:"options"`
GroupesSorties map[int][]int64 `json:"groupes_sorties"` // offset -> ids_groupes
}
type InAssocieIngredients ¶
type InAssocieIngredients = IngredientsSejour
type InCommandeComplete ¶
type InCommandeComplete struct {
IngredientsSejour
Contraintes CommandeContraintes `json:"contraintes"`
}
type InCommandeSimple ¶
type InCommandeSimple struct {
IngredientsSejour
Contraintes CommandeContraintes `json:"contraintes"`
}
type InLieIngredientProduit ¶
type InRechercheProduit ¶
type InResoudIngredients ¶
type InResoudIngredients struct {
Mode string `json:"mode"` // "repas" ou "journees"
IdRepas int64 `json:"id_repas"` // pour Mode == "repas"
// pour Mode == "repas" seulement
// donner -1 pour utiliser le nombre de personnes actuel
NbPersonnes int64 `json:"nb_personnes"`
IdSejour int64 `json:"id_sejour"` // pour Mode == "journees"
JourOffsets []int64 `json:"jour_offset"` // pour Mode == "journees". Passer nil pour tout le sejour
}
type InSejourFournisseurs ¶
type InSetDefautProduit ¶
type IngredientProduits ¶
type IngredientQuantite ¶
type IngredientQuantite struct {
Ingredient models.Ingredient `json:"ingredient"`
Quantite float64 `json:"quantite"`
}
type IngredientQuantiteOrigines ¶
type IngredientQuantiteOrigines struct {
IngredientQuantite
Origines []TimedIngredientQuantite `json:"origines"`
}
type Ingredients ¶
type Ingredients = models.Ingredients
type IngredientsSejour ¶
type IngredientsSejour struct {
Ingredients []DateIngredientQuantites `json:"ingredients"`
IdSejour int64 `json:"id_sejour"`
}
type LivraisonsPossibles ¶
LivraisonsPossibles propose une livraison conseillées pour un ingrédient, en faisant éventuellement un choix arbitraire
type MenuComplet ¶
type OutCommandeComplete ¶
type OutCommandeComplete struct {
Commande []CommandeCompleteItem `json:"commande"`
}
type OutCommandeSimple ¶
type OutCommandeSimple struct {
Commande []CommandeSimpleItem `json:"commande"`
}
type OutDeleteGroupe ¶
type OutFournisseurs ¶
type OutFournisseurs struct {
Fournisseurs models.Fournisseurs `json:"fournisseurs"`
Livraisons models.Livraisons `json:"livraisons"`
}
type OutLoggin ¶
type OutLoggin struct {
Erreur string `json:"erreur"`
Token string `json:"token"`
Utilisateur Utilisateur `json:"utilisateur"`
Expires int `json:"expires"` // en jours
}
type PreviewCommande ¶
type PreviewCommande struct {
Produits []CommandeCompleteItem
}
type ProduitsPossibles ¶
ProduitsPossibles indique les produits disponibles pour un ingrédient
type RecetteComplet ¶
type RecetteComplet struct {
models.Recette
Ingredients models.LienIngredients `json:"ingredients"`
}
type RepasComplet ¶
type RepasComplet struct {
models.Repas
Groupes []models.RepasGroupe `json:"groupes"`
Recettes models.Ids `json:"recettes"`
Ingredients models.LienIngredients `json:"ingredients"`
}
type RequeteContext ¶
RequeteContext est créé pour chaque requête.
func (RequeteContext) AjouteIngredientProduit ¶
func (ct RequeteContext) AjouteIngredientProduit(idIngredient int64, produit models.Produit) (models.Produit, error)
AjouteIngredientProduit crée le produit donné et l'associe à l'ingrédient.
func (RequeteContext) CreateFournisseur ¶
func (ct RequeteContext) CreateFournisseur(fournisseur models.Fournisseur) (out models.Fournisseur, err error)
CreateFournisseur crée un fournisseur et le lie à l'utilisateur courant Une contrainte de livraison "standard" est automatiquement créée
func (RequeteContext) CreateGroupe ¶
func (ct RequeteContext) CreateGroupe(idSejour int64) (out models.Groupe, err error)
func (RequeteContext) CreateIngredient ¶
func (ct RequeteContext) CreateIngredient() (out models.Ingredient, err error)
func (RequeteContext) CreateLivraison ¶
func (RequeteContext) CreateMenu ¶
func (ct RequeteContext) CreateMenu() (out models.Menu, err error)
func (RequeteContext) CreateRecette ¶
func (ct RequeteContext) CreateRecette() (out models.Recette, err error)
func (RequeteContext) CreateRepas ¶
func (ct RequeteContext) CreateRepas(idSejour int64) (out models.Repas, err error)
func (RequeteContext) CreateSejour ¶
func (ct RequeteContext) CreateSejour() (out models.Sejour, err error)
func (RequeteContext) DeleteFournisseur ¶
func (ct RequeteContext) DeleteFournisseur(idFournisseur int64) error
func (RequeteContext) DeleteGroupe ¶
func (ct RequeteContext) DeleteGroupe(id int64) (OutDeleteGroupe, error)
DeleteGroupe supprime le groupe et renvoie le nombre de repas touchés.
func (RequeteContext) DeleteIngredient ¶
func (ct RequeteContext) DeleteIngredient(id int64, checkProduits bool) error
func (RequeteContext) DeleteLivraison ¶
func (ct RequeteContext) DeleteLivraison(idLivraison int64) error
DeleteLivraison supprime la livraison
func (RequeteContext) DeleteMenu ¶
func (ct RequeteContext) DeleteMenu(id int64) error
func (RequeteContext) DeleteProduit ¶
func (ct RequeteContext) DeleteProduit(idProduit int64) error
func (RequeteContext) DeleteRecette ¶
func (ct RequeteContext) DeleteRecette(id int64) error
func (RequeteContext) DeleteRepas ¶
func (ct RequeteContext) DeleteRepas(id int64) error
func (RequeteContext) DeleteSejour ¶
func (ct RequeteContext) DeleteSejour(id int64) error
func (RequeteContext) EtablitCommandeComplete ¶
func (ct RequeteContext) EtablitCommandeComplete(params InCommandeComplete) (OutCommandeComplete, error)
EtablitCommandeComplete associe à chaque ingrédient un produit (avec une quantité) et un jour de commande respectant la date d'utilisation et le délai de livraison. Tous les ingrédients doivent être associés à un produit par le client.
func (RequeteContext) EtablitCommandeSimple ¶
func (ct RequeteContext) EtablitCommandeSimple(params InCommandeSimple) (OutCommandeSimple, error)
EtablitCommandeSimple regroupe chaque ingrédient par fournisseur, en précisant une date de commande respectant les délais de livraisons. Tous les ingrédients doivent être associés à une livraison par le client.
func (RequeteContext) GetIngredientProduits ¶
func (ct RequeteContext) GetIngredientProduits(idIngredient int64) (IngredientProduits, error)
func (RequeteContext) InitiateRepas ¶
func (ct RequeteContext) InitiateRepas(params InAssistantCreateRepass) error
func (RequeteContext) LoadFournisseurs ¶
func (ct RequeteContext) LoadFournisseurs() (OutFournisseurs, error)
LoadFournisseurs renvoie les fournisseurs associés à l'utilisateur courant, ainsi que les contraints de livraisons pertinentes.
func (RequeteContext) LoadSejoursUtilisateur ¶
func (ct RequeteContext) LoadSejoursUtilisateur() (out Sejours, err error)
func (RequeteContext) ProposeLienIngredientLivraison ¶
func (ct RequeteContext) ProposeLienIngredientLivraison(params InAssocieIngredients) (LivraisonsPossibles, error)
ProposeLienIngredientLivraison renvoie une association possible pour les ingrédients donnés, en général incomplète. Les livraisons sont restreintes au séjour courant. Le client doit la complèter avant d'utiliser `EtablitCommandeSimple`.
func (RequeteContext) ProposeLienIngredientProduit ¶
func (ct RequeteContext) ProposeLienIngredientProduit(params InAssocieIngredients) (ProduitsPossibles, error)
ProposeLienIngredientProduit renvoie une association possible pour les ingrédients donnés, en général incomplète. Le client doit la complèter avant d'utiliser `EtablitCommandeComplete`. Les produits possibles sont restreint au séjour demandé.
func (RequeteContext) RechercheProduit ¶
func (ct RequeteContext) RechercheProduit(search InRechercheProduit) ([]models.Produit, error)
RechercheProduit effectue une recherche par chaine dans l'ensemble des produits accessibles à l'utilisateur courant, par pertinence. Pour des raisons de performances, le nombre de résultats renvoyé est limité.
func (RequeteContext) SetDefautProduit ¶
func (ct RequeteContext) SetDefautProduit(idIngredient int64, idProduit int64, on bool) error
SetDefautProduit met à jour le produit par défaut pour l'ingrédient donné `GetIngredientProduits` devrait être appelé ensuite.
func (RequeteContext) UpdateFournisseur ¶
func (ct RequeteContext) UpdateFournisseur(fournisseur models.Fournisseur) (models.Fournisseur, error)
func (RequeteContext) UpdateGroupe ¶
func (RequeteContext) UpdateIngredient ¶
func (ct RequeteContext) UpdateIngredient(ig models.Ingredient) (models.Ingredient, error)
func (RequeteContext) UpdateLivraison ¶
func (RequeteContext) UpdateManyRepas ¶
func (ct RequeteContext) UpdateManyRepas(repass []RepasComplet) error
func (RequeteContext) UpdateMenu ¶
func (ct RequeteContext) UpdateMenu(in MenuComplet) (MenuComplet, error)
func (RequeteContext) UpdateProduit ¶
UpdateProduit modifie un produit, sous réserve qu'il ne soit pas encore utilisé dans une commande.
func (RequeteContext) UpdateRecette ¶
func (ct RequeteContext) UpdateRecette(in RecetteComplet) (RecetteComplet, error)
func (RequeteContext) UpdateSejour ¶
func (RequeteContext) UpdateSejourFournisseurs ¶
func (ct RequeteContext) UpdateSejourFournisseurs(idSejour int64, idsFournisseurs []int64) error
type SejourRepas ¶
type SejourRepas struct {
models.Sejour
Fournisseurs []models.SejourFournisseur `json:"fournisseurs"`
Repass []RepasComplet `json:"repass"`
}
type Sejours ¶
type Sejours struct {
Sejours map[int64]SejourRepas `json:"sejours"`
Groupes models.Groupes `json:"groupes"`
}
Sejours contient les séjours, ainsi que les groupes et repas associés.
type Server ¶
Server est le controller principal, partagé par toutes les requêtes.
func (Server) GetDevToken ¶
GetDevToken choisit un utilisateur au hasard et renvoie un token de connection
func (Server) JWTMiddleware ¶
func (s Server) JWTMiddleware() echo.MiddlewareFunc
func (Server) LoadIngredients ¶
func (s Server) LoadIngredients() (models.Ingredients, error)
func (Server) LoadRecettes ¶
func (s Server) LoadRecettes() (out map[int64]*RecetteComplet, err error)
------------------------------------------------------------------------ ------------------------ Recettes -------------------------------------- ------------------------------------------------------------------------
func (Server) LoadUtilisateurs ¶
func (s Server) LoadUtilisateurs() (map[int64]Utilisateur, error)
LoadUtilisateurs renvois les données publiques des utilisateurs enregistrés.
func (Server) NewRequeteContext ¶
func (s Server) NewRequeteContext(c echo.Context) RequeteContext
NewRequeteContext attend une requête authentifiée par JWT
func (Server) ResoudIngredientsJournees ¶
func (s Server) ResoudIngredientsJournees(idSejour int64, journeesOffsets []int64) ([]DateIngredientQuantites, error)
ResoudIngredientsJournees renvoies le total des ingrédients. Si `journeesOffsets` vaut nil, tout le séjour est utilisé.
func (Server) ResoudIngredientsRepas ¶
func (s Server) ResoudIngredientsRepas(idRepas, nbPersonnes int64) ([]IngredientQuantite, error)
type TimedIngredientQuantite ¶
type TimedIngredientQuantite struct {
IngredientQuantite
Date time.Time `json:"date"`
}
TimedIngredientQuantite ajoute la date de demande de l'ingrédient
type UserMeta ¶
type UserMeta struct {
IdProprietaire int64
jwt.StandardClaims
}
UserMeta are custom claims extending default ones.