Нема описа
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

master_store_dimension.go 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package tables
  2. import (
  3. "time"
  4. "git.x2erp.com/qdy/go-db/sqldef"
  5. )
  6. func init() {
  7. sqldef.AddRegistration(func(r *sqldef.Registry) {
  8. tb := sqldef.NewTable("master_store_dimension", "店铺维度表 - 存储店铺相关分类标准,如经营模式、店铺定位、零售业态、市场层级、销售渠道、区域等").
  9. ID("id", 50).NotNull().Comment("主键ID").End().
  10. String("type", 30).NotNull().Comment("维度类型: business_model(经营模式)/store_tier(店铺定位)/retail_format(零售业态)/market_tier(市场层级)/sales_channel(销售渠道)/region(区域)").End().
  11. String("code", 50).NotNull().Comment("编码").End().
  12. String("name", 100).NotNull().Comment("名称").End().
  13. String("description", 500).Comment("描述").End().
  14. Int("sort_order").Comment("显示次序").End().
  15. JSON("extra_properties").Comment("扩展属性JSON,存储类型特有属性如: {\"min_area\": 50.0, \"max_area\": 200.0, \"business_hours_type\": \"MALL\", \"parent_id\": \"区域父ID\", \"level\": 1}").End().
  16. DateTime("created_at").NotNull().Default("CURRENT_TIMESTAMP").Comment("创建时间").End().
  17. DateTime("updated_at").NotNull().Default("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP").Comment("更新时间").End()
  18. tb.AddIndex("idx_type", "type")
  19. tb.AddIndex("idx_code", "code")
  20. tb.AddIndex("idx_sort_order", "sort_order")
  21. tb.AddUniqueIndex("uk_type_code", "type", "code")
  22. r.RegisterTable(tb.Build())
  23. })
  24. }
  25. type MasterStoreDimension struct {
  26. ID string `gorm:"column:id;type:varchar(50);not null;primaryKey;comment:主键ID"`
  27. Type string `gorm:"column:type;type:varchar(30);not null;comment:维度类型: business_model(经营模式)/store_tier(店铺定位)/retail_format(零售业态)/market_tier(市场层级)/sales_channel(销售渠道)/region(区域)"`
  28. Code string `gorm:"column:code;type:varchar(50);not null;comment:编码"`
  29. Name string `gorm:"column:name;type:varchar(100);not null;comment:名称"`
  30. Description string `gorm:"column:description;type:varchar(500);comment:描述"`
  31. SortOrder int32 `gorm:"column:sort_order;type:int;comment:显示次序"`
  32. ExtraProperties string `gorm:"column:extra_properties;type:json;comment:扩展属性JSON,存储类型特有属性如: {\"min_area\": 50.0, \"max_area\": 200.0, \"business_hours_type\": \"MALL\", \"parent_id\": \"区域父ID\", \"level\": 1}"`
  33. CreatedAt time.Time `gorm:"column:created_at;not null;default:CURRENT_TIMESTAMP;comment:创建时间"`
  34. UpdatedAt time.Time `gorm:"column:updated_at;not null;default:CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;comment:更新时间"`
  35. }
  36. type MasterStoreDimensionDB struct {
  37. ID string `db:"id" json:"id"`
  38. Type string `db:"type" json:"type"`
  39. Code string `db:"code" json:"code"`
  40. Name string `db:"name" json:"name"`
  41. Description string `db:"description" json:"description"`
  42. SortOrder int32 `db:"sort_order" json:"sortOrder"`
  43. ExtraProperties string `db:"extra_properties" json:"extraProperties"`
  44. CreatedAt time.Time `db:"created_at" json:"createdAt"`
  45. UpdatedAt time.Time `db:"updated_at" json:"updatedAt"`
  46. }
  47. func (MasterStoreDimension) TableName() string {
  48. return "master_store_dimension"
  49. }