package model import ( "bkb-seller/global" "gorm.io/gorm" ) type TbCategory struct { //商品分类 global.MG_MODEL Name string `gorm:"type:varchar(100);not null;comment:商品分类名称" json:"name"` //名称 Pid uint `gorm:"type:int(11);comment:父id" json:"pid"` //父id Layer int `gorm:"type:int(1)" json:"layer"` //层数 IsLeaf bool `gorm:"type:tinyint(1)" json:"is_leaf"` //是否叶子分类 Status int `gorm:"type:tinyint(1);comment:状态 1:正常" json:"status"` //状态 } type TbCategoryTree struct { ID uint `json:"id"` // DeletedAt gorm.DeletedAt `json:"-"` // 删除时间 Layer int `json:"-"` // Name string `json:"name"` //名称 Pid uint `json:"pid"` //父id IsLeaf bool `json:"is_leaf"` //是否叶子分类 Children []*TbCategoryTree `gorm:"-" json:"children"` //子节点 } func (TbCategory) TableName() string { return "tb_category" } func (TbCategoryTree) TableName() string { return "tb_category" } type CategoryParentTree struct { TbCategory Parent *CategoryParentTree `json:"-"` //父节点 }