entity

package
v1.0.50 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 26, 2026 License: MIT Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Business

type Business struct {
	App             string  `json:"app" gorm:"column:app"`                 // 所属应用标识,如 manager / resource / gateway
	Keyword         string  `json:"keyword" gorm:"column:keyword"`         // 业务配置键(应用内唯一)
	Type            string  `json:"type" gorm:"column:type"`               // 值类型:string | text | int | float | bool | enum | object | kv | array
	Extra           string  `json:"extra" gorm:"column:extra"`             // 渲染元数据(JSON 字符串,见 ParseExtra)
	Description     *string `json:"description" gorm:"column:description"` // 配置说明
	model.BaseModel         // Id(uint32 自增主键) + CreatedAt/UpdatedAt(int64 Unix 秒)
}

Business 业务配置项定义(按业务维度组织的配置项)

func (*Business) ParseExtra added in v1.0.50

func (b *Business) ParseExtra() *BusinessExtra

ParseExtra 解析渲染元数据,解析失败返回 nil(不阻断业务,按无元数据处理)

func (*Business) ValidateExtra added in v1.0.50

func (b *Business) ValidateExtra() error

ValidateExtra 校验渲染元数据合法性(仅允许合法 JSON 且字段类型正确)

type BusinessExtra added in v1.0.50

type BusinessExtra struct {
	Options     []BusinessExtraOption `json:"options"`     // 枚举/多选供选项(label 可选,省略时展示 value)
	Min         *float64              `json:"min"`         // 数值下限(int/float)
	Max         *float64              `json:"max"`         // 数值上限(int/float)
	Unit        string                `json:"unit"`        // 单位后缀(如 MB)
	Placeholder string                `json:"placeholder"` // 输入占位提示
	Default     string                `json:"default"`     // 未设置值时的默认值(与 value 同格式)
	Required    bool                  `json:"required"`    // 保存时是否必填
	Rows        int                   `json:"rows"`        // text 行数
	MaxLength   int                   `json:"maxLength"`   // 字符串最大长度
}

BusinessExtra 业务变量渲染元数据(对应 business.extra JSON 列,字段可增量扩展)

type BusinessExtraOption added in v1.0.50

type BusinessExtraOption struct {
	Label string `json:"label"` // 展示文案(可空 = 使用 Value)
	Value string `json:"value"` // 存储值
}

BusinessExtraOption 枚举选项

type BusinessValue

type BusinessValue struct {
	EnvId           uint32    `json:"envId" gorm:"column:env_id"`           // 所属环境 ID
	BusinessId      uint32    `json:"businessId" gorm:"column:business_id"` // 所属业务配置 ID
	Value           string    `json:"value" gorm:"column:value"`            // 配置值(按 Business.Type 校验格式)
	Business        *Business `json:"business"`                             // 关联的业务配置(Preload 加载)
	model.BaseModel           // Id(uint32 自增主键) + CreatedAt/UpdatedAt(int64 Unix 秒)
}

BusinessValue 业务配置值(按 环境+业务配置项 维度存储,同一项每环境一条记录)

func (*BusinessValue) MarshalValue

func (bv *BusinessValue) MarshalValue(tp string, extra string) (string, error)

MarshalValue 按类型校验并序列化配置值,避免非法格式入库 extra 为业务变量的渲染元数据(JSON 字符串),用于 int/float 范围与 enum/array 枚举校验,可传空

type Configure

type Configure struct {
	model.BaseModel
	App         string  `json:"app" gorm:"column:app"`                 // 所属应用标识
	EnvId       uint32  `json:"envId" gorm:"column:env_id"`            // 所属环境 ID
	Content     string  `json:"content" gorm:"column:content"`         // 渲染后的配置内容
	Version     string  `json:"version" gorm:"column:version"`         // 内容哈希(MD5 大写),用于版本比对与去重
	Format      string  `json:"format" gorm:"column:format"`           // 内容格式:json | yaml
	Description *string `json:"description" gorm:"column:description"` // 配置说明
}

Configure 应用在某环境下的最终配置(由当前模板 + 业务/资源值渲染生成)

type Env

