Documentation ¶
Index ¶
- Constants
- Variables
- func Decode(context *core.Context, result interface{}, res Resourcer, f ...ProcessorFlag) (err error)
- func DecodeMetaValues(context *core.Context, result interface{}, res Resourcer, prefix string, ...) (err error)
- func ErrCantBeBlank(ctx *core.Context, record interface{}, fieldName string, label ...string) error
- func ErrField(ctx *core.Context, record interface{}, fieldName string, label ...string) func(err interface{}) error
- func ErrMetaCantBeBlank(context *core.Context, metaor Metaor) error
- func FormTreeWalkMetaValues(t *FormTree, context *core.Context, metaorsMap map[string]Metaor, ...) (err error)
- func GenericSetter(meta Metaor, fieldName string, ...) func(record interface{}, metaValue *MetaValue, context *core.Context) error
- func GetField(context *core.Context, record interface{}, metaValue *MetaValue) (reflect.Value, error)
- func IdToPrimaryQuery(ctx *core.Context, res Resourcer, exclude bool, id ...aorm.ID) (query string, args []interface{}, err error)
- func IsDefaultMetaSetter(meta *Meta) bool
- func MetaValuesToID(res Resourcer, metaValues *MetaValues) (aorm.ID, error)
- func MustParseID(res Resourcer, s string) aorm.ID
- func OnDBAction(dis edis.EventDispatcherInterface, cb func(e *DBEvent), ...) (err error)
- func OnDBActionE(dis edis.EventDispatcherInterface, cb func(e *DBEvent) error, ...) (err error)
- func ResultFormatter(slice interface{}, formatter func(i int, record interface{}), ...)
- func Setter(newValue GetFielder, ...) func(record interface{}, metaValue *MetaValue, context *core.Context) error
- func SingleFieldIndexSetter(fieldIndex []int, ...) func(record interface{}, metaValue *MetaValue, context *core.Context) error
- func SingleFieldSetter(fieldName string, ...) func(record interface{}, metaValue *MetaValue, context *core.Context) error
- func SliceMetaAppendDeleted(record reflect.Value, metaName string, pks ...ID)
- func StringToPrimaryQuery(ctx *core.Context, res Resourcer, s string, exclude bool) (query string, primaryValues []interface{}, err error)
- type Basic
- type BasicDescriptableValue
- type BasicDescriptableValuer
- type BasicIcon
- type BasicLabel
- type BasicValuer
- type BytesParser
- type CRUD
- func (this *CRUD) CallCreate(record interface{}) (err error)
- func (this *CRUD) CallDelete(recorde interface{}) (err error)
- func (this *CRUD) CallUpdate(recorde interface{}, old ...interface{}) (err error)
- func (this *CRUD) Context() *core.Context
- func (this *CRUD) Count(result interface{}) (err error)
- func (this *CRUD) CountDB(result interface{}) (db *aorm.DB, err error)
- func (this *CRUD) Create(record interface{}) error
- func (this *CRUD) DB() *aorm.DB
- func (this *CRUD) DefaultLayout() bool
- func (this *CRUD) Delete(record interface{}) (err error)
- func (this *CRUD) Dispatcher(dis ...edis.EventDispatcherInterface) *CRUD
- func (this *CRUD) Dispatchers() []edis.EventDispatcherInterface
- func (this *CRUD) FindMany(result interface{}) (err error)
- func (this *CRUD) FindManyBasic() (result []BasicValuer, err error)
- func (this *CRUD) FindManyLayout(layout ...interface{}) (result interface{}, err error)
- func (this *CRUD) FindManyLayoutOrDefault(layout interface{}, defaul ...interface{}) (interface{}, error)
- func (this *CRUD) FindOne(result interface{}, key ...aorm.ID) (err error)
- func (this *CRUD) FindOneBasic(key aorm.ID) (result BasicValuer, err error)
- func (this *CRUD) FindOneLayout(key aorm.ID, layout ...interface{}) (result interface{}, err error)
- func (this *CRUD) HasPermission(mode roles.PermissionMode, ctxN ...*core.Context) bool
- func (this *CRUD) Layout() LayoutInterface
- func (this *CRUD) MetaValues() *MetaValues
- func (this *CRUD) Parent() *CRUD
- func (this *CRUD) Resource() Resourcer
- func (this *CRUD) SaveOrCreate(recorde interface{}) error
- func (this *CRUD) SetContext(ctx *core.Context) *CRUD
- func (this *CRUD) SetDB(DB *aorm.DB) *CRUD
- func (this *CRUD) SetLayout(layout interface{}) *CRUD
- func (this *CRUD) SetLayoutOrDefault(layout interface{}, defaul ...interface{}) *CRUD
- func (this *CRUD) SetMetaValues(metaValues *MetaValues) *CRUD
- func (this *CRUD) Update(record interface{}, old ...interface{}) error
- type CalbackFunc
- type Callback
- type ConfigureMetaBeforeInitializeInterface
- type ConfigureMetaInterface
- type ConfigureResourceBeforeInitializeInterface
- type ConfigureResourceInterface
- type ContextScanner
- type ContextStringsScanner
- type DBActionEvent
- type DBEvent
- type Decoder
- type DescriptionGetter
- type DuplicateUniqueIndexError
- type ExcludeData
- type FContextResourcer
- type FFormattedValuer
- type FSetter
- type FValuer
- type FormTree
- func (this *FormTree) Of(key string) *FormTree
- func (this *FormTree) ParseFormTreeFiles(m map[string][]*multipart.FileHeader, prefix string)
- func (this *FormTree) ParseFormTreeValues(m map[string][]string, prefix string)
- func (this *FormTree) Walk(cb func(t *FormTree, data interface{}) (childData interface{}, err error), ...) (err error)
- type FormTreeMap
- type FormattedValue
- type GetFielder
- type ID
- type IDLabeler
- type IconContextGetter
- type IconGetter
- type Layout
- type LayoutInterface
- type Meta
- func (this *Meta) CanCollection() bool
- func (this *Meta) DBName() string
- func (this *Meta) DefaultPermissionDeny() bool
- func (this *Meta) GetBaseResource() Resourcer
- func (this *Meta) GetContextMetas(record interface{}, context *core.Context) (metas []Metaor)
- func (this *Meta) GetContextResource(context *core.Context) Resourcer
- func (this *Meta) GetContextResourcer() func(meta Metaor, context *core.Context) Resourcer
- func (this *Meta) GetFieldName() string
- func (this *Meta) GetFieldStruct() *aorm.StructField
- func (this *Meta) GetFormattedValuer() func(interface{}, *core.Context) *FormattedValue
- func (this *Meta) GetLabelC(ctx *core.Context) string
- func (this *Meta) GetMetas() (metas []Metaor)
- func (this *Meta) GetRecordLabelC(ctx *core.Context, record interface{}) string
- func (this *Meta) GetReflectStructValueOrInstantiate(record reflect.Value) reflect.Value
- func (this *Meta) GetResource() Resourcer
- func (this Meta) GetSetter() func(recorde interface{}, metaValue *MetaValue, context *core.Context) error
- func (this *Meta) GetValuer() func(interface{}, *core.Context) interface{}
- func (this *Meta) HasPermission(mode roles.PermissionMode, context *core.Context) (perm roles.Perm)
- func (this *Meta) Initialize(virtual bool) error
- func (this *Meta) IsAlone() bool
- func (this *Meta) IsInline() bool
- func (this *Meta) IsLoadRelatedBeforeSave() bool
- func (this *Meta) IsNewRecord(value interface{}) bool
- func (this *Meta) IsRequired() bool
- func (this *Meta) IsSiblingsRequirementCheckDisabled() SiblingsRequirementCheckDisabled
- func (this *Meta) IsZero(recorde, value interface{}) bool
- func (this *Meta) Namer() *MetaName
- func (this *Meta) Permissioner(p ...core.Permissioner)
- func (this *Meta) PreInitialize() error
- func (this *Meta) Proxier() bool
- func (this *Meta) Record(record interface{}) interface{}
- func (this *Meta) RecordRequirer() func(ctx *core.Context, record interface{}) bool
- func (this *Meta) RecordValidator(f ...func(record interface{}, ctx *core.Context) (err error)) *Meta
- func (this *Meta) SetFieldName(name string)
- func (this *Meta) SetFormattedValuer(fc func(interface{}, *core.Context) *FormattedValue)
- func (this *Meta) SetPermission(permission *roles.Permission)
- func (this *Meta) SetSetter(...)
- func (this *Meta) SetValuer(fc func(interface{}, *core.Context) interface{})
- func (this *Meta) Severitify(fv *FormattedValue) *FormattedValue
- func (this *Meta) UIValidator(ctx *core.Context, recorde interface{}) string
- func (this *Meta) Validator(...) *Meta
- func (this *Meta) Validators() []func(record interface{}, values *MetaValue, ctx *core.Context) (err error)
- type MetaConfig
- type MetaConfigInterface
- type MetaName
- type MetaScanner
- type MetaValue
- func (this *MetaValue) EachQueryVal(prefix []string, cb func(prefix []string, name string, value interface{}))
- func (this *MetaValue) FirstInterfaceValue() (value interface{})
- func (this *MetaValue) LastStringValue() (value string)
- func (this *MetaValue) Path() string
- func (this *MetaValue) SetStringValue(v string)
- func (this *MetaValue) StringValue() string
- type MetaValueScanner
- type MetaValuer
- type MetaValues
- func ConvertFormDataToMetaValues(context *core.Context, form url.Values, multipartForm *multipart.Form, ...) (_ *MetaValues, err error)
- func ConvertFormToMetaValues(context *core.Context, request *http.Request, metaors []Metaor, prefix string, ...) (*MetaValues, error)
- func ConvertJSONToMetaValues(context *core.Context, reader io.Reader, metaors []Metaor) (*MetaValues, error)
- func (this *MetaValues) Add(metaValue ...*MetaValue)
- func (this *MetaValues) CheckRequirement(context *core.Context, metaors ...Metaor) error
- func (mvs MetaValues) Get(name string) *MetaValue
- func (mvs MetaValues) GetString(name string) string
- func (mvs *MetaValues) IsBlank() bool
- func (mvs *MetaValues) IsEmpty() bool
- func (this *MetaValues) IsRequirementCheck() bool
- func (this *MetaValues) Reset()
- type Metaor
- type ParentRelationship
- type Processor
- type ProcessorFlag
- type ReadonlyMetaor
- type Repository
- type RepositoryClient
- type RepositoryContext
- type Resource
- func (res *Resource) AddProcessor(fc func(record interface{}, metaValues *MetaValues, ctx *core.Context) error)
- func (res *Resource) AddValidator(fc func(record interface{}, metaValues *MetaValues, ctx *core.Context) error)
- func (res *Resource) BasicDescriptableValue(ctx *core.Context, record interface{}) BasicDescriptableValuer
- func (res *Resource) BasicValue(ctx *core.Context, record interface{}) BasicValuer
- func (res *Resource) ConfigGet(key interface{}) (value interface{}, ok bool)
- func (res *Resource) ConfigSet(key, value interface{})
- func (res *Resource) ContextSetup(ctx *core.Context) *core.Context
- func (res *Resource) Crud(ctx *core.Context) *CRUD
- func (res *Resource) CrudDB(db *aorm.DB) *CRUD
- func (res *Resource) DefaultDenyMode() bool
- func (res *Resource) DefaultPrimaryKeyOrder() aorm.Order
- func (res *Resource) FieldOf(rec interface{}, fieldName string) *aorm.Field
- func (res *Resource) FullID() string
- func (res *Resource) GetContextMetas(*core.Context) []Metaor
- func (res *Resource) GetData() maps.Interface
- func (res *Resource) GetID() string
- func (res *Resource) GetKey(value interface{}) aorm.ID
- func (res *Resource) GetLayout(name string, defaul ...string) LayoutInterface
- func (res *Resource) GetLayoutOrDefault(name string) LayoutInterface
- func (res *Resource) GetMetas([]string) []Metaor
- func (res *Resource) GetModelStruct() *aorm.ModelStruct
- func (res *Resource) GetParentRelation() *ParentRelationship
- func (res *Resource) GetParentResource() Resourcer
- func (res *Resource) GetPathLevel() int
- func (res *Resource) GetPrimaryFields() []*aorm.StructField
- func (res *Resource) GetPrivateLabel() string
- func (res *Resource) GetResource() *Resource
- func (res *Resource) HasKey() bool
- func (res *Resource) HasPermission(mode roles.PermissionMode, context *core.Context) (perm roles.Perm)
- func (res *Resource) InstanceOf(rec interface{}, fieldName ...string) *aorm.Instance
- func (res *Resource) IsSingleton() bool
- func (res *Resource) Layout(name string, layout LayoutInterface)
- func (this *Resource) NewForIdS(id string) (interface{}, error)
- func (res *Resource) NewStruct(site ...*core.Site) interface{}
- func (res *Resource) NewStructCallback(callbacks ...func(obj interface{}, site *core.Site)) *Resource
- func (res *Resource) OnDBAction(cb func(e *DBEvent), action ...DBActionEvent) (err error)
- func (res *Resource) OnDBActionE(cb func(e *DBEvent) error, action ...DBActionEvent) (err error)
- func (res *Resource) Options(opt ...core.Option) *Resource
- func (res *Resource) ParamIDName() string
- func (res *Resource) ParamIDPattern() string
- func (res *Resource) ParseID(s string) (ID aorm.ID, err error)
- func (res *Resource) Permissioner(p core.Permissioner, pN ...core.Permissioner)
- func (res *Resource) PrimaryQuery(ctx *core.Context, primaryValue aorm.ID, exclude ...bool) (string, []interface{}, error)
- func (res *Resource) PrimaryValues(id aorm.ID) (args []interface{})
- func (res *Resource) SetDefaultDenyMode(defaultDenyMode func() bool)
- func (res *Resource) SetDefaultPrimaryKeyOrder(val aorm.Order)
- func (res *Resource) SetI18nModel(value interface{})
- func (res *Resource) SetI18nModelStruct(ms *aorm.ModelStruct, name ...string)
- func (res *Resource) SetI18nName(name string)
- func (res *Resource) SetID(record interface{}, id aorm.ID)
- func (res *Resource) SetParent(parent Resourcer, rel *ParentRelationship)
- func (res *Resource) SetPrimaryFields(fields ...string) error
- func (res *Resource) ToParam() string
- func (res *Resource) Validate(record interface{}, values *MetaValues, ctx *core.Context, ...)
- func (res *Resource) Validator(...)
- type ResourceResultMetaValuesBeforeCommiter
- type Resourcer
- type ResourcerMetaValuesBeforeCommiter
- type SiblingsRequirementCheckDisabled
- type SliceValue
- type SliceValueIterator
- type StringsScanner
- type Struct
- type StructValue
- func (v StructValue) GetValue() interface{}
- func (v StructValue) New() interface{}
- func (v StructValue) NewChan(buf int) interface{}
- func (v StructValue) NewChanPtr(buf int) interface{}
- func (v StructValue) NewSlice() interface{}
- func (v StructValue) NewSliceArgs(len, cap int) interface{}
- func (v StructValue) NewSlicePtr() interface{}
- func (v StructValue) NewSlicePtrArgs(len, cap int) interface{}
- func (v StructValue) NewSliceRecord() (slice interface{}, recorde interface{})
- type ValueSetter
Constants ¶
const ( AutoLoadLinkDisabled contextKey = "autoload_link_disabled" AutoLoadDisabled contextKey = "autoload_disabled" )
const BASIC_LAYOUT = "basic"
const DEFAULT_LAYOUT = "default"
const DefaultFormInputPrefix = "QorResource"
Variables ¶
var ErrProcessorSkipLeft = errors.New("resource: skip left")
ErrProcessorSkipLeft skip left processors error, if returned this error in validation, before callbacks, then qor will stop process following processors
var FormTreeSkipDir = errors.New("skip dir")
Functions ¶
func Decode ¶
func Decode(context *core.Context, result interface{}, res Resourcer, f ...ProcessorFlag) (err error)
Decode decode context to result according to resource definition
func DecodeMetaValues ¶
func DecodeMetaValues(context *core.Context, result interface{}, res Resourcer, prefix string, metaValues *MetaValues, f ...ProcessorFlag) (err error)
func ErrCantBeBlank ¶
func FormTreeWalkMetaValues ¶
func GenericSetter ¶
func IdToPrimaryQuery ¶
func IdToPrimaryQuery(ctx *core.Context, res Resourcer, exclude bool, id ...aorm.ID) (query string, args []interface{}, err error)
IdToPrimaryQuery to returns primary query params
func IsDefaultMetaSetter ¶
func MetaValuesToID ¶
func MetaValuesToID(res Resourcer, metaValues *MetaValues) (aorm.ID, error)
MetaValuesToID to primary query params from meta values
func OnDBAction ¶
func OnDBAction(dis edis.EventDispatcherInterface, cb func(e *DBEvent), action ...DBActionEvent) (err error)
func OnDBActionE ¶
func OnDBActionE(dis edis.EventDispatcherInterface, cb func(e *DBEvent) error, action ...DBActionEvent) (err error)
func ResultFormatter ¶
func SingleFieldIndexSetter ¶
func SingleFieldSetter ¶
func SliceMetaAppendDeleted ¶
Types ¶
type Basic ¶
func (Basic) BasicLabel ¶
type BasicDescriptableValue ¶
func (BasicDescriptableValue) BasicDescription ¶
func (this BasicDescriptableValue) BasicDescription() string
func (BasicDescriptableValue) GetDescription ¶
func (this BasicDescriptableValue) GetDescription() string
type BasicDescriptableValuer ¶
type BasicDescriptableValuer interface { BasicValuer BasicDescription() string }
type BasicLabel ¶
type BasicLabel interface {
BasicLabel() string
}
type BasicValuer ¶
type BasicValuer interface { fmt.Stringer BasicLabel BasicIcon GetID() ID }
type BytesParser ¶
type CRUD ¶
type CRUD struct { DefaultDenyMode bool edis.EventDispatcher Chan interface{} Recorde interface{} HasPermissionFunc func(mode roles.PermissionMode, ctx *core.Context) roles.Perm // contains filtered or unexported fields }
func (*CRUD) CallCreate ¶
func (*CRUD) CallDelete ¶
func (*CRUD) CallUpdate ¶
func (*CRUD) DefaultLayout ¶
func (*CRUD) Dispatcher ¶
func (this *CRUD) Dispatcher(dis ...edis.EventDispatcherInterface) *CRUD
func (*CRUD) Dispatchers ¶
func (this *CRUD) Dispatchers() []edis.EventDispatcherInterface
func (*CRUD) FindManyBasic ¶
func (this *CRUD) FindManyBasic() (result []BasicValuer, err error)
func (*CRUD) FindManyLayout ¶
func (*CRUD) FindManyLayoutOrDefault ¶
func (*CRUD) FindOneBasic ¶
func (this *CRUD) FindOneBasic(key aorm.ID) (result BasicValuer, err error)
func (*CRUD) FindOneLayout ¶
func (*CRUD) HasPermission ¶
func (*CRUD) Layout ¶
func (this *CRUD) Layout() LayoutInterface
func (*CRUD) MetaValues ¶
func (this *CRUD) MetaValues() *MetaValues
func (*CRUD) SaveOrCreate ¶
func (*CRUD) SetLayoutOrDefault ¶
func (*CRUD) SetMetaValues ¶
func (this *CRUD) SetMetaValues(metaValues *MetaValues) *CRUD
type CalbackFunc ¶
type Callback ¶
type Callback struct { Name string Handler CalbackFunc }
type ConfigureMetaBeforeInitializeInterface ¶
type ConfigureMetaBeforeInitializeInterface interface {
ConfigureQorMetaBeforeInitialize(Metaor)
}
ConfigureMetaBeforeInitializeInterface if a struct's field's type implemented this interface, it will be called when initializing a meta
type ConfigureMetaInterface ¶
type ConfigureMetaInterface interface {
ConfigureQorMeta(Metaor)
}
ConfigureMetaInterface if a struct's field's type implemented this interface, it will be called after configed
type ConfigureResourceBeforeInitializeInterface ¶
type ConfigureResourceBeforeInitializeInterface interface {
ConfigureResourceBeforeInitialize(Resourcer)
}
ConfigureResourceBeforeInitializeInterface if a struct implemented this interface, it will be called before everything when create a resource with the struct
type ConfigureResourceInterface ¶
type ConfigureResourceInterface interface {
ConfigureResource(Resourcer)
}
ConfigureResourceInterface if a struct implemented this interface, it will be called after configured by user
type ContextScanner ¶
type ContextScanner interface { // ContextScan scan value ContextScan(ctx *core.Context, src interface{}) error }
ContextScanner interface Allow to scan value with reflect.StructField arg
type ContextStringsScanner ¶
type ContextStringsScanner interface { // ContextScan scan value StringsScan(ctx *core.Context, src []string) error }
ContextStringsScanner interface Allow to scan value with reflect.StructField arg
type DBActionEvent ¶
type DBActionEvent uint
const ( BEFORE DBActionEvent = 1 << iota AFTER ERROR E_DB_ACTION_COUNT E_DB_ACTION_CREATE E_DB_ACTION_DELETE E_DB_ACTION_FIND_MANY E_DB_ACTION_FIND_ONE E_DB_ACTION_UPDATE )
func (DBActionEvent) After ¶
func (n DBActionEvent) After() DBActionEvent
func (DBActionEvent) Before ¶
func (n DBActionEvent) Before() DBActionEvent
func (DBActionEvent) Error ¶
func (n DBActionEvent) Error() DBActionEvent
func (DBActionEvent) FullName ¶
func (n DBActionEvent) FullName() string
func (DBActionEvent) FullNames ¶
func (n DBActionEvent) FullNames() []string
func (DBActionEvent) Name ¶
func (n DBActionEvent) Name() string
func (DBActionEvent) Names ¶
func (n DBActionEvent) Names() []string
type DBEvent ¶
type DBEvent struct { edis.EventInterface Crud *CRUD Action DBActionEvent Context *core.Context DBError error // contains filtered or unexported fields }
func NewDBEvent ¶
func NewDBEvent(action DBActionEvent, ctx *core.Context) *DBEvent
func (*DBEvent) OriginalContext ¶
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
func (Decoder) SetNotLoad ¶
type DescriptionGetter ¶
type DescriptionGetter interface {
GetDescription() string
}
type DuplicateUniqueIndexError ¶
type DuplicateUniqueIndexError struct { *aorm.DuplicateUniqueIndexError // contains filtered or unexported fields }
func (DuplicateUniqueIndexError) Cause ¶
func (d DuplicateUniqueIndexError) Cause() error
func (*DuplicateUniqueIndexError) Record ¶
func (d *DuplicateUniqueIndexError) Record() interface{}
func (*DuplicateUniqueIndexError) Resource ¶
func (d *DuplicateUniqueIndexError) Resource() Resourcer
type ExcludeData ¶
type FContextResourcer ¶
type FFormattedValuer ¶
type FFormattedValuer = func(interface{}, *core.Context) *FormattedValue
type FormTree ¶
type FormTree struct { Key string Index int Value interface{} Children FormTreeMap Parent *FormTree Data interface{} }
func NewFormTree ¶
func NewFormTree() *FormTree
func (*FormTree) ParseFormTreeFiles ¶
func (this *FormTree) ParseFormTreeFiles(m map[string][]*multipart.FileHeader, prefix string)
func (*FormTree) ParseFormTreeValues ¶
type FormTreeMap ¶
func (*FormTreeMap) Add ¶
func (this *FormTreeMap) Add(key string, t *FormTree)
func (*FormTreeMap) GetStringValue ¶
func (this *FormTreeMap) GetStringValue(key string) string
Get gets the first value associated with the given key. If there are no values associated with the key, Get returns the empty string. To access multiple values, use the map directly.
type FormattedValue ¶
type FormattedValue struct { Record interface{} IsZeroF func(record, value interface{}) bool NoZero, Zero bool Raw interface{} // Raws is a slice of raw values Raws interface{} Value string Values []string SafeValue string SafeValues []string // Slice if Raw is Slice Slice bool Severity core.Severity Data map[interface{}]interface{} }
func (*FormattedValue) GetSafeValue ¶
func (v *FormattedValue) GetSafeValue() string
func (*FormattedValue) GetSafeValues ¶
func (v *FormattedValue) GetSafeValues() []string
func (*FormattedValue) IsZero ¶
func (v *FormattedValue) IsZero() bool
func (*FormattedValue) SetNonZero ¶
func (v *FormattedValue) SetNonZero() *FormattedValue
func (*FormattedValue) SetZero ¶
func (v *FormattedValue) SetZero() *FormattedValue
type GetFielder ¶
type IconContextGetter ¶
type IconGetter ¶
type IconGetter interface {
GetIcon() string
}
type Layout ¶
type Layout struct { StructValue PrepareFunc func(crud *CRUD) *CRUD FormatResultFunc func(crud *CRUD, result interface{}) interface{} // contains filtered or unexported fields }
func NewBasicDescriptionLayout ¶
func NewBasicDescriptionLayout() *Layout
func NewBasicLayout ¶
func NewBasicLayout() *Layout
func (*Layout) FormatResult ¶
type LayoutInterface ¶
type Meta ¶
type Meta struct { *MetaName Alias *MetaName FieldName string FieldStruct *aorm.StructField ContextResourcer FContextResourcer Setter FSetter Valuer FValuer GetRecordHandler func(ctx *core.Context, record interface{}) interface{} FormattedValuer FFormattedValuer Config MetaConfigInterface BaseResource Resourcer Resource Resourcer Permission *roles.Permission Help string HelpLong string SaveID bool Inline bool Required bool Icon bool Data maps.Map Typ reflect.Type UIValidatorFunc func(ctx *core.Context, recorde interface{}) string LoadRelatedBeforeSave bool DisableSiblingsRequirement SiblingsRequirementCheckDisabled IsCollection bool Permissioners []core.Permissioner Severity core.Severity SeveritifyFunc func(fv *FormattedValue) DefaultDeny bool // contains filtered or unexported fields }
Meta meta struct definition
func (*Meta) CanCollection ¶
func (*Meta) DefaultPermissionDeny ¶
func (*Meta) GetBaseResource ¶
GetBaseResource get base resource from meta
func (*Meta) GetContextMetas ¶
func (*Meta) GetContextResource ¶
func (*Meta) GetContextResourcer ¶
GetContextResource get resource from meta
func (*Meta) GetFieldName ¶
GetFieldName get meta's field name
func (*Meta) GetFieldStruct ¶
func (this *Meta) GetFieldStruct() *aorm.StructField
GetFieldStruct get aorm field struct
func (*Meta) GetFormattedValuer ¶
func (this *Meta) GetFormattedValuer() func(interface{}, *core.Context) *FormattedValue
GetFormattedValuer get formatted valuer from meta
func (*Meta) GetRecordLabelC ¶
func (*Meta) GetReflectStructValueOrInstantiate ¶
func (*Meta) GetResource ¶
func (Meta) GetSetter ¶
func (this Meta) GetSetter() func(recorde interface{}, metaValue *MetaValue, context *core.Context) error
GetSetter get setter from meta
func (*Meta) HasPermission ¶
AdminHasContextPermission check has permission or not
func (*Meta) Initialize ¶
Initialize initialize meta, will set valuer, setter if haven't configure it
func (*Meta) IsLoadRelatedBeforeSave ¶
func (*Meta) IsNewRecord ¶
func (*Meta) IsRequired ¶
func (*Meta) IsSiblingsRequirementCheckDisabled ¶
func (this *Meta) IsSiblingsRequirementCheckDisabled() SiblingsRequirementCheckDisabled
func (*Meta) Permissioner ¶
func (this *Meta) Permissioner(p ...core.Permissioner)
func (*Meta) PreInitialize ¶
PreInitialize when will be run before initialize, used to fill some basic necessary information
func (*Meta) RecordRequirer ¶
func (*Meta) RecordValidator ¶
func (*Meta) SetFieldName ¶
SetFieldName set meta's field name
func (*Meta) SetFormattedValuer ¶
func (this *Meta) SetFormattedValuer(fc func(interface{}, *core.Context) *FormattedValue)
SetFormattedValuer set formatted valuer for meta
func (*Meta) SetPermission ¶
func (this *Meta) SetPermission(permission *roles.Permission)
SetPermission set permission for meta
func (*Meta) SetSetter ¶
func (this *Meta) SetSetter(fc func(recorde interface{}, metaValue *MetaValue, context *core.Context) error)
SetSetter set setter to meta
func (*Meta) Severitify ¶
func (this *Meta) Severitify(fv *FormattedValue) *FormattedValue
func (*Meta) UIValidator ¶
type MetaConfig ¶
type MetaConfig struct { }
MetaConfig base meta config struct
func (MetaConfig) ConfigureQorMeta ¶
func (MetaConfig) ConfigureQorMeta(Metaor)
ConfigureQorMeta implement the MetaConfigInterface
type MetaConfigInterface ¶
type MetaConfigInterface interface { ConfigureMetaInterface }
MetaConfigInterface meta configuration interface
type MetaName ¶
func (*MetaName) GetEncodedName ¶
GetEncodedName get meta's encodedName
func (*MetaName) GetEncodedNameOrDefault ¶
GetEncodedName get meta's encodedName
type MetaScanner ¶
type MetaScanner interface {
MetaScan(value interface{}) error
}
type MetaValue ¶
type MetaValue struct { Processor *Processor Parent *MetaValue Name string Value interface{} Index int MetaValues *MetaValues ReadOnly bool Meta Metaor NoBlank bool // contains filtered or unexported fields }
MetaValue a struct used to hold information when convert inputs from HTTP form, JSON, CSV files and so on to meta values It will includes field name, field value and its configured Meta, if it is a nested resource, will includes nested metas in its MetaValues
func (*MetaValue) EachQueryVal ¶
func (*MetaValue) FirstInterfaceValue ¶
func (this *MetaValue) FirstInterfaceValue() (value interface{})
func (*MetaValue) LastStringValue ¶
func (*MetaValue) SetStringValue ¶
func (*MetaValue) StringValue ¶
type MetaValueScanner ¶
type MetaValuer ¶
type MetaValuer interface {
MetaValue() interface{}
}
type MetaValues ¶
MetaValues is slice of MetaValue
func ConvertFormDataToMetaValues ¶
func ConvertFormDataToMetaValues(context *core.Context, form url.Values, multipartForm *multipart.Form, metaors []Metaor, prefix string, root ...*MetaValue) (_ *MetaValues, err error)
ConvertFormToMetaValues convert form to meta values
func ConvertFormToMetaValues ¶
func ConvertFormToMetaValues(context *core.Context, request *http.Request, metaors []Metaor, prefix string, root ...*MetaValue) (*MetaValues, error)
ConvertFormToMetaValues convert form to meta values
func ConvertJSONToMetaValues ¶
func ConvertJSONToMetaValues(context *core.Context, reader io.Reader, metaors []Metaor) (*MetaValues, error)
ConvertJSONToMetaValues convert json to meta values
func (*MetaValues) Add ¶
func (this *MetaValues) Add(metaValue ...*MetaValue)
func (*MetaValues) CheckRequirement ¶
func (this *MetaValues) CheckRequirement(context *core.Context, metaors ...Metaor) error
func (MetaValues) Get ¶
func (mvs MetaValues) Get(name string) *MetaValue
Get get meta value from MetaValues with name
func (MetaValues) GetString ¶
func (mvs MetaValues) GetString(name string) string
Get get meta value from MetaValues with name
func (*MetaValues) IsBlank ¶
func (mvs *MetaValues) IsBlank() bool
func (*MetaValues) IsEmpty ¶
func (mvs *MetaValues) IsEmpty() bool
func (*MetaValues) IsRequirementCheck ¶
func (this *MetaValues) IsRequirementCheck() bool
func (*MetaValues) Reset ¶
func (this *MetaValues) Reset()
type Metaor ¶
type Metaor interface { core.Permissioner GetName() string GetFieldName() string GetFieldStruct() *aorm.StructField GetSetter() func(resource interface{}, metaValue *MetaValue, context *core.Context) error GetFormattedValuer() func(recorde interface{}, context *core.Context) *FormattedValue GetValuer() func(recorde interface{}, context *core.Context) interface{} GetContextResourcer() func(meta Metaor, context *core.Context) Resourcer GetResource() Resourcer GetBaseResource() Resourcer GetMetas() []Metaor GetContextMetas(recorde interface{}, context *core.Context) []Metaor GetContextResource(context *core.Context) Resourcer IsInline() bool IsRequired() bool RecordRequirer() func(ctx *core.Context, record interface{}) bool IsZero(recorde, value interface{}) bool GetLabelC(ctx *core.Context) string Validators() []func(record interface{}, values *MetaValue, ctx *core.Context) (err error) GetRecordLabelC(ctx *core.Context, record interface{}) string Proxier() bool IsAlone() bool CanCollection() bool IsSiblingsRequirementCheckDisabled() SiblingsRequirementCheckDisabled IsLoadRelatedBeforeSave() bool Record(record interface{}) interface{} GetReflectStructValueOrInstantiate(record reflect.Value) reflect.Value Severitify(fv *FormattedValue) *FormattedValue }
Metaor interface
type ParentRelationship ¶
type ParentRelationship struct { Data maps.Map aorm.Relationship }
type Processor ¶
type Processor struct { Result interface{} Resource Resourcer Context *core.Context MetaValue *MetaValue MetaValues *MetaValues Flag ProcessorFlag // contains filtered or unexported fields }
func DecodeToResource ¶
func DecodeToResource(res Resourcer, result interface{}, metaValue *MetaValue, context *core.Context, flag ...ProcessorFlag) *Processor
DecodeToResource decode meta values to resource result
func (*Processor) Initialize ¶
type ProcessorFlag ¶
type ProcessorFlag uint16
const ( ProcNone ProcessorFlag = 1 << iota ProcSkipLeft ProcSkipRequireCheck ProcSkipProcessors ProcSkipValidations ProcSkipPermissions ProcSkipLoad ProcSkipChildLoad ProcMerge )
func (ProcessorFlag) Clear ¶
func (b ProcessorFlag) Clear(flag ProcessorFlag) ProcessorFlag
func (ProcessorFlag) Has ¶
func (b ProcessorFlag) Has(flag ProcessorFlag) bool
func (ProcessorFlag) Set ¶
func (b ProcessorFlag) Set(flag ProcessorFlag) ProcessorFlag
func (ProcessorFlag) Toggle ¶
func (b ProcessorFlag) Toggle(flag ProcessorFlag) ProcessorFlag
type ReadonlyMetaor ¶
type Repository ¶
type Repository interface { FindOneLayout(key string, layout ...interface{}) (result interface{}, err error) FindManyLayout(layout ...interface{}) (result interface{}, err error) FindManyLayoutOrDefault(layout interface{}, defaul ...interface{}) (interface{}, error) FindManyBasic() (result []BasicValuer, err error) FindOneBasic(key string) (result BasicValuer, err error) FindOne(result interface{}, key ...string) (err error) FindMany(result interface{}) (err error) Create(record interface{}) error Update(record interface{}) error SaveOrCreate(recorde interface{}) error Delete(record interface{}) (err error) }
type RepositoryClient ¶
type RepositoryClient interface { Repository edis.EventDispatcherInterface SetDB(DB *aorm.DB) RepositoryClient DB() *aorm.DB Resource() Resourcer Layout() LayoutInterface Parent() RepositoryClient MetaValues() *MetaValues SetMetaValues(metaValues *MetaValues) RepositoryClient Dispatchers() []edis.EventDispatcherInterface AppendDispatcher(dis ...edis.EventDispatcherInterface) RepositoryClient SetLayout(layout interface{}) RepositoryClient SetLayoutOrDefault(layout interface{}, defaul ...interface{}) RepositoryClient SetContext(ctx *core.Context) RepositoryClient }
type RepositoryContext ¶
type RepositoryContext struct { }
type Resource ¶
type Resource struct { edis.EventDispatcher StructValue UID string UIDHash uintptr ID string Name string PluralName string PKG string PkgPath string I18nPrefix string PrimaryFields []*aorm.StructField Permission *roles.Permission Validators []func(interface{}, *MetaValues, *core.Context) error Processors []func(interface{}, *MetaValues, *core.Context) error ModelStruct *aorm.ModelStruct PathLevel int ParentRelation *ParentRelationship Data maps.SyncedMap Layouts map[string]LayoutInterface Singleton bool ContextSetupFunc func(ctx *core.Context) *core.Context Permissioners []core.Permissioner Tags aorm.TagSetting // contains filtered or unexported fields }
Resource is a struct that including basic definition of qor resource
func New ¶
func New(value interface{}, id, uid string, modelStruct *aorm.ModelStruct) *Resource
New initialize qor resource
func (*Resource) AddProcessor ¶
func (res *Resource) AddProcessor(fc func(record interface{}, metaValues *MetaValues, ctx *core.Context) error)
AddProcessor add processor to resource, it is used to process data before creating, updating, will rollback the change if it return any error
func (*Resource) AddValidator ¶
func (res *Resource) AddValidator(fc func(record interface{}, metaValues *MetaValues, ctx *core.Context) error)
AddValidator add validator to resource, it will invoked when creating, updating, and will rollback the change if validator return any error
func (*Resource) BasicDescriptableValue ¶
func (res *Resource) BasicDescriptableValue(ctx *core.Context, record interface{}) BasicDescriptableValuer
func (*Resource) BasicValue ¶
func (res *Resource) BasicValue(ctx *core.Context, record interface{}) BasicValuer
func (*Resource) DefaultDenyMode ¶
func (*Resource) DefaultPrimaryKeyOrder ¶
func (*Resource) GetLayout ¶
func (res *Resource) GetLayout(name string, defaul ...string) LayoutInterface
func (*Resource) GetLayoutOrDefault ¶
func (res *Resource) GetLayoutOrDefault(name string) LayoutInterface
func (*Resource) GetModelStruct ¶
func (res *Resource) GetModelStruct() *aorm.ModelStruct
func (*Resource) GetParentRelation ¶
func (res *Resource) GetParentRelation() *ParentRelationship
func (*Resource) GetParentResource ¶
func (*Resource) GetPathLevel ¶
func (*Resource) GetPrimaryFields ¶
func (res *Resource) GetPrimaryFields() []*aorm.StructField
func (*Resource) GetPrivateLabel ¶
func (*Resource) GetResource ¶
GetResource return itself to match interface `Resourcer`
func (*Resource) HasPermission ¶
func (*Resource) InstanceOf ¶
func (*Resource) IsSingleton ¶
func (*Resource) Layout ¶
func (res *Resource) Layout(name string, layout LayoutInterface)
func (*Resource) NewStructCallback ¶
func (*Resource) OnDBAction ¶
func (res *Resource) OnDBAction(cb func(e *DBEvent), action ...DBActionEvent) (err error)
func (*Resource) OnDBActionE ¶
func (res *Resource) OnDBActionE(cb func(e *DBEvent) error, action ...DBActionEvent) (err error)
func (*Resource) ParamIDName ¶
func (*Resource) ParamIDPattern ¶
func (*Resource) Permissioner ¶
func (res *Resource) Permissioner(p core.Permissioner, pN ...core.Permissioner)
func (*Resource) PrimaryQuery ¶
func (res *Resource) PrimaryQuery(ctx *core.Context, primaryValue aorm.ID, exclude ...bool) (string, []interface{}, error)
IdToPrimaryQuery to primary query params
func (*Resource) PrimaryValues ¶
IdToPrimaryQuery to primary query params
func (*Resource) SetDefaultDenyMode ¶
func (*Resource) SetDefaultPrimaryKeyOrder ¶
func (*Resource) SetI18nModel ¶
func (res *Resource) SetI18nModel(value interface{})
func (*Resource) SetI18nModelStruct ¶
func (res *Resource) SetI18nModelStruct(ms *aorm.ModelStruct, name ...string)
func (*Resource) SetI18nName ¶
func (*Resource) SetParent ¶
func (res *Resource) SetParent(parent Resourcer, rel *ParentRelationship)
func (*Resource) SetPrimaryFields ¶
SetPrimaryFields set primary fields
type ResourceResultMetaValuesBeforeCommiter ¶
type ResourceResultMetaValuesBeforeCommiter interface {
BeforeCommitMetaValues(ctx *core.Context, res Resourcer, metaValues *MetaValues)
}
type Resourcer ¶
type Resourcer interface { edis.EventDispatcherInterface Struct core.Permissioner GetID() string FullID() string GetResource() *Resource GetPrimaryFields() []*aorm.StructField GetMetas([]string) []Metaor GetContextMetas(*core.Context) []Metaor NewStruct(site ...*core.Site) interface{} GetPathLevel() int SetParent(parent Resourcer, rel *ParentRelationship) GetParentResource() Resourcer GetParentRelation() *ParentRelationship IsSingleton() bool ToParam() string ParamIDPattern() string ParamIDName() string BasicValue(ctx *core.Context, recorde interface{}) BasicValuer BasicDescriptableValue(ctx *core.Context, record interface{}) BasicDescriptableValuer Crud(ctx *core.Context) *CRUD CrudDB(db *aorm.DB) *CRUD Layout(name string, layout LayoutInterface) GetLayoutOrDefault(name string) LayoutInterface GetLayout(name string, defaul ...string) LayoutInterface HasKey() bool ContextSetup(ctx *core.Context) *core.Context GetKey(value interface{}) aorm.ID ParseID(s string) (ID aorm.ID, err error) SetID(record interface{}, id aorm.ID) PrimaryValues(id aorm.ID) (args []interface{}) GetModelStruct() *aorm.ModelStruct DefaultDenyMode() bool DefaultPrimaryKeyOrder() aorm.Order SetDefaultPrimaryKeyOrder(val aorm.Order) }
Resourcer interface
type ResourcerMetaValuesBeforeCommiter ¶
type ResourcerMetaValuesBeforeCommiter interface {
BeforeCommitMetaValues(ctx *core.Context, record interface{}, metaValues *MetaValues)
}
type SiblingsRequirementCheckDisabled ¶
type SiblingsRequirementCheckDisabled uint8
const ( SiblingsRequirementCheckDisabledOnTrue SiblingsRequirementCheckDisabled = iota + 1 SiblingsRequirementCheckDisabledOnFalse )
func (SiblingsRequirementCheckDisabled) OnFalse ¶
func (this SiblingsRequirementCheckDisabled) OnFalse() bool
func (SiblingsRequirementCheckDisabled) OnTrue ¶
func (this SiblingsRequirementCheckDisabled) OnTrue() bool
type SliceValue ¶
type SliceValue struct { Current interface{} Deleted interface{} DeletedID []ID // contains filtered or unexported fields }
func (*SliceValue) DeletedMap ¶
func (s *SliceValue) DeletedMap() map[string]bool
func (*SliceValue) IsDeleted ¶
func (s *SliceValue) IsDeleted(id ID) bool
func (*SliceValue) Iterator ¶
func (s *SliceValue) Iterator() template.Iterator
func (*SliceValue) Len ¶
func (s *SliceValue) Len() (l int)
type SliceValueIterator ¶
func (*SliceValueIterator) Done ¶
func (s *SliceValueIterator) Done(state interface{}) bool
func (*SliceValueIterator) Next ¶
func (s *SliceValueIterator) Next(state interface{}) (item, nextState interface{})
func (*SliceValueIterator) Start ¶
func (s *SliceValueIterator) Start() (state interface{})
type StringsScanner ¶
StringsScanner interface Allow to scan value with reflect.StructField arg
type Struct ¶
type Struct interface { New() interface{} NewSlice() interface{} NewSliceArgs(len, cap int) interface{} NewSlicePtr() interface{} NewSlicePtrArgs(len, cap int) interface{} NewSliceRecord() (slice interface{}, recorde interface{}) NewChan(buf int) interface{} NewChanPtr(buf int) interface{} GetValue() interface{} }
type StructValue ¶
type StructValue struct {
Value interface{}
}
func NewStructValue ¶
func NewStructValue(value interface{}) StructValue
func (StructValue) GetValue ¶
func (v StructValue) GetValue() interface{}
func (StructValue) New ¶
func (v StructValue) New() interface{}
NewStruct initialize a struct for the Value
func (StructValue) NewChan ¶
func (v StructValue) NewChan(buf int) interface{}
NewChan initialize a channel of struct for the Value
func (StructValue) NewChanPtr ¶
func (v StructValue) NewChanPtr(buf int) interface{}
NewChanPtr initialize a channel of struct ptr for the Value
func (StructValue) NewSlice ¶
func (v StructValue) NewSlice() interface{}
NewSlice initialize a slice of struct for the Value
func (StructValue) NewSliceArgs ¶
func (v StructValue) NewSliceArgs(len, cap int) interface{}
func (StructValue) NewSlicePtr ¶
func (v StructValue) NewSlicePtr() interface{}
NewSlice initialize a slice of struct for the Value
func (StructValue) NewSlicePtrArgs ¶
func (v StructValue) NewSlicePtrArgs(len, cap int) interface{}
func (StructValue) NewSliceRecord ¶
func (v StructValue) NewSliceRecord() (slice interface{}, recorde interface{})
NewSlice initialize a slice of struct for the Value
type ValueSetter ¶
type ValueSetter struct {
// contains filtered or unexported fields
}
func NewValueSetter ¶
func NewValueSetter(value reflect.Value) *ValueSetter
func (ValueSetter) SetBool ¶
func (this ValueSetter) SetBool(x, null bool)
func (ValueSetter) SetInt ¶
func (this ValueSetter) SetInt(x int64)
func (ValueSetter) SetNil ¶
func (this ValueSetter) SetNil(v bool)
Source Files ¶
- api.go
- basic.go
- basic_api.go
- context_scanner.go
- crud.go
- decoder.go
- error.go
- event.go
- form_tree.go
- form_tree_metavalues.go
- formatted_value.go
- getter_api.go
- helpers.go
- layout.go
- layout_helper.go
- log.go
- meta.go
- meta_api.go
- meta_setup_setter.go
- meta_setup_valuer.go
- meta_utils.go
- meta_value.go
- processor.go
- repository.go
- repository_context.go
- resource.go
- resource_configure_api.go
- schema.go
- schema_formdata_to_metavalues.go
- schema_json_to_metavalues.go
- schema_map_to_metavalues.go
- slice_meta.go
- slice_value.go
- utils.go
- value.go