settings

package
v0.1.23 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2024 License: GPL-3.0 Imports: 9 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 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 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 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