No Description
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_template_detail.go 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. package tables
  2. import "git.x2erp.com/qdy/go-db/sqldef"
  3. func init() {
  4. sqldef.AddRegistration(func(r *sqldef.Registry) {
  5. // 配置模板明细表(K-V格式)
  6. tb := sqldef.NewTable("config_template_detail", "配置模板明细表").
  7. ID("config_template_detail_id", 256).NotNull().Comment("主键ID").End().
  8. String("config_template_id", 128).NotNull().Comment("模板ID,关联config_template表").End().
  9. String("config_key", 64).NotNull().Comment("配置键名").End().
  10. Text("config_value").NotNull().Comment("配置值").End().
  11. String("value_type", 32).NotNull().Default("'string'").Comment("值类型: string/int/bool/float/json").End().
  12. String("data_type", 32).Comment("数据类型: text/number/boolean/select/array/object").End().
  13. Bool("is_required").NotNull().Default("0").Comment("是否必填").End().
  14. Text("default_value").Comment("默认值").End().
  15. Text("validation_rules").Comment("验证规则JSON").End().
  16. Text("description").Comment("配置项说明").End().
  17. Int("sort_order").NotNull().Default("0").Comment("排序号").End().
  18. Bool("is_sensitive").NotNull().Default("0").Comment("是否敏感数据(如密码)").End().
  19. Bool("is_readonly").NotNull().Default("0").Comment("是否只读").End().
  20. String("creator", 32).NotNull().Comment("创建人").End().
  21. DateTime("created_at").NotNull().Default("CURRENT_TIMESTAMP").Comment("创建时间").End().
  22. DateTime("updated_at").Default("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP").Comment("更新时间").End()
  23. // 添加索引和约束
  24. tb.AddUniqueIndex("uk_template_key", "config_template_id", "config_key").
  25. AddIndex("idx_template_id", "config_template_id").
  26. AddIndex("idx_sort_order", "sort_order").
  27. AddIndex("idx_is_sensitive", "is_sensitive")
  28. // 可选:添加外键约束(如果数据库支持)
  29. // tb.AddForeignKey("fk_template_detail_template", "template_id", "config_template", "template_id")
  30. // 注册表
  31. r.RegisterTable(tb.Build())
  32. })
  33. }