settings

package
v1.1.10 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2025 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SettingGroupCore = "core"
)
View Source
const (
	TableNameSettings = "core_settings"
)

Variables

This section is empty.

Functions

func DecryptSecret added in v1.1.9

func DecryptSecret(encData string) string

DecryptSecret 对加密的密码进行解密

func EncryptSecret added in v1.1.9

func EncryptSecret(oriData string) string

EncryptSecret 对密码进行加密

func GetJSON

func GetJSON(group, key string, value interface{}) error

GetJSON 获取json配置

func GetSecret added in v1.1.9

func GetSecret(group, key string) (string, error)

GetSecret 获取密码配置

func GetText

func GetText(group, key string) (string, error)

GetText 获取文本配置

func GetValue added in v1.1.9

func GetValue(group, key string) (string, error)

GetValue 获取配置值,如果是加密配置,返回解密后的值

func GetYaml

func GetYaml(group, key string, value interface{}) error

GetYaml 获取yaml配置

func InitDB

func InitDB() error

InitDB .

func Set

func Set(group, key, value string) error

Set .

func SetSecretAESKey added in v1.1.9

func SetSecretAESKey(key string)

SetSecretAESKey 设置密码加密的key

func SetText

func SetText(group, key, value string) error

func SetYaml

func SetYaml(group, key string, value interface{}) error

SetYaml 插入yaml配置

func Updates

func Updates(sets ...*SettingItem) error

Updates 更新settings值

Types

type SettingItem

type SettingItem struct {
	gorm.Model

	Group     string    `json:"group" gorm:"column:group;type:varchar(16);uniqueIndex:idx_setting,priority:2,unique"`
	Key       string    `json:"key" gorm:"column:key;type:varchar(64);uniqueIndex:idx_setting,priority:3,unique"`
	Name      string    `json:"name" gorm:"column:name;type:varchar(64)"`
	Describe  string    `json:"describe" gorm:"column:describe;type:varchar(128)"`
	ValueType ValueType `json:"value_type" gorm:"column:value_type;default:text;type:varchar(16)"`
	Value     string    `json:"value" gorm:"column:value;type:text"`
	Default   string    `json:"default" gorm:"column:default;type:text"`
}

SettingItem 系统配置

func Get

func Get(group, key string) (*SettingItem, error)

Get 获取数据库或者缓存配置项

func GetByID

func GetByID(id uint) (*SettingItem, error)

GetByID .

func List

func List(group string, keys ...string) ([]*SettingItem, error)

List 配置列表

func (SettingItem) Identify

func (item SettingItem) Identify() string

Identify 唯一建

func (*SettingItem) SecretValue added in v1.1.9

func (item *SettingItem) SecretValue() string

SecretValue 密码原文

func (*SettingItem) TableName

func (*SettingItem) TableName() string

TableName .

type ValueType

type ValueType string
const (
	ValueSecret   ValueType = "secret"
	ValuePassword ValueType = "password"
	ValueText     ValueType = "text"
	ValueInt64    ValueType = "int64"
	ValueBool     ValueType = "bool"
	ValueJSON     ValueType = "json"
	ValueYaml     ValueType = "yaml"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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