Documentation ¶
Overview ¶
Package category is a default implementation of interfaces declared in "github.com/ottemo/commerce/app/models/category" package
Index ¶
- Constants
- func APIAddMediaForCategory(context api.InterfaceApplicationContext) (interface{}, error)
- func APIAddProductToCategory(context api.InterfaceApplicationContext) (interface{}, error)
- func APICreateCategory(context api.InterfaceApplicationContext) (interface{}, error)
- func APIDeleteCategory(context api.InterfaceApplicationContext) (interface{}, error)
- func APIGetCategoriesTree(context api.InterfaceApplicationContext) (interface{}, error)
- func APIGetCategory(context api.InterfaceApplicationContext) (interface{}, error)
- func APIGetCategoryAttributes(context api.InterfaceApplicationContext) (interface{}, error)
- func APIGetCategoryLayers(context api.InterfaceApplicationContext) (interface{}, error)
- func APIGetCategoryProducts(context api.InterfaceApplicationContext) (interface{}, error)
- func APIGetMedia(context api.InterfaceApplicationContext) (interface{}, error)
- func APIGetMediaPath(context api.InterfaceApplicationContext) (interface{}, error)
- func APIListCategories(context api.InterfaceApplicationContext) (interface{}, error)
- func APIListMedia(context api.InterfaceApplicationContext) (interface{}, error)
- func APIRemoveMediaForCategory(context api.InterfaceApplicationContext) (interface{}, error)
- func APIRemoveProductFromCategory(context api.InterfaceApplicationContext) (interface{}, error)
- func APIUpdateCategory(context api.InterfaceApplicationContext) (interface{}, error)
- type DefaultCategory
- func (it *DefaultCategory) AddMedia(mediaType string, mediaName string, content []byte) error
- func (it *DefaultCategory) AddProduct(productID string) error
- func (it *DefaultCategory) Delete() error
- func (it *DefaultCategory) FromHashMap(input map[string]interface{}) error
- func (it *DefaultCategory) Get(attribute string) interface{}
- func (it *DefaultCategory) GetAttributesInfo() []models.StructAttributeInfo
- func (it *DefaultCategory) GetCollection() models.InterfaceCollection
- func (it *DefaultCategory) GetDescription() string
- func (it *DefaultCategory) GetEnabled() bool
- func (it *DefaultCategory) GetID() string
- func (it *DefaultCategory) GetImage() string
- func (it *DefaultCategory) GetImplementationName() string
- func (it *DefaultCategory) GetMedia(mediaType string, mediaName string) ([]byte, error)
- func (it *DefaultCategory) GetMediaPath(mediaType string) (string, error)
- func (it *DefaultCategory) GetModelName() string
- func (it *DefaultCategory) GetName() string
- func (it *DefaultCategory) GetParent() category.InterfaceCategory
- func (it *DefaultCategory) GetProductIds() []string
- func (it *DefaultCategory) GetProducts() []product.InterfaceProduct
- func (it *DefaultCategory) GetProductsCollection() product.InterfaceProductCollection
- func (it *DefaultCategory) ListMedia(mediaType string) ([]string, error)
- func (it *DefaultCategory) Load(ID string) error
- func (it *DefaultCategory) New() (models.InterfaceModel, error)
- func (it *DefaultCategory) RemoveMedia(mediaType string, mediaName string) error
- func (it *DefaultCategory) RemoveProduct(productID string) error
- func (it *DefaultCategory) Save() error
- func (it *DefaultCategory) Set(attribute string, value interface{}) error
- func (it *DefaultCategory) SetID(NewID string) error
- func (it *DefaultCategory) ToHashMap() map[string]interface{}
- type DefaultCategoryCollection
- func (it *DefaultCategoryCollection) GetDBCollection() db.InterfaceDBCollection
- func (it *DefaultCategoryCollection) GetImplementationName() string
- func (it *DefaultCategoryCollection) GetModelName() string
- func (it *DefaultCategoryCollection) List() ([]models.StructListItem, error)
- func (it *DefaultCategoryCollection) ListAddExtraAttribute(attribute string) error
- func (it *DefaultCategoryCollection) ListCategories() []category.InterfaceCategory
- func (it *DefaultCategoryCollection) ListFilterAdd(Attribute string, Operator string, Value interface{}) error
- func (it *DefaultCategoryCollection) ListFilterReset() error
- func (it *DefaultCategoryCollection) ListLimit(offset int, limit int) error
- func (it *DefaultCategoryCollection) New() (models.InterfaceModel, error)
Constants ¶
const ( ConstCollectionNameCategory = "category" ConstCollectionNameCategoryProductJunction = "category_product" ConstErrorModule = "category" ConstErrorLevel = env.ConstErrorLevelActor ConstCategoryMediaTypeImage = "image" )
Package global constants
Variables ¶
This section is empty.
Functions ¶
func APIAddMediaForCategory ¶
func APIAddMediaForCategory(context api.InterfaceApplicationContext) (interface{}, error)
APIAddMediaForCategory uploads and assigns media file send in request for a specified category
- category id, media type and media name should be specified in "categoryID", "mediaType" and "mediaName" arguments
- media file should be provided in "file" field
func APIAddProductToCategory ¶
func APIAddProductToCategory(context api.InterfaceApplicationContext) (interface{}, error)
APIAddProductToCategory adds product to category
- category id and product id should be specified in "categoryID" and "productID" arguments
func APICreateCategory ¶
func APICreateCategory(context api.InterfaceApplicationContext) (interface{}, error)
APICreateCategory creates a new category
- category attributes must be provided in request content
- "name" attribute required
func APIDeleteCategory ¶
func APIDeleteCategory(context api.InterfaceApplicationContext) (interface{}, error)
APIDeleteCategory deletes existing category
- category id should be specified in "categoryID" argument
func APIGetCategoriesTree ¶
func APIGetCategoriesTree(context api.InterfaceApplicationContext) (interface{}, error)
APIGetCategoriesTree returns categories parent/child relation map
func APIGetCategory ¶
func APIGetCategory(context api.InterfaceApplicationContext) (interface{}, error)
APIGetCategory return specified category information
- category id should be specified in "categoryID" argument
func APIGetCategoryAttributes ¶
func APIGetCategoryAttributes(context api.InterfaceApplicationContext) (interface{}, error)
APIGetCategoryAttributes returns a list of category attributes
func APIGetCategoryLayers ¶
func APIGetCategoryLayers(context api.InterfaceApplicationContext) (interface{}, error)
APIGetCategoryLayers enumerates category attributes and their possible values which is used for layered navigation
- category id should be specified in "id" argument
func APIGetCategoryProducts ¶
func APIGetCategoryProducts(context api.InterfaceApplicationContext) (interface{}, error)
APIGetCategoryProducts returns category related products
- category id should be specified in "categoryID" argument
func APIGetMedia ¶
func APIGetMedia(context api.InterfaceApplicationContext) (interface{}, error)
APIGetMedia returns media contents for a category (file assigned to a category)
- category id, media type and media name must be specified in "categoryID", "mediaType" and "mediaName" arguments
- on success case not a JSON data returns, but media file
func APIGetMediaPath ¶
func APIGetMediaPath(context api.InterfaceApplicationContext) (interface{}, error)
APIGetMediaPath returns relative path to category media files within media library
- category id, media type must be specified in "categoryID" and "mediaType" arguments
func APIListCategories ¶
func APIListCategories(context api.InterfaceApplicationContext) (interface{}, error)
APIListCategories returns a list of available categories
- if "action" parameter is set to "count" result value will be just a number of list items
- for a not admins available categories are limited to enabled ones
func APIListMedia ¶
func APIListMedia(context api.InterfaceApplicationContext) (interface{}, error)
APIListMedia returns lost of media files assigned to specified category
- category id, media type must be specified in "categoryID" and "mediaType" arguments
func APIRemoveMediaForCategory ¶
func APIRemoveMediaForCategory(context api.InterfaceApplicationContext) (interface{}, error)
APIRemoveMediaForCategory removes media content from specified category
- category id, media type and media name should be specified in "categoryID", "mediaType" and "mediaName" arguments
func APIRemoveProductFromCategory ¶
func APIRemoveProductFromCategory(context api.InterfaceApplicationContext) (interface{}, error)
APIRemoveProductFromCategory removes product from category
- category id and product id should be specified in "categoryID" and "productID" arguments
func APIUpdateCategory ¶
func APIUpdateCategory(context api.InterfaceApplicationContext) (interface{}, error)
APIUpdateCategory modifies existing category
- category id must be specified as "id" argument
- category attributes must be specified in content
Types ¶
type DefaultCategory ¶
type DefaultCategory struct { Enabled bool Name string Description string Image string Parent category.InterfaceCategory Path string ProductIds []string // contains filtered or unexported fields }
DefaultCategory is a default implementer of InterfaceCategory
func (*DefaultCategory) AddMedia ¶
func (it *DefaultCategory) AddMedia(mediaType string, mediaName string, content []byte) error
AddMedia adds new media assigned to category
func (*DefaultCategory) AddProduct ¶
func (it *DefaultCategory) AddProduct(productID string) error
AddProduct associates given product with category
func (*DefaultCategory) Delete ¶
func (it *DefaultCategory) Delete() error
Delete removes current object from database storage
func (*DefaultCategory) FromHashMap ¶
func (it *DefaultCategory) FromHashMap(input map[string]interface{}) error
FromHashMap fills object attributes from map[string]interface{}
func (*DefaultCategory) Get ¶
func (it *DefaultCategory) Get(attribute string) interface{}
Get returns object attribute value or nil
func (*DefaultCategory) GetAttributesInfo ¶
func (it *DefaultCategory) GetAttributesInfo() []models.StructAttributeInfo
GetAttributesInfo returns information about object attributes
func (*DefaultCategory) GetCollection ¶
func (it *DefaultCategory) GetCollection() models.InterfaceCollection
GetCollection returns collection of current instance type
func (*DefaultCategory) GetDescription ¶
func (it *DefaultCategory) GetDescription() string
GetDescription returns the description of the requested category
func (*DefaultCategory) GetEnabled ¶
func (it *DefaultCategory) GetEnabled() bool
GetEnabled returns enabled flag for the current category
func (*DefaultCategory) GetID ¶
func (it *DefaultCategory) GetID() string
GetID returns database storage id of current object
func (*DefaultCategory) GetImage ¶
func (it *DefaultCategory) GetImage() string
GetImage returns the image of the requested category
func (*DefaultCategory) GetImplementationName ¶
func (it *DefaultCategory) GetImplementationName() string
GetImplementationName returns model implementation name
func (*DefaultCategory) GetMedia ¶
func (it *DefaultCategory) GetMedia(mediaType string, mediaName string) ([]byte, error)
GetMedia returns content of media assigned to category
func (*DefaultCategory) GetMediaPath ¶
func (it *DefaultCategory) GetMediaPath(mediaType string) (string, error)
GetMediaPath returns relative location of media assigned to category in media storage
func (*DefaultCategory) GetModelName ¶
func (it *DefaultCategory) GetModelName() string
GetModelName returns model name
func (*DefaultCategory) GetName ¶
func (it *DefaultCategory) GetName() string
GetName returns current category name
func (*DefaultCategory) GetParent ¶
func (it *DefaultCategory) GetParent() category.InterfaceCategory
GetParent returns parent category of nil
func (*DefaultCategory) GetProductIds ¶
func (it *DefaultCategory) GetProductIds() []string
GetProductIds returns product ids associated to category
func (*DefaultCategory) GetProducts ¶
func (it *DefaultCategory) GetProducts() []product.InterfaceProduct
GetProducts returns a set of category associated products
func (*DefaultCategory) GetProductsCollection ¶
func (it *DefaultCategory) GetProductsCollection() product.InterfaceProductCollection
GetProductsCollection returns category associated products collection instance
func (*DefaultCategory) ListMedia ¶
func (it *DefaultCategory) ListMedia(mediaType string) ([]string, error)
ListMedia lists media assigned to category
func (*DefaultCategory) Load ¶
func (it *DefaultCategory) Load(ID string) error
Load loads object information from database storage
func (*DefaultCategory) New ¶
func (it *DefaultCategory) New() (models.InterfaceModel, error)
New returns new instance of model implementation object
func (*DefaultCategory) RemoveMedia ¶
func (it *DefaultCategory) RemoveMedia(mediaType string, mediaName string) error
RemoveMedia removes media assigned to category
func (*DefaultCategory) RemoveProduct ¶
func (it *DefaultCategory) RemoveProduct(productID string) error
RemoveProduct un-associates given product with category
func (*DefaultCategory) Save ¶
func (it *DefaultCategory) Save() error
Save stores current object to database storage
func (*DefaultCategory) Set ¶
func (it *DefaultCategory) Set(attribute string, value interface{}) error
Set sets attribute value to object or returns error
func (*DefaultCategory) SetID ¶
func (it *DefaultCategory) SetID(NewID string) error
SetID sets database storage id for current object
func (*DefaultCategory) ToHashMap ¶
func (it *DefaultCategory) ToHashMap() map[string]interface{}
ToHashMap represents object as map[string]interface{}
type DefaultCategoryCollection ¶
type DefaultCategoryCollection struct {
// contains filtered or unexported fields
}
DefaultCategoryCollection is a default implementer of InterfaceCategoryCollection
func (*DefaultCategoryCollection) GetDBCollection ¶
func (it *DefaultCategoryCollection) GetDBCollection() db.InterfaceDBCollection
GetDBCollection returns database collection
func (*DefaultCategoryCollection) GetImplementationName ¶
func (it *DefaultCategoryCollection) GetImplementationName() string
GetImplementationName returns model implementation name
func (*DefaultCategoryCollection) GetModelName ¶
func (it *DefaultCategoryCollection) GetModelName() string
GetModelName returns model name
func (*DefaultCategoryCollection) List ¶
func (it *DefaultCategoryCollection) List() ([]models.StructListItem, error)
List enumerates items of model type
func (*DefaultCategoryCollection) ListAddExtraAttribute ¶
func (it *DefaultCategoryCollection) ListAddExtraAttribute(attribute string) error
ListAddExtraAttribute allows to obtain additional attributes from List() function
func (*DefaultCategoryCollection) ListCategories ¶
func (it *DefaultCategoryCollection) ListCategories() []category.InterfaceCategory
ListCategories returns list of category model items
func (*DefaultCategoryCollection) ListFilterAdd ¶
func (it *DefaultCategoryCollection) ListFilterAdd(Attribute string, Operator string, Value interface{}) error
ListFilterAdd adds selection filter to List() function
func (*DefaultCategoryCollection) ListFilterReset ¶
func (it *DefaultCategoryCollection) ListFilterReset() error
ListFilterReset clears presets made by ListFilterAdd() and ListAddExtraAttribute() functions
func (*DefaultCategoryCollection) ListLimit ¶
func (it *DefaultCategoryCollection) ListLimit(offset int, limit int) error
ListLimit specifies selection paging
func (*DefaultCategoryCollection) New ¶
func (it *DefaultCategoryCollection) New() (models.InterfaceModel, error)
New returns new instance of model implementation object