Без опису
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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("stock_store_snapshot", "日店铺库存快照表 - 用于保存每天晚上所有店铺的商品库存").
  9. ChineseName("日店铺库存快照表").Aliases("日店铺库存快照").
  10. ID("id", 50).NotNull().Comment("主键ID").ChineseName("主键ID").End().
  11. String("store_id", 50).NotNull().Comment("店铺ID").ChineseName("店铺ID").End().
  12. String("product_id", 50).NotNull().Comment("商品ID").ChineseName("商品ID").End().
  13. String("style_code", 30).NotNull().Comment("款式编码").ChineseName("款式编码").Aliases("编码").End().
  14. String("color_code", 20).NotNull().Comment("颜色代码").ChineseName("颜色代码").End().
  15. String("color_name", 50).NotNull().Comment("颜色名称").ChineseName("颜色名称").Aliases("名称").End().
  16. String("size_code", 10).NotNull().Comment("尺码代码").ChineseName("尺码代码").End().
  17. String("size_name", 20).NotNull().Comment("尺码名称").ChineseName("尺码名称").Aliases("名称").End().
  18. Decimal("stock_actual", 12, 4).NotNull().Default("0").Comment("目前库存").ChineseName("目前库存").End().
  19. Date("data_date").NotNull().Comment("快照日期").ChineseName("快照日期").End().
  20. DateTime("created_at").NotNull().Default("CURRENT_TIMESTAMP").Comment("创建时间").ChineseName("创建时间").Aliases("时间").End()
  21. tb.AddUniqueIndex("idx_store_product", "store_id", "product_id")
  22. tb.AddIndex("idx_style_code", "style_code")
  23. tb.AddIndex("idx_store_id", "store_id")
  24. tb.AddIndex("idx_product_id", "product_id")
  25. tb.AddIndex("idx_data_date", "data_date")
  26. tb.AddIndex("idx_store_product_date", "store_id", "product_id", "data_date")
  27. r.RegisterTable(tb.Build())
  28. })
  29. }
  30. type StockStoreSnapshot struct {
  31. ID string `gorm:"column:id;type:varchar(50);not null;primaryKey;comment:主键ID"`
  32. StoreID string `gorm:"column:store_id;type:varchar(50);not null;comment:店铺ID"`
  33. ProductID string `gorm:"column:product_id;type:varchar(50);not null;comment:商品ID"`
  34. StyleCode string `gorm:"column:style_code;type:varchar(30);not null;comment:款式编码"`
  35. ColorCode string `gorm:"column:color_code;type:varchar(20);not null;comment:颜色代码"`
  36. ColorName string `gorm:"column:color_name;type:varchar(50);not null;comment:颜色名称"`
  37. SizeCode string `gorm:"column:size_code;type:varchar(10);not null;comment:尺码代码"`
  38. SizeName string `gorm:"column:size_name;type:varchar(20);not null;comment:尺码名称"`
  39. StockActual float64 `gorm:"column:stock_actual;type:decimal(12,4);not null;default:0;comment:目前库存"`
  40. DataDate time.Time `gorm:"column:data_date;type:date;not null;comment:快照日期"`
  41. CreatedAt time.Time `gorm:"column:created_at;not null;default:CURRENT_TIMESTAMP;comment:创建时间"`
  42. }
  43. type StockStoreSnapshotDB struct {
  44. ID string `db:"id" json:"id"`
  45. StoreID string `db:"store_id" json:"storeID"`
  46. ProductID string `db:"product_id" json:"productID"`
  47. StyleCode string `db:"style_code" json:"styleCode"`
  48. ColorCode string `db:"color_code" json:"colorCode"`
  49. ColorName string `db:"color_name" json:"colorName"`
  50. SizeCode string `db:"size_code" json:"sizeCode"`
  51. SizeName string `db:"size_name" json:"sizeName"`
  52. StockActual float64 `db:"stock_actual" json:"stockActual"`
  53. DataDate time.Time `db:"data_date" json:"dataDate"`
  54. CreatedAt time.Time `db:"created_at" json:"createdAt"`
  55. }
  56. func (StockStoreSnapshot) TableName() string {
  57. return "stock_store_snapshot"
  58. }