暫無描述
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.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. tb.AddIndex("idx_standard_name", "standard_cn_name")
  23. tb.AddIndex("idx_category", "category")
  24. tb.AddIndex("idx_created_at", "created_at")
  25. r.RegisterTable(tb.Build())
  26. })
  27. }
  28. // DimBusiness 业务词典结构体
  29. type DimBusiness struct {
  30. ID string `gorm:"column:id;type:varchar(64);primaryKey;comment:主键ID"`
  31. ProjectID string `gorm:"column:project_id;type:varchar(8);not null;index:idx_project_id;comment:项目编号"`
  32. TableName string `gorm:"column:table_name;type:varchar(64);not null;comment:表名"`
  33. FieldName string `gorm:"column:field_name;type:varchar(64);not null;comment:字段名称(英文)"`
  34. BusinessAlias string `gorm:"column:business_alias;type:varchar(128);not null;comment:业务别名"`
  35. Description string `gorm:"column:description;type:text;comment:描述"`
  36. Creator string `gorm:"column:creator;type:varchar(32);not null;comment:创建人"`
  37. CreatedAt time.Time `gorm:"column:created_at;type:datetime;not null;default:CURRENT_TIMESTAMP;comment:创建时间"`
  38. UpdatedAt time.Time `gorm:"column:updated_at;type:datetime;not null;default:CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;comment:更新时间"`
  39. }
  40. func (DimBusiness) DimBusiness() string {
  41. return "dim_business"
  42. }