structures

package
v0.0.0-...-3de62b2 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2020 License: GPL-3.0 Imports: 1 Imported by: 1

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func MergeFloat

func MergeFloat(f1, f2 float64) float64

MergeFloat put the content of f2 in f1 if f1 is empty

func MergeInt

func MergeInt(i1, i2 int) int

MergeInt put the content of i2 in i1 if i1 is empty

func MergeString

func MergeString(s1, s2 string) string

MergeString put the content of i2 in i1 if i1 is empty

func MergeStrings

func MergeStrings(s1, s2 []string) []string

MergeStrings put the content of s2 in s1 if s1 is empty

Types

type Consumable

type Consumable struct {
	// The integer ID used in the firestore.
	ID            int64
	Name          string `json:"name"`
	Company       string `json:"compagny"`
	Manufacturing string `json:"manifacturing"`
	Created       time.Time
	Creator       int64
	NewVersion    int64
	Source        string
	Code          []string `json:"code"`
	Categories    []string `json:"categories"`
	Tags          []string `json:"tags"`
	Packaging     []string `json:"packaging"`
	// Nutrition facts on the consumable
	Fat           float64 `json:"fat"`
	Fiber         float64 `json:"fiber"`
	Glucides      float64 `json:"glucides"`
	Proteins      float64 `json:"proteins"`
	Sodium        float64 `json:"sodium"`
	SaturatedFat  float64 `json:"saturated_fat"`
	SugarGlucides float64 `json:"sugar_glucides"`
	Energy        float64 `json:"energy"`
	Alcool        float64 `json:"alcool"`
	// Health status of the consumable
	Additive   []string `json:"additive"`
	Ingredient []string `json:"ingredient"`
	Vitamins   []string `json:"vitamins"`
	Allergen   []string `json:"allergen"`
	NutriScore string   `json:"nutri_score"`
	// all Pictures needed for the consumable
	Back        string `json:"back"`
	Composition string `json:"composition"`
	Front       string `json:"front"`
	// Quantity of the product in a pack
	Grammes int `json:"grammes"`
	MLitre  int `json:"mililitre"`
	// Quality of the product
	Label []string `json:"label"`
}

Consumable struct used to parse /consumable/...

func MergeConsumable

func MergeConsumable(c1, c2 Consumable) Consumable

MergeConsumable Merge two consumable into one: C2 fill empty fields of C1

type Consumables

type Consumables struct {
	Consumable Consumable `json:"consumable"`
	Store      Store      `json:"store"`
	Stock      Stock      `json:"stock"`
}

Consumables struct used to parse /consumable/...

type ConsumablesID

type ConsumablesID struct {
	ConsumableID int64 `json:"consumable"`
	StoreID      int64 `json:"store"`
	StockID      int64 `json:"stock"`
}

ConsumablesID struct used to get a Consumable

type Email

type Email struct {
	UserMail string `json:"user_email"`
}

Email struct used to parse /verify/email

type List

type List struct {
	ID   int64  `json:"id" firestore:"id"`
	Name string `json:"name" firestore:"name"`
}

List content of a list

type ListContent

type ListContent struct {
	ID          int64         // The integer ID used in the firestore.
	ListID      int64         `json:"list_id" firestore:"list_id"`
	Consumables ConsumablesID `json:"consumable" firestore:"consumable"`
	Name        string        `json:"name" firestore:"name"`
	Done        bool          `json:"done" firestore:"done"`
	Erased      bool          `json:"erased" firestore:"erased"`
	// Mode is used to signify the mode of the consumable
	// It's content should be:
	// 	- "sample": for testing purpose
	// 	- "consumable": for a "real" consumable
	// 	- "personnal": for a user imported consmable where only the Name field is
	// used. stock and store are also not used
	Mode string `json:"mode"`
}

ListContent list content

type ListOwner

type ListOwner struct {
	ID     int64  // The integer ID used in the firestore.
	ListID int64  `json:"list_id" firestore:"list_id"`
	Email  string `json:"email" firestore:"email"`
}

ListOwner list reference to know who own the list

type Log

type Log struct {
	Email   string    `firestore:"email"`
	Log     string    `firestore:"log"`
	Created time.Time `firestore:"created"`
	IP      string    `firestore:"ip"`
	Port    string    `firestore:"port"`
	ID      int64     // The integer ID used in the firestore.
}

