| 12345678910111213141516171819202122232425262728293031323334353637383940 |
- package models
-
- import (
- "database/sql"
- "encoding/json"
- "strings"
- "time"
- )
-
- // ConfigTemplate 配置模板表
- type ConfigTemplate struct {
- ID int64 `json:"id" db:"id"` // 技术主键
- Name string `json:"name" db:"name"` // 模板名称
- TypeCode string `json:"type_code" db:"type_code"` // 类型编码,关联template_type.code
- Content json.RawMessage `json:"content" db:"content"` // 模板内容JSON
- ServiceType sql.NullString `json:"service_type,omitempty" db:"service_type"` // 适用服务类型
- IsDefault bool `json:"is_default" db:"is_default"` // 是否默认模板
- SortOrder int `json:"sort_order" db:"sort_order"` // 排序号
- Creator string `json:"creator" db:"creator"` // 创建人
- CreatedAt time.Time `json:"created_at" db:"created_at"` // 创建时间
- }
-
- // TableName 返回表名
- func (ConfigTemplate) TableName() string {
- return "config_template"
- }
-
- // TemplateKey 返回业务键:type_code.name
- func (c *ConfigTemplate) TemplateKey() string {
- return c.TypeCode + "." + c.Name
- }
-
- // ParseTemplateKey 解析业务键
- func ParseTemplateKey(key string) (typeCode, name string, ok bool) {
- parts := strings.SplitN(key, ".", 2)
- if len(parts) != 2 {
- return "", "", false
- }
- return parts[0], parts[1], true
- }
|