Documentation ¶
Index ¶
- Constants
- Variables
- type Dress
- type Food
- type Info
- type NewDress
- type NewFood
- type NewSoftware
- type Product
- func (p Product) CreateDress(ctx context.Context, seller string, nd NewDress, date time.Time) (Info, error)
- func (p Product) CreateFood(ctx context.Context, seller string, nf NewFood, date time.Time) (Info, error)
- func (p Product) CreateSoftware(ctx context.Context, seller string, ns NewSoftware, date time.Time) (Info, error)
- func (p Product) QueryByID(ctx context.Context, id string) (Info, error)
- func (p Product) QueryDressByID(ctx context.Context, id string) (Dress, error)
- func (p Product) QueryFoodByID(ctx context.Context, id string) (Food, error)
- func (p Product) QuerySoftwareByID(ctx context.Context, id string) (Software, error)
- func (p Product) QuerySoftwareByIDs(ctx context.Context, ids []string) ([]Software, error)
- type Software
- type TypeEnum
Constants ¶
View Source
const (
Collection = "products"
)
Variables ¶
View Source
var ( ErrNotFound = errors.New("not found") ErrInvalidID = errors.New("invalid id") )
Functions ¶
This section is empty.
Types ¶
type Dress ¶
type Dress struct { ID primitive.ObjectID `bson:"_id,omitempty" json:"id"` Seller string `bson:"seller,omitempty" json:"seller"` Title string `bson:"title,omitempty" json:"title"` Type TypeEnum `bson:"type" json:"type"` Price primitive.Decimal128 `bson:"price,omitempty" json:"price"` Currency string `bson:"currency,omitempty" json:"currency"` Description string `bson:"description,omitempty" json:"description"` SKU string `bson:"sku,omitempty" json:"sku"` Stock int `bson:"stock,omitempty" json:"stock"` Sizes []string `bson:"sizes,omitempty" json:"sizes"` Colors []string `bson:"colors,omitempty" json:"colors"` CreatedAt time.Time `bson:"created_at,omitempty" json:"created_at"` }
type Food ¶
type Food struct { ID primitive.ObjectID `bson:"_id,omitempty" json:"id"` Seller string `bson:"seller,omitempty" json:"seller"` Title string `bson:"title,omitempty" json:"title"` Type TypeEnum `bson:"type" json:"type"` Price primitive.Decimal128 `bson:"price,omitempty" json:"price"` Currency string `bson:"currency,omitempty" json:"currency"` Description string `bson:"description,omitempty" json:"description"` SKU string `bson:"sku,omitempty" json:"sku"` Stock int `bson:"stock,omitempty" json:"stock"` ExpireAt time.Time `bson:"expire_at,omitempty" json:"expire_at"` CreatedAt time.Time `bson:"created_at,omitempty" json:"created_at"` }
type Info ¶
type Info struct { ID primitive.ObjectID `bson:"_id,omitempty" json:"id"` Seller string `bson:"seller,omitempty" json:"seller"` Title string `bson:"title,omitempty" json:"title"` Type TypeEnum `bson:"type" json:"type"` Price primitive.Decimal128 `bson:"price,omitempty" json:"price"` Currency string `bson:"currency,omitempty" json:"currency"` Description string `bson:"description,omitempty" json:"description"` SKU string `bson:"sku,omitempty" json:"sku"` Stock int `bson:"stock,omitempty" json:"stock"` Sizes []string `bson:"sizes,omitempty" json:"sizes"` Colors []string `bson:"colors,omitempty" json:"colors"` License string `bson:"license,omitempty" json:"license"` Code string `bson:"code,omitempty" json:"code"` ExpireAt time.Time `bson:"expire_at,omitempty" json:"expire_at"` CreatedAt time.Time `bson:"created_at,omitempty" json:"created_at"` }
Info represent a individual product information.
type NewDress ¶
type NewDress struct { Title string `json:"title" validate:"required"` Price string `json:"price" validate:"required"` Currency string `json:"currency" validate:"required"` Description string `json:"description"` SKU string `json:"sku"` Stock int `json:"stock"` Sizes []string `json:"sizes"` Colors []string `json:"colors"` }
type NewFood ¶
type NewFood struct { Title string `json:"title" validate:"required"` Price string `json:"price" validate:"required"` Currency string `json:"currency" validate:"required"` Description string `json:"description"` SKU string `json:"sku"` Stock int `json:"stock"` ExpireAt time.Time `json:"expire_at"` }
type NewSoftware ¶
type NewSoftware struct { Title string `json:"title" validate:"required"` Price float64 `json:"price" validate:"required"` Currency string `json:"currency" validate:"required"` Description string `json:"description"` SKU string `json:"sku"` Stock int `json:"stock"` License string `json:"license"` Code string `json:"code"` }
type Product ¶
type Product struct {
// contains filtered or unexported fields
}
Product manage set of API's for product access.
func (Product) CreateDress ¶
func (p Product) CreateDress(ctx context.Context, seller string, nd NewDress, date time.Time) (Info, error)
CreateDress inserts a new product dress into the database.
func (Product) CreateFood ¶
func (p Product) CreateFood(ctx context.Context, seller string, nf NewFood, date time.Time) (Info, error)
CreateFood inserts a new product food into the database.
func (Product) CreateSoftware ¶
func (p Product) CreateSoftware(ctx context.Context, seller string, ns NewSoftware, date time.Time) (Info, error)
CreateSoftware inserts a new product software into the database.
func (Product) QueryDressByID ¶
func (Product) QueryFoodByID ¶
func (Product) QuerySoftwareByID ¶
type Software ¶
type Software struct { ID primitive.ObjectID `bson:"_id,omitempty" json:"id"` Seller string `bson:"seller,omitempty" json:"seller"` Title string `bson:"title,omitempty" json:"title"` Type TypeEnum `bson:"type" json:"type"` Price primitive.Decimal128 `bson:"price,omitempty" json:"price"` Currency string `bson:"currency,omitempty" json:"currency"` Description string `bson:"description,omitempty" json:"description"` SKU string `bson:"sku,omitempty" json:"sku"` Stock int `bson:"stock,omitempty" json:"stock"` License string `bson:"license,omitempty" json:"license"` Code string `bson:"code,omitempty" json:"code"` CreatedAt time.Time `bson:"created_at,omitempty" json:"created_at"` }
Click to show internal directories.
Click to hide internal directories.