Log struct used to store Logs in the datastore

type Logging

type Logging struct {
	Log   string `json:"message"`
	Token string `json:"user_token"`
}

Logging struct used to parse /log information

type Login

type Login struct {
	UserMail string `json:"user_email"`
	UserPass string `json:"user_password"`
}

Login struct used to parse /login information

type Password

type Password struct {
	Password string `json:"password"`
}

Password struct used to parse /verify/password

type Query

type Query struct {
	Query     string  `json:"query"`
	Limit     int     `json:"limit"`
	Size      uint64  `json:"size"`
	Latitude  float64 `json:"latitude"`
	Longitude float64 `json:"longitude"`
}

Query used to query certain api to get a personalized result

type Stock

type Stock struct {
	ID            int64 // The integer ID used in the firestore.
	PackQuantity  int   `json:"pack_quantity" firestore:"pack_quantity"`
	NbPacks       int   `json:"nb_packs" firestore:"nb_packs"`
	PackPrice     int   `json:"pack_price" firestore:"pack_price"`
	Available     bool  `json:"available" firestore:"available"`
	StoreKey      int   `json:"store_key" firestore:"store_key"`
	ConsumableKey int   `json:"consumable_key" firestore:"consumable_key"`
	GeoHash       int   `json:"geohash" firestore:"geohash"`
}

Stock Stock of a product in a store

type Store

type Store struct {
	Name       string `json:"name" firestore:"Name"`
	Address    string `json:"address" firestore:"Address"`
	Country    string `json:"country" firestore:"Country"`
	Zip        string `json:"zip" firestore:"Zip"`
	UserRating int    `json:"user_rating" firestore:"created"`
	GeoHash    int    `json:"geohash" firestore:"geohash"`
	// score averall score of the store, used to give a feeback score
	Score int `json:"score" firestore:"score"`
	// scoreNb number of people scoring the store
	ScoreNb int   `json:"score_nb" firestore:"scoreNb"`
	ID      int64 // The integer ID used in the firestore.
}

Store struct used to store store data

func MergeStore

func MergeStore(i1, i2 Store) Store

MergeStore Merge two user into one: i2 fill empty fields of i1

Example
StoreWithMissingInformations := Store{
	Name: "Store Test.",
	ID:   42,
}

SameStoreWithMoreInformations := Store{
	Name:    "The Best Test Store",
	ID:      21,
	Country: "In",
}
NewStore := MergeStore(StoreWithMissingInformations,
	SameStoreWithMoreInformations)

fmt.Println(NewStore.Name)
fmt.Println(NewStore.ID)
fmt.Println(NewStore.Country)
Output:

The Best Test Store
42
In

type User

type User struct {
	Email     string    `firestore:"email"`
	Pass      string    `firestore:"Hashed_password"`
	Created   time.Time `firestore:"created"`
	Validated bool      `firestore:"valid_user"`
	SBio      bool      `firestore:"setting_bio"`
	SVegan    bool      `firestore:"setting_vegan"`
	SHalal    bool      `firestore:"setting_halal"`
	SCasher   bool      `firestore:"setting_casher"`
	SSodium   bool      `firestore:"setting_sodium"`
	SEgg      bool      `firestore:"setting_egg"`
	SPenut    bool      `firestore:"setting_arachide"`
	SCrustace bool      `firestore:"setting_crustace"`
	SGluten   bool      `firestore:"setting_gluten"`
	SDiabetic bool      `firestore:"setting_diabetique"`
	SBoycott  []string  `firestore:"setting_boycott"`
	ID        int64     // The integer ID used in the firestore.
}

User struct used to store information in the datastore

func MergeUser

func MergeUser(i1, i2 User) User

MergeUser Merge two user into one: i2 fill empty fields of i1

Example
UserWithMissingInformations := User{
	Email: "[email protected]",
	ID:    42,
}

SameUserWithMoreInformations := User{
	Pass:      "Pass",
	Created:   time.Now(),
	Validated: true,
	ID:        21,
}
NewUser := MergeUser(UserWithMissingInformations,
	SameUserWithMoreInformations)

fmt.Println(NewUser.Email)
fmt.Println(NewUser.Pass)
fmt.Println(NewUser.Validated)
fmt.Println(NewUser.ID)
Output:

[email protected]
Pass
true
42

Jump to

Keyboard shortcuts

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