Documentation
¶
Overview ¶
Package mysql
Define mysql configuration
Index ¶
- func Connect(instance *DbConfig) (*gorm.DB, error)
- type Commodity
- type CommodityKind
- type DbConfig
- func (db *DbConfig) Build() DbConfig
- func (db *DbConfig) LoadDbConfigFromViper(v *viper.Viper) (string, error)
- func (db *DbConfig) String() string
- func (db *DbConfig) WithDBName(dbname string) *DbConfig
- func (db *DbConfig) WithHost(host string) *DbConfig
- func (db *DbConfig) WithName(name string) *DbConfig
- func (db *DbConfig) WithPassword(password string) *DbConfig
- func (db *DbConfig) WithPort(port int) *DbConfig
- type Order
- type OrderItem
- type RolePermission
- type User
- type UserFavorite
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Commodity ¶
type Commodity struct { gorm.Model Name string Description string Price float64 Owner string Img string }
Commodity 映射商品表
type CommodityKind ¶
type CommodityKind struct { ID uint `gorm:"primaryKey;autoIncrement"` CommodityID uint `gorm:"not null"` Kind string `gorm:"not null"` }
CommodityKind 商品种类表
type DbConfig ¶
type DbConfig struct {
// contains filtered or unexported fields
}
func (*DbConfig) LoadDbConfigFromViper ¶
LoadDbConfigFromViper return a connect string
func (*DbConfig) WithDBName ¶
func (*DbConfig) WithPassword ¶
type Order ¶
type Order struct { OrderID uint `gorm:"primaryKey;autoIncrement"` CustomerID uint `gorm:"not null"` OrderDate time.Time `gorm:"not null"` TotalAmount float64 `gorm:"not null"` Status string `gorm:"type:enum('pending','processing','shipped','completed','cancelled');default:'pending';not null"` PaymentMethod string `gorm:"size:50"` CreatedAt time.Time `gorm:"not null"` UpdatedAt time.Time `gorm:"not null"` DeletedAt gorm.DeletedAt `gorm:"index"` }
Order 映射订单表
type OrderItem ¶
type OrderItem struct { ItemID uint `gorm:"primaryKey;autoIncrement"` OrderId uint `gorm:"not null"` ProductId uint `gorm:"not null"` Quantity uint `gorm:"not null"` Price float64 `gorm:"not null"` Order Order `gorm:"foreignKey:OrderID"` Product Commodity `gorm:"foreignKey:ProductId"` CreatedAt time.Time `gorm:"not null"` UpdatedAt time.Time `gorm:"not null"` DeletedAt gorm.DeletedAt `gorm:"index"` }
OrderItem 订单商品关联表
type RolePermission ¶
type RolePermission struct { ID uint `gorm:"primaryKey;autoIncrement"` Role string `gorm:"not null"` Permission string `gorm:"not null"` }
RolePermission 角色权限关联表
type User ¶
type User struct { gorm.Model Username string `gorm:"not null"` RealName string Password []byte `gorm:"not null"` PhoneNumber string Role string `gorm:"not null"` Status string `gorm:"default:'offline'"` }
User 用户表模型
type UserFavorite ¶
type UserFavorite struct { ID uint `gorm:"primaryKey;autoIncrement"` UserID uint `gorm:"not null"` CommodityID uint `gorm:"not null"` }
UserFavorite 用户收藏商品表
Click to show internal directories.
Click to hide internal directories.