settings

package
v3.6.3 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2021 License: AGPL-3.0 Imports: 13 Imported by: 0

README

后台配置

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotExists = errors.New(`Not exists`)

Functions

func AddConfigs

func AddConfigs(configs map[string]map[string]*dbschema.NgingConfig)

func AddDefaultConfig

func AddDefaultConfig(group string, configs map[string]*dbschema.NgingConfig)

func AddTmpl

func AddTmpl(group string, tmpl string, opts ...FormSetter)

func ConfigAsStore

func ConfigAsStore(ctx echo.Context, groups ...string) echo.H

ConfigAsStore {Group:{Key:ValueObject}}

func ConfigDefaults

func ConfigDefaults() map[string]map[string]*dbschema.NgingConfig

func ConfigDefaultsAsStore

func ConfigDefaultsAsStore() echo.H

func ConfigHasGroup

func ConfigHasGroup(group string) bool

func ConfigHasKey

func ConfigHasKey(group string, key string) bool

func DecodeConfig

func DecodeConfig(v *dbschema.NgingConfig, cfg echo.H, decoder Decoder) (echo.H, error)

func DecodeConfigValue

func DecodeConfigValue(v *dbschema.NgingConfig, decoder Decoder) (echo.H, error)

func Decoders

func Decoders() map[string]Decoder

func DefaultDecoder

func DefaultDecoder(v *dbschema.NgingConfig, r echo.H) error

func DefaultEncoder

func DefaultEncoder(v *dbschema.NgingConfig, value string) string

func DeleteDefaultConfig

func DeleteDefaultConfig(group string, keys ...string)

func EncodeConfigValue

func EncodeConfigValue(_v *echo.Mapx, v *dbschema.NgingConfig, encoder Encoder) (value string, err error)

func Encoders

func Encoders() map[string]Encoder

func GetDefaultConfig

func GetDefaultConfig(group string) map[string]*dbschema.NgingConfig

func GetDefaultConfigOk

func GetDefaultConfigOk(group string) (map[string]*dbschema.NgingConfig, bool)

func Init

func Init() error

func InsertBy

func InsertBy(ctx echo.Context, configs map[string]*dbschema.NgingConfig, key string, values ...string) error

func InsertDefaultConfig

func InsertDefaultConfig(ctx echo.Context, group, key string, values ...string) error

func InsertMissing

func InsertMissing(ctx echo.Context, gm *echo.Mapx, added map[string]int, configs map[string]*dbschema.NgingConfig, encoder Encoder) error

func InsertMissingDefaultConfig

func InsertMissingDefaultConfig(ctx echo.Context, added map[string]map[string]struct{}) error

func Register

func Register(sf ...*SettingForm)

func RegisterDecoder

func RegisterDecoder(group string, decoder Decoder)

RegisterDecoder 注册配置值解码器(用于从数据库读出来之后的解码操作) 名称支持"group"或"group.key"两种格式,例如: settings.RegisterDecoder(`sms`,...)对整个sms组的配置有效 settings.RegisterDecoder(`sms.twilio`,...)对sms组内key为twilio的配置有效

func RegisterEncoder

func RegisterEncoder(group string, encoder Encoder)

RegisterEncoder 注册配置值编码器(用于客户端提交表单数据之后的编码操作,编码结果保存到数据库) 名称支持"group"或"group.key"两种格式,例如: settings.RegisterDecoder(`sms`,...)对整个sms组的配置有效 settings.RegisterDecoder(`sms.twilio`,...)对sms组内key为twilio的配置有效

func RunHookGet

func RunHookGet(ctx echo.Context, groups ...string) error

func RunHookPost

func RunHookPost(ctx echo.Context, groups ...string) error

Types

type Codec

type Codec interface {
	Decode(string, ...string) string
	Encode(string, ...string) string
}

type Config

type Config struct {
	Group   string
	Items   map[string]*dbschema.NgingConfig
	Forms   []*SettingForm
	Encoder Encoder
	Decoder Decoder
}

func NewConfig

func NewConfig() *Config

func (*Config) Apply

func (c *Config) Apply()

type DataFrom added in v3.6.2

type DataFrom func(v *dbschema.NgingConfig, r echo.H) (pointer interface{}, err error)

func (DataFrom) Register added in v3.6.2

func (d DataFrom) Register(name string)

type DataFroms added in v3.6.2

type DataFroms map[string]DataFrom

func (DataFroms) Register added in v3.6.2

func (d DataFroms) Register(group string)

type DataInitor added in v3.6.2

type DataInitor func(v *dbschema.NgingConfig) (pointer interface{}, err error)

