설명 없음
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.

config_tenant.go 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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("config_tenant", "配置租户表").
  9. ID("id", 128).NotNull().Comment("主键").End().
  10. String("tenant_id", 128).NotNull().Comment("租户ID").End().
  11. String("name", 128).NotNull().Default("''").Comment("租户名称").End().
  12. String("creator", 32).NotNull().Comment("创建人").End().
  13. DateTime("created_at").NotNull().Default("CURRENT_TIMESTAMP").Comment("创建时间").End()
  14. tb.AddIndex("idx_tenant_id", "tenant_id")
  15. tb.AddIndex("idx_name", "name")
  16. r.RegisterTable(tb.Build())
  17. })
  18. }
  19. type Tenant struct {
  20. TenantID string `gorm:"column:tenant_id;type:varchar(128);not null;primaryKey;comment:租户ID"`
  21. Name string `gorm:"column:name;type:varchar(128);not null;default:'';comment:租户名称"`
  22. Creator string `gorm:"column:creator;type:varchar(32);not null;comment:创建人"`
  23. CreatedAt time.Time `gorm:"column:created_at;not null;default:CURRENT_TIMESTAMP;comment:创建时间"`
  24. }
  25. type TenantDB struct {
  26. ID string `db:"id" json:"id"`
  27. TenantID string `db:"tenant_id" json:"tenantID"`
  28. Name string `db:"name" json:"name"`
  29. Creator string `db:"creator" json:"creator"`
  30. CreatedAt time.Time `db:"created_at" json:"createdAt"`
  31. }
  32. func (Tenant) TableName() string {
  33. return "config_tenant"
  34. }