説明なし
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

dim_table.go 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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_table", "表字典").
  9. ID("id", 64).Comment("主键ID").End().
  10. String("projectId", 8).NotNull().Comment("项目编号").End().
  11. String("table_name", 64).NotNull().Comment("表名").End(). // 最大64字符
  12. String("table_name_cn", 128).NotNull().Comment("中文表名").End(). // 中文名可以稍长
  13. Text("description").Comment("描述").End().
  14. String("primary_key_field_name", 64).NotNull().Comment("主键字段名").End(). // 修改为64
  15. String("creator", 32).NotNull().Comment("创建人").End().
  16. DateTime("created_at").NotNull().Default("CURRENT_TIMESTAMP").Comment("创建时间").End()
  17. r.RegisterTable(tb.Build())
  18. tb.AddIndex("idx_table_name", "table_name")
  19. })
  20. }
  21. // TableRequest 表字典结构体
  22. type DimTable struct {
  23. ID string `gorm:"column:id;type:varchar(64);primaryKey;comment:主键ID"`
  24. ProjectId string `gorm:"column:project_id;type:varchar(8);not null;comment:项目名称"`
  25. TableName string `gorm:"column:table_name;type:varchar(64);not null;comment:表名"`
  26. TableNameCN string `gorm:"column:table_name_cn;type:varchar(128);not null;comment:中文表名"`
  27. Description string `gorm:"column:description;type:text;comment:描述"`
  28. PrimaryKeyFieldName string `gorm:"column:primary_key_field_name;type:varchar(64);not null;comment:主键字段名"`
  29. Creator string `gorm:"column:creator;type:varchar(32);not null;comment:创建人"`
  30. CreatedAt time.Time `gorm:"column:created_at;type:datetime;not null;default:CURRENT_TIMESTAMP;comment:创建时间"`
  31. }
  32. func (DimTable) DimTable() string {
  33. return "dim_table"
  34. }