Nav apraksta
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

config_template.go 4.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. package models
  2. import (
  3. "time"
  4. )
  5. // ConfigTemplate 配置模板
  6. type ConfigTemplate struct {
  7. ConfigTemplateID string `gorm:"column:config_template_id;primaryKey;type:varchar(128)" json:"config_template_id"`
  8. TemplateName string `gorm:"column:template_name;type:varchar(100);not null;uniqueIndex;comment:模板名称" json:"template_name"`
  9. IsDefault bool `gorm:"column:is_default;type:boolean;default:false;comment:是否为默认模板" json:"is_default"`
  10. SortOrder int `gorm:"column:sort_order;type:integer;default:0;comment:排序序号" json:"sort_order"`
  11. Description string `gorm:"column:description;type:text;comment:模板描述" json:"description"`
  12. Creator string `gorm:"column:creator;type:varchar(100);not null;comment:创建者" json:"creator"`
  13. CreatedAt time.Time `gorm:"column:created_at;type:timestamp;default:CURRENT_TIMESTAMP" json:"created_at"`
  14. UpdatedAt time.Time `gorm:"column:updated_at;type:timestamp;default:CURRENT_TIMESTAMP;autoUpdateTime" json:"updated_at"`
  15. // 关联关系
  16. Details []ConfigTemplateDetail `gorm:"foreignKey:ConfigTemplateID;references:ConfigTemplateID" json:"details,omitempty"`
  17. }
  18. // TableName 设置表名
  19. func (ConfigTemplate) TableName() string {
  20. return "config_template"
  21. }
  22. // ConfigTemplateDetail 配置模板详情
  23. type ConfigTemplateDetail struct {
  24. ConfigTemplateDetailID string `gorm:"column:config_template_detail_id;primaryKey;autoIncrement" json:"config_template_detail_id"`
  25. ConfigTemplateID string `gorm:"column:config_template_id;not null;index" json:"config_template_id"`
  26. ConfigKey string `gorm:"column:config_key;type:varchar(100);not null;index" json:"config_key"`
  27. ConfigValue string `gorm:"column:config_value;type:text" json:"config_value"`
  28. ValueType string `gorm:"column:value_type;type:varchar(20);not null;default:'string';comment:值类型:string,number,boolean,json,array" json:"value_type"`
  29. DataType string `gorm:"column:data_type;type:varchar(50);comment:数据类型:int,float,string,boolean,date,datetime" json:"data_type"`
  30. IsRequired bool `gorm:"column:is_required;type:boolean;default:false" json:"is_required"`
  31. DefaultValue string `gorm:"column:default_value;type:text" json:"default_value"`
  32. ValidationRules string `gorm:"column:validation_rules;type:jsonb;comment:验证规则JSON" json:"validation_rules"`
  33. Description string `gorm:"column:description;type:text" json:"description"`
  34. SortOrder int `gorm:"column:sort_order;type:integer;default:0" json:"sort_order"`
  35. IsSensitive bool `gorm:"column:is_sensitive;type:boolean;default:false;comment:是否为敏感信息,敏感信息会加密存储" json:"is_sensitive"`
  36. IsReadonly bool `gorm:"column:is_readonly;type:boolean;default:false" json:"is_readonly"`
  37. Creator string `gorm:"column:creator;type:varchar(100);not null" json:"creator"`
  38. CreatedAt time.Time `gorm:"column:created_at;type:timestamp;default:CURRENT_TIMESTAMP" json:"created_at"`
  39. UpdatedAt time.Time `gorm:"column:updated_at;type:timestamp;default:CURRENT_TIMESTAMP;autoUpdateTime" json:"updated_at"`
  40. }
  41. // TableName 设置表名
  42. func (ConfigTemplateDetail) TableName() string {
  43. return "config_template_detail"
  44. }
  45. // ValidationRulesStruct 验证规则结构体
  46. type ValidationRules struct {
  47. Min *float64 `json:"min,omitempty"` // 最小值
  48. Max *float64 `json:"max,omitempty"` // 最大值
  49. MinLength *int `json:"min_length,omitempty"` // 最小长度
  50. MaxLength *int `json:"max_length,omitempty"` // 最大长度
  51. Pattern string `json:"pattern,omitempty"` // 正则表达式
  52. Required *bool `json:"required,omitempty"` // 是否必填
  53. EnumValues []string `json:"enum_values,omitempty"` // 枚举值
  54. Message string `json:"message,omitempty"` // 验证失败提示信息
  55. }