| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- package models
-
- import (
- "time"
- )
-
- // ConfigTemplate 配置模板
- type ConfigTemplate struct {
- ConfigTemplateID string `gorm:"column:config_template_id;primaryKey;type:varchar(128)" json:"config_template_id"`
- TemplateName string `gorm:"column:template_name;type:varchar(100);not null;uniqueIndex;comment:模板名称" json:"template_name"`
- IsDefault bool `gorm:"column:is_default;type:boolean;default:false;comment:是否为默认模板" json:"is_default"`
- SortOrder int `gorm:"column:sort_order;type:integer;default:0;comment:排序序号" json:"sort_order"`
- Description string `gorm:"column:description;type:text;comment:模板描述" json:"description"`
- Creator string `gorm:"column:creator;type:varchar(100);not null;comment:创建者" json:"creator"`
- CreatedAt time.Time `gorm:"column:created_at;type:timestamp;default:CURRENT_TIMESTAMP" json:"created_at"`
- UpdatedAt time.Time `gorm:"column:updated_at;type:timestamp;default:CURRENT_TIMESTAMP;autoUpdateTime" json:"updated_at"`
-
- // 关联关系
- Details []ConfigTemplateDetail `gorm:"foreignKey:ConfigTemplateID;references:ConfigTemplateID" json:"details,omitempty"`
- }
-
- // TableName 设置表名
- func (ConfigTemplate) TableName() string {
- return "config_template"
- }
-
- // ConfigTemplateDetail 配置模板详情
- type ConfigTemplateDetail struct {
- ConfigTemplateDetailID string `gorm:"column:config_template_detail_id;primaryKey;autoIncrement" json:"config_template_detail_id"`
- ConfigTemplateID string `gorm:"column:config_template_id;not null;index" json:"config_template_id"`
- ConfigKey string `gorm:"column:config_key;type:varchar(100);not null;index" json:"config_key"`
- ConfigValue string `gorm:"column:config_value;type:text" json:"config_value"`
- ValueType string `gorm:"column:value_type;type:varchar(20);not null;default:'string';comment:值类型:string,number,boolean,json,array" json:"value_type"`
- DataType string `gorm:"column:data_type;type:varchar(50);comment:数据类型:int,float,string,boolean,date,datetime" json:"data_type"`
- IsRequired bool `gorm:"column:is_required;type:boolean;default:false" json:"is_required"`
- DefaultValue string `gorm:"column:default_value;type:text" json:"default_value"`
- ValidationRules string `gorm:"column:validation_rules;type:jsonb;comment:验证规则JSON" json:"validation_rules"`
- Description string `gorm:"column:description;type:text" json:"description"`
- SortOrder int `gorm:"column:sort_order;type:integer;default:0" json:"sort_order"`
- IsSensitive bool `gorm:"column:is_sensitive;type:boolean;default:false;comment:是否为敏感信息,敏感信息会加密存储" json:"is_sensitive"`
- IsReadonly bool `gorm:"column:is_readonly;type:boolean;default:false" json:"is_readonly"`
- Creator string `gorm:"column:creator;type:varchar(100);not null" json:"creator"`
- CreatedAt time.Time `gorm:"column:created_at;type:timestamp;default:CURRENT_TIMESTAMP" json:"created_at"`
- UpdatedAt time.Time `gorm:"column:updated_at;type:timestamp;default:CURRENT_TIMESTAMP;autoUpdateTime" json:"updated_at"`
- }
-
- // TableName 设置表名
- func (ConfigTemplateDetail) TableName() string {
- return "config_template_detail"
- }
-
- // ValidationRulesStruct 验证规则结构体
- type ValidationRules struct {
- Min *float64 `json:"min,omitempty"` // 最小值
- Max *float64 `json:"max,omitempty"` // 最大值
- MinLength *int `json:"min_length,omitempty"` // 最小长度
- MaxLength *int `json:"max_length,omitempty"` // 最大长度
- Pattern string `json:"pattern,omitempty"` // 正则表达式
- Required *bool `json:"required,omitempty"` // 是否必填
- EnumValues []string `json:"enum_values,omitempty"` // 枚举值
- Message string `json:"message,omitempty"` // 验证失败提示信息
- }
|