settings

package
v0.1.27 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2024 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TableNameSettings = "core_settings"
)

Variables

This section is empty.

Functions

func DecryptPassword

func DecryptPassword(encData string) string

DecryptPassword 对加密的密码进行解密

func EncryptPassword

func EncryptPassword(oriData string) string

EncryptPassword 对密码进行加密

func GetJSON

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

GetJSON 获取json配置

func GetPassword

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

GetPassword 获取密码配置

func GetRemoteJSON added in v0.1.27

func GetRemoteJSON(key string, val interface{}) error

func GetRemoteText added in v0.1.27

func GetRemoteText(key string) (string, error)

func GetRemoteYAML added in v0.1.27

func GetRemoteYAML(key string, val interface{}) error

func GetText

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

GetText 获取文本配置

func GetYaml

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

GetYaml 获取yaml配置

func InitDB

func InitDB() error

InitDB .

func InitRemoteSettingClientWithEnv added in v0.1.27

func InitRemoteSettingClientWithEnv(cli *RemoteSettingClient)

func Set

func Set(group, key, value string) error

Set .

func SetPasswordAESKey

func SetPasswordAESKey(key string)

func SetText

func SetText(group, key, value string) error

func SetYaml

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

func Updates

func Updates(sets ...*SettingItem) error

Updates 更新settings值

Types

type RemoteSettingClient added in v0.1.27

type RemoteSettingClient struct {
	BaseURL string
	AK, SK  string
	Group   string
	// contains filtered or unexported fields
}

RemoteSettingClient is a client to get remote settings from a remote server.

func NewRemoteSettingClient added in v0.1.27

func NewRemoteSettingClient(baseURL, ak, sk, group string) *RemoteSettingClient

NewRemoteSettingClient creates a new RemoteSettingClient.

func NewRemoteSettingClientWithEnv added in v0.1.27

func NewRemoteSettingClientWithEnv() *RemoteSettingClient

NewRemoteSettingClientWithEnv creates a new RemoteSettingClient with env.

func (*RemoteSettingClient) Get added in v0.1.27

func (c *RemoteSettingClient) Get(key string) (string, error)

Get gets the remote settings.

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) PasswordValue

func (item *SettingItem) PasswordValue() string

PasswordValue 密码原文

func (*SettingItem) TableName

func (*SettingItem) TableName() string

TableName .

type ValueType

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

Jump to

Keyboard shortcuts

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