Documentation ¶
Overview ¶
配置修正对象的特点: 1. 极少变化 使用配置修正后, 不能进行修改 目前分两种应用场景 1. 配置修正 2. 数据库读写
Index ¶
- func GetClassCreator(key string) func(data datax.M) IObject
- func SetClassCreator(class string, creator func(data datax.M) IObject)
- type IModify
- type IObject
- type Object
- func (s *Object) GetObjectByPath(path string) IObject
- func (s *Object) RefAnyType() string
- func (s *Object) RefClassCatalog() string
- func (s *Object) RefClassId() string
- func (s *Object) RefClassType() string
- func (s *Object) RefGet(field string) (val interface{})
- func (s *Object) RefGetArray(field string) IObject
- func (s *Object) RefGetBool(field string) bool
- func (s *Object) RefGetFloat64(field string) float64
- func (s *Object) RefGetInt(field string) int
- func (s *Object) RefGetObject(field string) (r IObject)
- func (s *Object) RefGetString(field string) string
- func (s *Object) RefGetUint(field string) uint
- func (s *Object) RefHas(field string) bool
- func (s *Object) RefIsNil() bool
- func (s *Object) RefIsObject(field string) (r bool)
- func (s *Object) RefKeys() (r []string)
- func (s *Object) RefLength() int
- func (s *Object) RefNew() IObject
- func (s *Object) RefNewByMap(data map[string]interface{})
- func (s *Object) RefNewIfNil() IObject
- func (s *Object) RefRemove(field string)
- func (s *Object) RefRemoveByMap(fieldMap map[string]interface{})
- func (s *Object) RefReplaceObjectByPath(path string, val map[string]interface{})
- func (s *Object) RefSet(field string, val interface{}) error
- func (s *Object) RefSetAnyType(val string)
- func (s *Object) RefSetByPath(path string, val interface{})
- func (s *Object) RefSetClassId(classId string)
- func (s *Object) RefSetClassModify(field string, modify IModify)
- func (s *Object) RefSetContext(modifyContext interface{})
- func (s *Object) RefSetMapOrArrayModify(modify IModify)
- func (s *Object) RefSetNil() IObject
- func (s *Object) RefSetObject(field string, r IObject)
- func (s *Object) RefSetThis(val IObject)
- func (s *Object) RefUpdate(data map[string]interface{})
- func (s *Object) RefUseModify()
- func (s *Object) RefUseVersion()
- func (s *Object) ToMap() datax.M
- func (s *Object) ToMapByField(fieldMap datax.M) (r datax.M)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type IObject ¶
type IObject interface { RefSetThis(val IObject) RefUseModify() RefSetMapOrArrayModify(modify IModify) RefSetClassModify(field string, modify IModify) RefUseVersion() // 如果设置了schema, 返回schema的分类【catalog】 RefClassCatalog() string // 如果是class类型, 返回class的类型名字, 否则返回空 RefClassType() string // 通常作为Root才有ClassId RefClassId() string // 当对象为any类型时 RefAnyType() string RefSetAnyType(val string) // RefUseModify打开修正功能后,需要设置上下文,提供给修正函数 RefSetContext(modifyContext interface{}) RefSetClassId(id string) RefGet(field string) (val interface{}) // basic RefGetInt(field string) (val int) RefGetUint(field string) (val uint) RefGetFloat64(field string) (val float64) RefGetString(field string) (val string) RefGetBool(field string) (val bool) RefIsObject(field string) (r bool) // 明确知道当前字段的类型为Class/Map时使用,必然返回一个Object // 如果字段的值为nil,则创建对象,调用RefIsNil()返回true // 如果当前字段不是对象,发生异常 RefGetObject(field string) IObject // 只支持基础类型的数组 RefGetArray(field string) IObject RefSet(field string, val interface{}) error // 设置字段的值,如果字段的类型是Object,使用此方法 RefSetObject(field string, val IObject) RefSetByPath(path string, val interface{}) RefHas(field string) (val bool) RefIsNil() bool RefSetNil() IObject RefNewIfNil() IObject RefNew() IObject RefKeys() []string ToMap() datax.M // key-value // * 如果field为object/map // * 如果value==nil, 标识输出object/map的所有字段 // * 如果value==Map, 标识输出object/map中,Map的名字为Keys的字段 ToMapByField(fieldMap datax.M) (r datax.M) RefLength() int RefNewByMap(data map[string]interface{}) RefUpdate(data map[string]interface{}) RefRemove(field string) RefRemoveByMap(fieldMap map[string]interface{}) RefReplaceObjectByPath(path string, val map[string]interface{}) // contains filtered or unexported methods }
func GetObjectByPath ¶
paht = /field1/field2 or field1/field2
type Object ¶
type Object struct {
// contains filtered or unexported fields
}
func NewObjectByType ¶
需要提前加载schemax的类型描述数据,否则报告异常
func (*Object) GetObjectByPath ¶
func (*Object) RefAnyType ¶
func (*Object) RefClassCatalog ¶
func (*Object) RefClassId ¶
func (*Object) RefClassType ¶
func (*Object) RefGetArray ¶
func (*Object) RefGetBool ¶
func (*Object) RefGetFloat64 ¶
func (*Object) RefGetObject ¶
如果当前对象为nil,触发panic
func (*Object) RefGetString ¶
func (*Object) RefGetUint ¶
func (*Object) RefIsObject ¶
当前对象是否Object any类型无法判断
func (*Object) RefNewByMap ¶
func (*Object) RefRemoveByMap ¶
func (*Object) RefReplaceObjectByPath ¶
func (*Object) RefSetAnyType ¶
func (*Object) RefSetByPath ¶
func (*Object) RefSetClassId ¶
func (*Object) RefSetClassModify ¶
func (*Object) RefSetContext ¶
func (s *Object) RefSetContext(modifyContext interface{})
func (*Object) RefSetMapOrArrayModify ¶
func (*Object) RefSetObject ¶
设置字段的值,如果字段的类型是Object,使用此方法
func (*Object) RefSetThis ¶
func (*Object) RefUseModify ¶
func (s *Object) RefUseModify()
func (*Object) RefUseVersion ¶
func (s *Object) RefUseVersion()
Source Files ¶
Click to show internal directories.
Click to hide internal directories.