Nessuna descrizione
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.

dim_ business.go 2.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. package model
  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("dim_business", "业务词典表").
  9. ID("id", 64).Comment("主键ID").End().
  10. String("project_id", 8).NotNull().Comment("项目编号").End().
  11. String("table_name", 64).NotNull().Comment("表名").End().
  12. String("field_name", 64).NotNull().Comment("字段名称(英文)").End().
  13. String("business_alias", 128).NotNull().Comment("业务别名").End().
  14. String("description", 128).Comment("描述").End().
  15. String("creator", 32).NotNull().Comment("创建人").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. // 核心唯一索引:同一项目下业务别名必须唯一
  19. tb.AddUniqueIndex("uk_project_alias", "project_id", "business_alias")
  20. // 常用查询索引
  21. tb.AddIndex("idx_project_table_field", "project_id", "table_name", "field_name")
  22. r.RegisterTable(tb.Build())
  23. })
  24. }
  25. // DimBusiness 业务词典结构体
  26. type DimBusiness struct {
  27. ID string `gorm:"column:id;type:varchar(64);primaryKey;comment:主键ID"`
  28. ProjectID string `gorm:"column:project_id;type:varchar(8);not null;index:idx_project_id;comment:项目编号"`
  29. TableName string `gorm:"column:table_name;type:varchar(64);not null;comment:表名"`
  30. FieldName string `gorm:"column:field_name;type:varchar(64);not null;comment:字段名称(英文)"`
  31. BusinessAlias string `gorm:"column:business_alias;type:varchar(128);not null;comment:业务别名"`
  32. Description string `gorm:"column:description;type:text;comment:描述"`
  33. Creator string `gorm:"column:creator;type:varchar(32);not null;comment:创建人"`
  34. CreatedAt time.Time `gorm:"column:created_at;type:datetime;not null;default:CURRENT_TIMESTAMP;comment:创建时间"`
  35. UpdatedAt time.Time `gorm:"column:updated_at;type:datetime;not null;default:CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;comment:更新时间"`
  36. }
  37. func (DimBusiness) DimBusiness() string {
  38. return "dim_business"
  39. }