feat: 添加购买分组功能,替代跨分类购物选项
This commit is contained in:
@@ -7,23 +7,24 @@ import (
|
||||
)
|
||||
|
||||
type Category struct {
|
||||
ID uint `gorm:"primaryKey" json:"id"`
|
||||
Name string `gorm:"size:100;not null;uniqueIndex" json:"name"`
|
||||
Description string `json:"description"`
|
||||
ParentID *uint `json:"parent_id"`
|
||||
MinAmount *float64 `json:"min_amount"`
|
||||
MaxAmount *float64 `json:"max_amount"`
|
||||
MinQuantity *int `json:"min_quantity"`
|
||||
MaxQuantity *int `json:"max_quantity"`
|
||||
MinWeight *float64 `json:"min_weight"`
|
||||
MaxWeight *float64 `json:"max_weight"`
|
||||
AllowCrossCategory bool `gorm:"default:false" json:"allow_cross_category"`
|
||||
SortOrder int `gorm:"default:0" json:"sort_order"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
|
||||
ProductCount int64 `gorm:"-" json:"product_count"`
|
||||
Children []Category `gorm:"foreignKey:ParentID" json:"children,omitempty"`
|
||||
ID uint `gorm:"primaryKey" json:"id"`
|
||||
Name string `gorm:"size:100;not null;uniqueIndex" json:"name"`
|
||||
Description string `json:"description"`
|
||||
ParentID *uint `json:"parent_id"`
|
||||
PurchaseGroupID *uint `json:"purchase_group_id"`
|
||||
PurchaseGroup *PurchaseGroup `gorm:"foreignKey:PurchaseGroupID" json:"purchase_group,omitempty"`
|
||||
MinAmount *float64 `json:"min_amount"`
|
||||
MaxAmount *float64 `json:"max_amount"`
|
||||
MinQuantity *int `json:"min_quantity"`
|
||||
MaxQuantity *int `json:"max_quantity"`
|
||||
MinWeight *float64 `json:"min_weight"`
|
||||
MaxWeight *float64 `json:"max_weight"`
|
||||
SortOrder int `gorm:"default:0" json:"sort_order"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
|
||||
ProductCount int64 `gorm:"-" json:"product_count"`
|
||||
Children []Category `gorm:"foreignKey:ParentID" json:"children,omitempty"`
|
||||
}
|
||||
|
||||
func (Category) TableName() string {
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type PurchaseGroup struct {
|
||||
ID uint `gorm:"primaryKey" json:"id"`
|
||||
Name string `gorm:"size:100;not null;uniqueIndex" json:"name"`
|
||||
Description string `json:"description"`
|
||||
SortOrder int `gorm:"default:0" json:"sort_order"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
|
||||
Categories []Category `gorm:"foreignKey:PurchaseGroupID" json:"categories,omitempty"`
|
||||
}
|
||||
|
||||
func (PurchaseGroup) TableName() string {
|
||||
return "purchase_groups"
|
||||
}
|
||||
Reference in New Issue
Block a user