Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DataRequest ¶
type Handler ¶
type Handler interface { // Gets handles a request to get all products Gets(w http.ResponseWriter, r *http.Request) // Get handles a request to get a product Get(w http.ResponseWriter, r *http.Request) // Create handles a request to create a new product Create(w http.ResponseWriter, r *http.Request) // Update handles a request to update a product Update(w http.ResponseWriter, r *http.Request) // Delete handles a request to delete a product Delete(w http.ResponseWriter, r *http.Request) // GetFromStore handles a request to get products from a store using pagination and store id GetFromStore(w http.ResponseWriter, r *http.Request) // CreateOrder handles a request to create a new order CreateOrder(w http.ResponseWriter, r *http.Request) // GetOrders handles a request to get all orders GetOrders(w http.ResponseWriter, r *http.Request) // GetOrder handles a request to get an order GetOrder(w http.ResponseWriter, r *http.Request) }
Handler provides the products handlers
type OrderRequest ¶
type OrderRequest struct {
Data []DataRequest `json:"data"`
}
type OrderResponse ¶
type OrderStatus ¶
type OrderStatus string
const ( OrderStatusPending OrderStatus = "pending" OrderStatusCompleted OrderStatus = "completed" OrderStatusCancelled OrderStatus = "cancelled" OrderStatusReleased OrderStatus = "released" )
type Orders ¶
type Orders struct { gorm.Model ID uuid.UUID `gorm:"primaryKey"` ProductID uuid.UUID `gorm:"not null"` Product Products `gorm:"foreignKey:ProductID"` BuyerID uuid.UUID `gorm:"not null"` Quantity int `gorm:"not null"` Total float64 `gorm:"not null"` Status OrderStatus `gorm:"not null, type:ENUM('pending', 'completed', 'cancelled', 'released'), default:'pending'"` TxHash string }
type Products ¶
type Products struct { gorm.Model ID uuid.UUID `gorm:"primaryKey"` Name string `gorm:"not null"` Price float64 `gorm:"not null"` Unit string `gorm:"not null"` ImageURL string // TODO: Define options for products Description string `gorm:"not null"` StoreID uuid.UUID `gorm:"not null"` Store Stores `gorm:"foreignKey:StoreID"` }
type Service ¶
type Service interface { // GetProducts returns all products GetProducts() ([]Products, error) // GetProduct returns a product by id GetProduct(id string) (*Products, error) // CreateProduct creates a new product CreateProduct(userId string, p *Products) (string, error) // UpdateProduct updates a product UpdateProduct(userId string, id string, p *Products) error // DeleteProduct deletes a product DeleteProduct(userId string, id string) error // GetProductsFromStore returns paginated products from a store GetProductsFromStore(storeId string, cursor string, limit int) ([]Products, error) // CreateOrders returns order_ids for given products CreateOrders(userId string, orders []DataRequest) ([]OrderResponse, error) // GetOrders returns all orders GetOrders(userId string, filter string) ([]Orders, error) // SaveFile saves a file to the object storage SaveFile(file multipart.File, filepath string) (string, error) // GetOrder returns an order by id GetOrder(id string) (*Orders, error) }
Service is the products service interface
Click to show internal directories.
Click to hide internal directories.