Files
sale/backend/internal/models/category.go
T
admin b26fea9621
Build and Push Docker Image / build-and-push (push) Successful in 1m0s
Build and Push Docker Image / deploy (push) Successful in 8s
Docker Build / Build and Push Docker Image (push) Has been cancelled
Docker Build / Deploy to Server (push) Has been cancelled
feat: 分类管理添加是否可跨分类购物选项
2026-07-05 20:18:27 +08:00

32 lines
1.2 KiB
Go

package models
import (
"time"
"gorm.io/gorm"
)
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"`
}
func (Category) TableName() string {
return "categories"
}