config

package
v0.0.0-...-2383c70 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AppName = "system_config"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AddConfigRequest

type AddConfigRequest struct {
	Items []*KVItem `json:"items"`
}

func NewAddConfigRequest

func NewAddConfigRequest() *AddConfigRequest

func (*AddConfigRequest) AddKVItem

func (r *AddConfigRequest) AddKVItem(items ...*KVItem) *AddConfigRequest

func (*AddConfigRequest) Validate

func (r *AddConfigRequest) Validate() error

type ConfigItem

type ConfigItem struct {
	apps.ResourceMeta
	KVItem
}

func NewConfigItem

func NewConfigItem() *ConfigItem

func (*ConfigItem) Decrypt

func (c *ConfigItem) Decrypt() error

func (*ConfigItem) Encrypt

func (c *ConfigItem) Encrypt() error

func (*ConfigItem) Load

func (c *ConfigItem) Load(v any) error

func (*ConfigItem) String

func (c *ConfigItem) String() string

func (*ConfigItem) TableName

func (c *ConfigItem) TableName() string

type DESCRIBE_BY

type DESCRIBE_BY int
const (
	DESCRIBE_BY_ID DESCRIBE_BY = iota
	DESCRIBE_BY_KEY
)

type DescribeConfigRequest

type DescribeConfigRequest struct {
	DescribeBy    DESCRIBE_BY
	DescribeValue string
}

func NewDescribeConfigRequestById

func NewDescribeConfigRequestById(id string) *DescribeConfigRequest

func NewDescribeConfigRequestByKey

func NewDescribeConfigRequestByKey(key string) *DescribeConfigRequest

type FORMAT

type FORMAT int
const (
	FORMAT_JSON FORMAT = iota
)

type KVItem

type KVItem struct {
	// 配置所属组
	Group string `json:"group" bson:"group" validate:"required,lte=64" gorm:"column:group;type:varchar(200);index"`
	// 配置Key名称
	Key string `json:"key" bson:"key" validate:"required,lte=64" gorm:"column:key;type:varchar(200);index"`
	// 配置Key描述
	Desc string `json:"desc" bson:"desc" gorm:"column:desc;type:text"`
	// 格式
	Format FORMAT `json:"format" bson:"format" gorm:"column:format;type:tinyint(1)"`
	// 配置Key的值
	Value string `json:"value" bson:"value" validate:"required" gorm:"column:value;type:text"`
	// 是否加密
	IsEncrypted bool `json:"is_encrypted" bson:"is_encrypted" validate:"required" gorm:"column:is_encrypted;type:tinyint(1)"`
	// 其他扩展信息
	Extras map[string]string `json:"extras" gorm:"column:extras;serializer:json;type:json" description:"其他扩展信息"`
}

func NewKVItem

func NewKVItem(key, value string) *KVItem

func (*KVItem) SetDesc

func (i *KVItem) SetDesc(desc string) *KVItem

func (*KVItem) SetGroup

func (i *KVItem) SetGroup(group string) *KVItem

func (*KVItem) SetIsEncrypted

func (i *KVItem) SetIsEncrypted(isEncrypted bool) *KVItem

type QueryConfigRequest

type QueryConfigRequest struct {
	Group string `json:"group"`
}

func NewQueryConfigRequest

func NewQueryConfigRequest() *QueryConfigRequest

type Service

type Service interface {
	// 添加配置
	AddConfig(context.Context, *AddConfigRequest) (*types.Set[*ConfigItem], error)
	// 查询配置项
	QueryConfig(context.Context, *QueryConfigRequest) (*types.Set[*ConfigItem], error)
	// 查询配置详情
	DescribeConfig(context.Context, *DescribeConfigRequest) (*ConfigItem, error)
	// 更新配置
	UpdateConfig(context.Context, *UpdateConfigRequest) (*ConfigItem, error)
}

func GetService

func GetService() Service

type UpdateConfigRequest

type UpdateConfigRequest struct {
	Id string `json:"id"`
	KVItem
}

func NewUpdateConfigRequest

func NewUpdateConfigRequest(id string) *UpdateConfigRequest

Directories

Path Synopsis
api
impl

Jump to

Keyboard shortcuts

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