func (DataInitor) Register added in v3.6.2

func (d DataInitor) Register(name string)

type DataInitors added in v3.6.2

type DataInitors map[string]DataInitor

func (DataInitors) Register added in v3.6.2

func (d DataInitors) Register(group string)

type Decoder

type Decoder func(v *dbschema.NgingConfig, dbschemaMap echo.H) error

func GetDecoder

func GetDecoder(group string) Decoder

type Encoder

type Encoder func(v *dbschema.NgingConfig, formDataMap echo.H) ([]byte, error)

func GetEncoder

func GetEncoder(group string) Encoder

type FormSetter

type FormSetter func(*SettingForm)

func OptAddConfig added in v3.6.2

func OptAddConfig(configs ...*dbschema.NgingConfig) FormSetter

func OptAddFootTmpl added in v3.6.2

func OptAddFootTmpl(tmpl ...string) FormSetter

func OptAddHeadTmpl added in v3.6.2

func OptAddHeadTmpl(tmpl ...string) FormSetter

func OptAddHookGet

func OptAddHookGet(hookGet ...func(echo.Context) error) FormSetter

func OptAddHookPost

func OptAddHookPost(hookPost ...func(echo.Context) error) FormSetter

func OptAddTmpl

func OptAddTmpl(tmpl ...string) FormSetter

func OptDataTransfer added in v3.6.2

func OptDataTransfer(name string, dataInitor DataInitor, dataFrom DataFrom) FormSetter

func OptFootTmpl added in v3.6.2

func OptFootTmpl(tmpl ...string) FormSetter

func OptFormConfig added in v3.6.2

func OptFormConfig(formcfg *formsconfig.Config) FormSetter

func OptGroup

func OptGroup(group string) FormSetter

func OptHeadTmpl added in v3.6.2

func OptHeadTmpl(tmpl ...string) FormSetter

func OptHookGet

func OptHookGet(hookGet ...func(echo.Context) error) FormSetter

func OptHookPost

func OptHookPost(hookPost ...func(echo.Context) error) FormSetter

func OptLabel

func OptLabel(label string) FormSetter

func OptRenderer added in v3.6.2

func OptRenderer(renderer func(echo.Context) template.HTML) FormSetter

func OptShort

func OptShort(short string) FormSetter

func OptTmpl

func OptTmpl(tmpl ...string) FormSetter

type SettingForm

type SettingForm struct {
	Short    string   //简短标签
	Label    string   //标签文本
	Group    string   //组标识
	Tmpl     []string //输入表单模板路径
	HeadTmpl []string
	FootTmpl []string
	// contains filtered or unexported fields
}

func Get

func Get(group string) (int, *SettingForm)

func NewForm added in v3.6.2

func NewForm(group string, short string, label string, opts ...FormSetter) *SettingForm

func Settings

func Settings() []*SettingForm

func (*SettingForm) AddConfig added in v3.6.2

func (s *SettingForm) AddConfig(configs ...*dbschema.NgingConfig) *SettingForm

func (*SettingForm) AddFootTmpl added in v3.6.2

func (s *SettingForm) AddFootTmpl(tmpl ...string) *SettingForm

func (*SettingForm) AddHeadTmpl added in v3.6.2

func (s *SettingForm) AddHeadTmpl(tmpl ...string) *SettingForm

func (*SettingForm) AddHookGet

func (s *SettingForm) AddHookGet(hook func(echo.Context) error) *SettingForm

func (*SettingForm) AddHookPost

func (s *SettingForm) AddHookPost(hook func(echo.Context) error) *SettingForm

func (*SettingForm) AddTmpl

func (s *SettingForm) AddTmpl(tmpl ...string) *SettingForm

func (*SettingForm) Render added in v3.6.2

func (s *SettingForm) Render(ctx echo.Context) template.HTML

func (*SettingForm) RunHookGet

func (s *SettingForm) RunHookGet(ctx echo.Context) error

func (*SettingForm) RunHookPost

func (s *SettingForm) RunHookPost(ctx echo.Context) error

func (*SettingForm) SetDataTransfer added in v3.6.2

func (s *SettingForm) SetDataTransfer(name string, dataInitor DataInitor, dataFrom DataFrom) *SettingForm

func (*SettingForm) SetFormConfig added in v3.6.2

func (s *SettingForm) SetFormConfig(formcfg *formsconfig.Config) *SettingForm

func (*SettingForm) SetRenderer added in v3.6.2

func (s *SettingForm) SetRenderer(renderer func(echo.Context) template.HTML) *SettingForm

Jump to

Keyboard shortcuts

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