Documentation
¶
Index ¶
- Constants
- func AutoMigrate()
- func GetDB() *gorm.DB
- func GetSetting(code string) string
- func SeedDB()
- func SetDB(connection string)
- type Category
- type Error
- type Image
- type Login
- type Manage
- type Menu
- type MenuItem
- type Model
- type Order
- type OrderConsult
- type Page
- type Product
- type Register
- type Setting
- type Slide
- type User
Constants ¶
const ADMIN = "admin"
ADMIN is an admin role name
const ANONYMOUS = "anonymous"
ANONYMOUS is an anonymous role name
const CUSTOMER = "customer"
CUSTOMER is a customer role name
const MANAGER = "manager"
MANAGER is a manager role name
Variables ¶
This section is empty.
Functions ¶
func GetSetting ¶
GetSetting returns a site setting by its code, empty string otherwise
Types ¶
type Category ¶
type Category struct { Model Title string `form:"title"` Slug string `form:"slug"` Excerpt string `form:"excerpt"` Description string `form:"description"` MetaKeywords string `form:"meta_keywords"` MetaDescription string `form:"meta_description"` Published bool `form:"published"` ParentID *uint64 `form:"parent_id"` Products []Product Class string `form:"class"` Ord int `form:"ord"` Children []Category `gorm:"foreignkey:ParentID"` }
Category type contains product category info
type Image ¶
type Image struct { Model URL string `form:"url"` ProductID uint64 `form:"product_id"` Hash string `gorm:"-" form:"-"` Product Product `gorm:"save_associations:false" binding:"-" form:"-"` }
Image type contains image info
type Login ¶
type Login struct { Email string `form:"email" binding:"required"` Password string `form:"password" binding:"required"` }
Login view model
type Manage ¶
type Manage struct { FirstName string `form:"first_name" binding:"required"` MiddleName string `form:"middle_name" binding:"required"` LastName string `form:"last_name" binding:"required"` Email string `binding:"-"` Password string `form:"password" binding:"required"` PasswordConfirm string `form:"password_confirm" binding:"required"` }
Manage user view model
type Menu ¶
type Menu struct { Model Code string `form:"code" binding:"required"` Title string `form:"title" binding:"required"` Items []MenuItem }
Menu type contains menu info
type MenuItem ¶
type MenuItem struct { Model Title string `form:"title" binding:"required"` URL string `form:"url"` Ord int `form:"ord"` ParentID *uint64 `form:"parent_id"` Class string `form:"class"` MenuID uint64 `form:"menu_id" binding:"required"` Children []MenuItem `gorm:"foreignkey:ParentID"` }
MenuItem type contains menu item info
type Model ¶
type Model struct { ID uint64 `form:"id" gorm:"primary_key"` CreatedAt time.Time `binding:"-" form:"-"` UpdatedAt time.Time `binding:"-" form:"-"` DeletedAt *time.Time `binding:"-" form:"-"` }
Model is a tuned version of gorm.Model
type Order ¶
type Order struct { Model FirstName string `form:"first_name"` MiddleName string `form:"middle_name"` LastName string `form:"last_name"` Email string `form:"email"` Phone string `form:"phone"` Comment string `form:"comment"` Products []Product `gorm:"many2many:order_products;save_associations:false" binding:"-" form:"-"` }
Order type contains buy order info
type OrderConsult ¶
OrderConsult type contains consult order info
type Page ¶
type Page struct { Model Title string `form:"title"` Description string `form:"description"` Slug string `form:"slug"` Published bool `form:"published"` MetaKeywords string `form:"meta_keywords"` MetaDescription string `form:"meta_description"` }
Page type contains page info
type Product ¶
type Product struct { Model Title string `form:"title"` Description string `form:"description"` MetaKeywords string `form:"meta_keywords"` MetaDescription string `form:"meta_description"` CategoryID uint64 `form:"category_id"` Published bool `form:"published"` Slug string `form:"slug"` Category Category `gorm:"save_associations:false" binding:"-" form:"-"` ImageIds []uint64 `form:"imageids" gorm:"-"` //hack DefaultImageID uint64 `form:"defaultimageid"` Recommended bool `form:"recommended"` Images []Image Orders []Order `gorm:"save_associations:false" binding:"-" form:"-"` }
Product type contains product info
func (*Product) DefaultImage ¶
DefaultImage returns url of the default product img
type Register ¶
type Register struct { FirstName string `form:"first_name" binding:"required"` MiddleName string `form:"middle_name" binding:"required"` LastName string `form:"last_name" binding:"required"` Email string `form:"email" binding:"required"` Password string `form:"password" binding:"required"` PasswordConfirm string `form:"password_confirm" binding:"required"` }
Register view model
type Setting ¶
type Setting struct { Model Code string `binding:"required" form:"code"` Title string `form:"title"` Value string `form:"value"` }
Setting type contains settings info
type Slide ¶
type Slide struct { Model Title string `form:"title" binding:"required"` Content string `form:"content"` FileURL string `form:"file_url"` Ord int `form:"ord"` }
Slide type contains carousel slide info
type User ¶
type User struct { Model Email string `form:"email" binding:"required"` FirstName string `form:"first_name"` MiddleName string `form:"middle_name"` LastName string `form:"last_name"` Password string `form:"password" binding:"required"` Role string `form:"role" binding:"required"` }
User type contains user info