type Env struct {
	Token           string  `json:"token" gorm:"column:token"`             // 环境凭证,客户端 Watch 配置时用于鉴权(MD5 大写)
	Keyword         string  `json:"keyword" gorm:"column:keyword"`         // 环境标识(唯一,如 dev / test / prod)
	Name            string  `json:"name" gorm:"column:name"`               // 环境名称
	Status          *bool   `json:"status" gorm:"column:status"`           // 环境状态:true=启用 false=禁用;NULL=禁用
	Description     *string `json:"description" gorm:"column:description"` // 环境描述
	model.BaseModel         // Id(uint32 自增主键) + CreatedAt/UpdatedAt(int64 Unix 秒)
}

Env 环境信息(dev/test/prod 等环境定义,含客户端拉取配置的鉴权 Token)

type Resource

type Resource struct {
	Keyword         string         `json:"keyword" gorm:"column:keyword"`         // 资源标识(唯一),模板中通过 ${keyword.field} 引用
	Fields          string         `json:"fields" gorm:"column:fields"`           // 资源字段列表,逗号分隔(如 host,port)
	Tag             string         `json:"tag" gorm:"column:tag"`                 // 资源标签,用于分类检索
	Private         *bool          `json:"private" gorm:"column:private"`         // 私有资源:true=仅绑定 App 可见;false=全局公共;NULL=视为公共
	Description     *string        `json:"description" gorm:"column:description"` // 资源说明
	ResourceApps    []*ResourceApp `json:"resourceApps"`                          // 绑定的应用列表(关联查询,非表字段)
	model.BaseModel                // Id(uint32 自增主键) + CreatedAt/UpdatedAt(int64 Unix 秒)
}

Resource 资源配置定义(资源视图片,Fields 为资源字段的逗号分隔列表)

type ResourceApp added in v1.0.50

type ResourceApp struct {
	App        string `json:"app" gorm:"column:app"`                // 绑定的应用标识
	ResourceId uint32 `json:"resourceId" gorm:"column:resource_id"` // 资源 ID
}

ResourceApp 资源配置与应用的绑定关系

func (ResourceApp) TableName added in v1.0.50

func (ResourceApp) TableName() string

type ResourceValue

type ResourceValue struct {
	EnvId           uint32    `json:"envId" gorm:"column:env_id"`           // 所属环境 ID
	ResourceId      uint32    `json:"resourceId" gorm:"column:resource_id"` // 所属资源 ID
	Value           string    `json:"value" gorm:"column:value"`            // 配置值(JSON 对象,键为 Resource.Fields 中定义的字段)
	Resource        *Resource `json:"resource"`                             // 关联的资源(Preload 加载)
	model.BaseModel           // Id(uint32 自增主键) + CreatedAt/UpdatedAt(int64 Unix 秒)
}

ResourceValue 资源配置值(按 环境+资源 维度存储,同一资源每环境一条记录)

type Template

type Template struct {
	model.BaseModel
	App         string `json:"app" gorm:"column:app"`                 // 所属应用标识
	Namespace   string `json:"namespace" gorm:"column:namespace"`     // 模板命名空间(空值按 conf 处理,见 service.normalizeTemplateNamespace)
	Content     string `json:"content" gorm:"column:content"`         // 模板内容(含 ${key} 占位符)
	Version     string `json:"version" gorm:"column:version"`         // 内容哈希(MD5 大写),同一内容复用同一版本
	IsUse       bool   `json:"isUse" gorm:"column:is_use"`            // 是否为当前生效版本(每应用+命名空间仅一条为 true)
	Format      string `json:"format" gorm:"column:format"`           // 内容格式:json | yaml
	Description string `json:"description" gorm:"column:description"` // 版本说明
	Compare     string `json:"compare" gorm:"column:compare"`         // 与上一版本的差异(JSON 数组),仅创建时生成
}

Template 配置模板(多版本管理,IsUse 标记当前生效版本)

type TemplateNamespace added in v1.0.50

type TemplateNamespace struct {
	App             string  `json:"app" gorm:"column:app"`                 // 所属应用标识
	Namespace       string  `json:"namespace" gorm:"column:namespace"`     // 命名空间标识(应用内唯一)
	Name            string  `json:"name" gorm:"column:name"`               // 命名空间名称
	Description     *string `json:"description" gorm:"column:description"` // 命名空间说明
	Sort            uint32  `json:"sort" gorm:"column:sort"`               // 排序权重(升序)
	model.BaseModel         // Id(uint32 自增主键) + CreatedAt/UpdatedAt(int64 Unix 秒)
}

TemplateNamespace 模板命名空间(用于按命名空间隔离管理模板)

func (TemplateNamespace) TableName added in v1.0.50

func (TemplateNamespace) TableName() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL