Documentation ¶
Index ¶
- Variables
- func AddConfigs(configs map[string]map[string]*dbschema.NgingConfig)
- func AddDefaultConfig(group string, configs map[string]*dbschema.NgingConfig)
- func AddTmpl(group string, tmpl string, opts ...FormSetter)
- func ConfigAsStore(ctx echo.Context, groups ...string) echo.H
- func ConfigDefaults() map[string]map[string]*dbschema.NgingConfig
- func ConfigDefaultsAsStore() echo.H
- func ConfigHasGroup(group string) bool
- func ConfigHasKey(group string, key string) bool
- func DecodeConfig(v *dbschema.NgingConfig, cfg echo.H, decoder Decoder) (echo.H, error)
- func DecodeConfigValue(v *dbschema.NgingConfig, decoder Decoder) (echo.H, error)
- func Decoders() map[string]Decoder
- func DefaultDecoder(v *dbschema.NgingConfig, r echo.H) error
- func DefaultEncoder(v *dbschema.NgingConfig, value string) string
- func DeleteDefaultConfig(group string, keys ...string)
- func EncodeConfigValue(_v *echo.Mapx, v *dbschema.NgingConfig, encoder Encoder) (value string, err error)
- func Encoders() map[string]Encoder
- func FormStoreToMap(d echo.H) echo.H
- func GetDefaultConfig(group string) map[string]*dbschema.NgingConfig
- func GetDefaultConfigOk(group string) (map[string]*dbschema.NgingConfig, bool)
- func GetReflectType(dest interface{}) reflect.Type
- func Init(ctx echo.Context) error
- func InsertBy(ctx echo.Context, configs map[string]*dbschema.NgingConfig, key string, ...) error
- func InsertDefaultConfig(ctx echo.Context, group, key string, values ...string) error
- func InsertMissing(ctx echo.Context, gm *echo.Mapx, added map[string]int, ...) error
- func InsertMissingDefaultConfig(ctx echo.Context, added map[string]map[string]struct{}) error
- func MakeDecoder(t reflect.Type) func(v *dbschema.NgingConfig, r echo.H) error
- func MakeEncoder(t reflect.Type) func(v *dbschema.NgingConfig, r echo.H) ([]byte, error)
- func Register(sf ...*SettingForm)
- func RegisterDecoder(group string, decoder Decoder)
- func RegisterEncoder(group string, encoder Encoder)
- func RegisterTransferType(group string, dest interface{})
- func RunHookGet(ctx echo.Context, groups ...string) error
- func RunHookPost(ctx echo.Context, groups ...string) error
- func StructFieldConvert(s string) string
- type Codec
- type Config
- func (c *Config) AddForm(cfgs ...*SettingForm) *Config
- func (c *Config) AddItem(item *dbschema.NgingConfig) *Config
- func (c *Config) Apply()
- func (c *Config) SetDecoder(decoder Decoder) *Config
- func (c *Config) SetEncoder(encoder Encoder) *Config
- func (c *Config) SetTransferType(dest interface{}) *Config
- type DataDecoder
- type DataDecoders
- type DataEncoder
- type DataEncoders
- type Decoder
- type Encoder
- type FormSetter
- func OptAddConfig(configs ...*dbschema.NgingConfig) FormSetter
- func OptAddFootTmpl(tmpl ...string) FormSetter
- func OptAddHeadTmpl(tmpl ...string) FormSetter
- func OptAddHookGet(hookGet ...func(echo.Context) error) FormSetter
- func OptAddHookPost(hookPost ...func(echo.Context) error) FormSetter
- func OptAddTmpl(tmpl ...string) FormSetter
- func OptDataTransfer(name string, dataInitor DataDecoder, dataForm DataEncoder) FormSetter
- func OptFootTmpl(tmpl ...string) FormSetter
- func OptFormConfig(formcfg *formsconfig.Config) FormSetter
- func OptGroup(group string) FormSetter
- func OptHeadTmpl(tmpl ...string) FormSetter
- func OptHookGet(hookGet ...func(echo.Context) error) FormSetter
- func OptHookPost(hookPost ...func(echo.Context) error) FormSetter
- func OptLabel(label string) FormSetter
- func OptRenderer(renderer func(echo.Context) template.HTML) FormSetter
- func OptShort(short string) FormSetter
- func OptTmpl(tmpl ...string) FormSetter
- type SetDefaults
- type SettingForm
- func (s *SettingForm) AddConfig(configs ...*dbschema.NgingConfig) *SettingForm
- func (s *SettingForm) AddFootTmpl(tmpl ...string) *SettingForm
- func (s *SettingForm) AddHeadTmpl(tmpl ...string) *SettingForm
- func (s *SettingForm) AddHookGet(hook func(echo.Context) error) *SettingForm
- func (s *SettingForm) AddHookPost(hook func(echo.Context) error) *SettingForm
- func (s *SettingForm) AddTmpl(tmpl ...string) *SettingForm
- func (s *SettingForm) Render(ctx echo.Context) template.HTML
- func (s *SettingForm) RunHookGet(ctx echo.Context) error
- func (s *SettingForm) RunHookPost(ctx echo.Context) error
- func (s *SettingForm) SetDataTransfer(name string, dataDecoder DataDecoder, dataEncoder DataEncoder) *SettingForm
- func (s *SettingForm) SetFormConfig(formcfg *formsconfig.Config) *SettingForm
- func (s *SettingForm) SetRenderer(renderer func(echo.Context) template.HTML) *SettingForm
- func (s *SettingForm) SetTransferType(name string, dest interface{}) *SettingForm
- type Validator
Constants ¶
This section is empty.
Variables ¶
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 ¶
ConfigAsStore {Group:{Key:ValueObject}}
func ConfigDefaults ¶
func ConfigDefaults() map[string]map[string]*dbschema.NgingConfig
func ConfigDefaultsAsStore ¶
func ConfigHasGroup ¶
func ConfigHasKey ¶
func DecodeConfig ¶
func DecodeConfigValue ¶
func DefaultDecoder ¶
func DefaultDecoder(v *dbschema.NgingConfig, r echo.H) error
func DefaultEncoder ¶
func DefaultEncoder(v *dbschema.NgingConfig, value string) string
func DeleteDefaultConfig ¶
func EncodeConfigValue ¶
func GetDefaultConfig ¶
func GetDefaultConfig(group string) map[string]*dbschema.NgingConfig
func GetDefaultConfigOk ¶
func GetDefaultConfigOk(group string) (map[string]*dbschema.NgingConfig, bool)
func GetReflectType ¶ added in v0.6.6
func InsertDefaultConfig ¶
func InsertMissing ¶
func MakeDecoder ¶ added in v0.6.6
func MakeEncoder ¶ added in v0.6.6
func Register ¶
func Register(sf ...*SettingForm)
func RegisterDecoder ¶
RegisterDecoder 注册配置值解码器(用于从数据库读出来之后的解码操作) 名称支持"group"或"group.key"两种格式,例如: settings.RegisterDecoder(`sms`,...)对整个sms组的配置有效 settings.RegisterDecoder(`sms.twilio`,...)对sms组内key为twilio的配置有效
func RegisterEncoder ¶
RegisterEncoder 注册配置值编码器(用于客户端提交表单数据之后的编码操作,编码结果保存到数据库) 名称支持"group"或"group.key"两种格式,例如: settings.RegisterDecoder(`sms`,...)对整个sms组的配置有效 settings.RegisterDecoder(`sms.twilio`,...)对sms组内key为twilio的配置有效
func RegisterTransferType ¶ added in v0.6.6
func RegisterTransferType(group string, dest interface{})
RegisterTransferType 注册数据转换类型 名称支持"group"或"group.key"两种格式,例如: settings.RegisterTransferType(`sms`,...)对整个sms组的配置有效 settings.RegisterTransferType(`sms.twilio`,...)对sms组内key为twilio的配置有效
func StructFieldConvert ¶ added in v0.6.8
Types ¶
type Config ¶
type Config struct { Group string Items map[string]*dbschema.NgingConfig Forms []*SettingForm Encoder Encoder Decoder Decoder }
func (*Config) AddForm ¶ added in v0.6.7
func (c *Config) AddForm(cfgs ...*SettingForm) *Config
func (*Config) AddItem ¶ added in v0.6.7
func (c *Config) AddItem(item *dbschema.NgingConfig) *Config
func (*Config) SetDecoder ¶ added in v0.6.7
func (*Config) SetEncoder ¶ added in v0.6.7
func (*Config) SetTransferType ¶ added in v0.6.7
type DataDecoder ¶
type DataDecoder func(v *dbschema.NgingConfig) (pointer interface{}, err error)
func (DataDecoder) Register ¶
func (d DataDecoder) Register(name string)
type DataDecoders ¶
type DataDecoders map[string]DataDecoder
func (DataDecoders) Register ¶
func (d DataDecoders) Register(group string)
type DataEncoder ¶
type DataEncoder func(v *dbschema.NgingConfig, r echo.H) (pointer interface{}, err error)
func (DataEncoder) Register ¶
func (d DataEncoder) Register(name string)
type DataEncoders ¶
type DataEncoders map[string]DataEncoder
func (DataEncoders) Register ¶
func (d DataEncoders) Register(group string)
type Decoder ¶
type Decoder func(v *dbschema.NgingConfig, dbschemaMap echo.H) error
func GetDecoder ¶
type Encoder ¶
func GetEncoder ¶
type FormSetter ¶
type FormSetter func(*SettingForm)
func OptAddConfig ¶
func OptAddConfig(configs ...*dbschema.NgingConfig) FormSetter
func OptAddFootTmpl ¶
func OptAddFootTmpl(tmpl ...string) FormSetter
func OptAddHeadTmpl ¶
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 ¶
func OptDataTransfer(name string, dataInitor DataDecoder, dataForm DataEncoder) FormSetter
func OptFootTmpl ¶
func OptFootTmpl(tmpl ...string) FormSetter
func OptFormConfig ¶
func OptFormConfig(formcfg *formsconfig.Config) FormSetter
func OptGroup ¶
func OptGroup(group string) FormSetter
func OptHeadTmpl ¶
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 ¶
func OptRenderer(renderer func(echo.Context) template.HTML) FormSetter
func OptShort ¶
func OptShort(short string) FormSetter
func OptTmpl ¶
func OptTmpl(tmpl ...string) FormSetter
type SetDefaults ¶ added in v0.6.6
type SetDefaults interface {
SetDefaults()
}
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 ¶
func NewForm(group string, short string, label string, opts ...FormSetter) *SettingForm
func Settings ¶
func Settings() []*SettingForm
func (*SettingForm) AddConfig ¶
func (s *SettingForm) AddConfig(configs ...*dbschema.NgingConfig) *SettingForm
func (*SettingForm) AddFootTmpl ¶
func (s *SettingForm) AddFootTmpl(tmpl ...string) *SettingForm
func (*SettingForm) AddHeadTmpl ¶
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) RunHookGet ¶
func (s *SettingForm) RunHookGet(ctx echo.Context) error
func (*SettingForm) RunHookPost ¶
func (s *SettingForm) RunHookPost(ctx echo.Context) error
func (*SettingForm) SetDataTransfer ¶
func (s *SettingForm) SetDataTransfer(name string, dataDecoder DataDecoder, dataEncoder DataEncoder) *SettingForm
SetDataTransfer 数据转换 dataDecoder: Decoder(table => form) dataEncoder: Encoder(form => table)
func (*SettingForm) SetFormConfig ¶
func (s *SettingForm) SetFormConfig(formcfg *formsconfig.Config) *SettingForm
func (*SettingForm) SetRenderer ¶
func (s *SettingForm) SetRenderer(renderer func(echo.Context) template.HTML) *SettingForm
func (*SettingForm) SetTransferType ¶ added in v0.6.6
func (s *SettingForm) SetTransferType(name string, dest interface{}) *SettingForm