| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- package tables
-
- import (
- "time"
-
- "git.x2erp.com/qdy/go-db/sqldef"
- )
-
- func init() {
- sqldef.AddRegistration(func(r *sqldef.Registry) {
- tb := sqldef.NewTable("master_product_dimension", "商品维度表 - 存储商品相关分类标准,如大类、小类、季节、波段、面料等").
- ID("id", 50).NotNull().Comment("主键ID").End().
- String("type", 30).NotNull().Comment("维度类型: category_major(大类)/category_minor(小类)/season(季节)/wave(波段)/fabric(面料)/color_family(色系)/size_group(尺码组)").End().
- String("code", 50).NotNull().Comment("编码").End().
- String("name", 100).NotNull().Comment("名称").End().
- String("description", 500).Comment("描述").End().
- Int("sort_order").Comment("显示次序").End().
- DateTime("created_at").NotNull().Default("CURRENT_TIMESTAMP").Comment("创建时间").End().
- DateTime("updated_at").NotNull().Default("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP").Comment("更新时间").End()
-
- tb.AddIndex("idx_type", "type")
- tb.AddIndex("idx_code", "code")
- tb.AddIndex("idx_sort_order", "sort_order")
- tb.AddUniqueIndex("uk_type_code", "type", "code")
-
- r.RegisterTable(tb.Build())
- })
- }
-
- type MasterProductDimension struct {
- ID string `gorm:"column:id;type:varchar(50);not null;primaryKey;comment:主键ID"`
- Type string `gorm:"column:type;type:varchar(30);not null;comment:维度类型: category_major(大类)/category_minor(小类)/season(季节)/wave(波段)/fabric(面料)/color_family(色系)/size_group(尺码组)"`
- Code string `gorm:"column:code;type:varchar(50);not null;comment:编码"`
- Name string `gorm:"column:name;type:varchar(100);not null;comment:名称"`
- Description string `gorm:"column:description;type:varchar(500);comment:描述"`
- SortOrder int32 `gorm:"column:sort_order;type:int;comment:显示次序"`
- CreatedAt time.Time `gorm:"column:created_at;not null;default:CURRENT_TIMESTAMP;comment:创建时间"`
- UpdatedAt time.Time `gorm:"column:updated_at;not null;default:CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;comment:更新时间"`
- }
-
- type MasterProductDimensionDB struct {
- ID string `db:"id" json:"id"`
- Type string `db:"type" json:"type"`
- Code string `db:"code" json:"code"`
- Name string `db:"name" json:"name"`
- Description string `db:"description" json:"description"`
- SortOrder int32 `db:"sort_order" json:"sortOrder"`
- CreatedAt time.Time `db:"created_at" json:"createdAt"`
- UpdatedAt time.Time `db:"updated_at" json:"updatedAt"`
- }
-
- func (MasterProductDimension) TableName() string {
- return "master_product_dimension"
- }
|