Sin descripción
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_agent.go 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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_agent", "配置租户Agent表").
  9. ID("id", 128).NotNull().Comment("主键").End().
  10. String("agent_id", 128).NotNull().Comment("Agent ID").End().
  11. String("project_id", 128).NotNull().Comment("项目ID").End().
  12. String("tenant_id", 128).NotNull().Comment("租户ID").End().
  13. String("description", 256).NotNull().Default("''").Comment("描述").End().
  14. JSON("content").NotNull().Comment("内容 (JSON格式)").End().
  15. String("creator", 32).NotNull().Comment("创建人").End().
  16. DateTime("created_at").NotNull().Default("CURRENT_TIMESTAMP").Comment("创建时间").End()
  17. tb.AddIndex("idx_agent_id", "agent_id")
  18. tb.AddIndex("idx_tenant_id", "tenant_id")
  19. tb.AddIndex("idx_project_id", "project_id")
  20. r.RegisterTable(tb.Build())
  21. })
  22. }
  23. type TenantAgent struct {
  24. AgentID string `gorm:"column:agent_id;type:varchar(128);not null;primaryKey;comment:Agent ID"`
  25. TenantID string `gorm:"column:tenant_id;type:varchar(128);not null;comment:租户ID"`
  26. ProjectID string `gorm:"column:project_id;type:varchar(128);not null;comment:项目ID"`
  27. Description string `gorm:"column:description;type:varchar(256);not null;default:'';comment:描述"`
  28. Content string `gorm:"column:content;type:json;not null;comment:内容 (JSON格式)"`
  29. Creator string `gorm:"column:creator;type:varchar(32);not null;comment:创建人"`
  30. CreatedAt time.Time `gorm:"column:created_at;not null;default:CURRENT_TIMESTAMP;comment:创建时间"`
  31. }
  32. type TenantAgentDB struct {
  33. ID string `db:"id"`
  34. AgentID string `db:"agent_id"`
  35. TenantID string `db:"tenant_id"`
  36. ProjectID string `db:"project_id"`
  37. Description string `db:"description"`
  38. Content string `db:"content"`
  39. Creator string `db:"creator"`
  40. CreatedAt time.Time `db:"created_at"`
  41. }
  42. func (TenantAgent) TableName() string {
  43. return "config_tenant_agent"
  44. }