Documentation ¶
Index ¶
- Constants
- Variables
- func CanSet(i interface{}) bool
- func CheckValueNilSafe(vi reflect.Value) bool
- func CopyMap(dest, src reflect.Value) (int, error)
- func CopyMapInterface(dest, src interface{}) (int, error)
- func CopySlice(dest, src reflect.Value) (int, error)
- func CopySliceInterface(dest, src interface{}) (int, error)
- func GetBeanClassName(model interface{}) string
- func GetTypeClassName(rt reflect.Type) string
- func IsNil(i interface{}) bool
- func IsSimpleType(t reflect.Type) bool
- func MustPtr(bean interface{}) error
- func MustPtrValue(beanValue reflect.Value) error
- func New(t reflect.Type) interface{}
- func NewValue(t reflect.Type) reflect.Value
- func SetFieldValue(dst reflect.Value, fieldName string, value reflect.Value) error
- func SetFieldValueByTag(dst reflect.Value, tags string, value reflect.Value, tagName string) error
- func SetFieldValueEx(v reflect.Value, fieldName string, value reflect.Value, tagName string, ...) error
- func SetModelNameType(mtype reflect.Type)
- func SetOrCopyMap(dest, src reflect.Value, set bool) (int, error)
- func SetOrCopySlice(dest, src reflect.Value, set bool) (int, error)
- func SetStrcutFieldValue(o interface{}, fieldStr string, value interface{}) error
- func SetStrcutFieldValueByTag(o interface{}, matchStr string, value interface{}, tagName string) error
- func SetStrcutFieldValueEx(o interface{}, fieldName string, value interface{}, tagName string, ...) error
- func SetValue(dst reflect.Value, value reflect.Value) bool
- func SetValueInterface(dst interface{}, v interface{}) error
- type MapInfo
- func (mapInfo *MapInfo) AddValue(v reflect.Value) bool
- func (mapInfo *MapInfo) CanAddValue() bool
- func (mapInfo *MapInfo) CanSet(v reflect.Value) bool
- func (mapInfo *MapInfo) CanSetField() bool
- func (mapInfo *MapInfo) GetClassName() string
- func (mapInfo *MapInfo) Kind() int
- func (mapInfo *MapInfo) New() Object
- func (mapInfo *MapInfo) NewElem() Object
- func (mapInfo *MapInfo) SetField(name string, vv reflect.Value) bool
- func (mapInfo *MapInfo) SetValue(v reflect.Value) bool
- type Newable
- type Object
- func GetObjectInfo(model interface{}) (Object, error)
- func GetReflectMapInfo(rt reflect.Type, rv reflect.Value) (Object, error)
- func GetReflectObjectInfo(rt reflect.Type, rv reflect.Value) (Object, error)
- func GetReflectSimpleTypeInfo(rt reflect.Type, rv reflect.Value) (Object, error)
- func GetReflectSliceInfo(rt reflect.Type, rv reflect.Value) (Object, error)
- type Settable
- type SimpleTypeInfo
- func (simpleTypeInfo *SimpleTypeInfo) AddValue(v reflect.Value) bool
- func (simpleTypeInfo *SimpleTypeInfo) CanAddValue() bool
- func (simpleTypeInfo *SimpleTypeInfo) CanSet(v reflect.Value) bool
- func (simpleTypeInfo *SimpleTypeInfo) CanSetField() bool
- func (simpleTypeInfo *SimpleTypeInfo) GetClassName() string
- func (simpleTypeInfo *SimpleTypeInfo) Kind() int
- func (simpleTypeInfo *SimpleTypeInfo) New() Object
- func (simpleTypeInfo *SimpleTypeInfo) NewElem() Object
- func (simpleTypeInfo *SimpleTypeInfo) SetField(name string, vv reflect.Value) bool
- func (simpleTypeInfo *SimpleTypeInfo) SetValue(v reflect.Value) bool
- type SliceInfo
- func (sliceInfo *SliceInfo) AddValue(v reflect.Value) bool
- func (sliceInfo *SliceInfo) CanAddValue() bool
- func (sliceInfo *SliceInfo) CanSetField() bool
- func (sliceInfo *SliceInfo) GetClassName() string
- func (sliceInfo *SliceInfo) Kind() int
- func (sliceInfo *SliceInfo) New() Object
- func (sliceInfo *SliceInfo) NewElem() Object
- func (sliceInfo *SliceInfo) SetField(name string, v reflect.Value) bool
- type StructInfo
- func (structInfo *StructInfo) AddValue(v reflect.Value) bool
- func (structInfo *StructInfo) CanAddValue() bool
- func (structInfo *StructInfo) CanSetField() bool
- func (structInfo *StructInfo) FillMapValue(paramMap *map[string]interface{})
- func (structInfo *StructInfo) GetClassName() string
- func (structInfo *StructInfo) Kind() int
- func (structInfo *StructInfo) MapValue() map[string]interface{}
- func (structInfo *StructInfo) New() Object
- func (structInfo *StructInfo) NewElem() Object
- func (structInfo *StructInfo) SetField(name string, vv reflect.Value) bool
Constants ¶
View Source
const ( ObjectUnknown = iota ObjectSimpletype ObjectStruct ObjectSlice ObjectMap ObjectCustom = 50000 )
Variables ¶
View Source
var ( EMPTY_STRING string BOOL_DEFAULT bool BYTE_DEFAULT byte COMPLEX64_DEFAULT complex64 COMPLEX128_DEFAULT complex128 FLOAT32_DEFAULT float32 FLOAT64_DEFAULT float64 INT64_DEFAULT int64 UINT64_DEFAULT uint64 INT32_DEFAULT int32 UINT32_DEFAULT uint32 INT16_DEFAULT int16 UINT16_DEFAULT uint16 INT8_DEFAULT int8 UINT8_DEFAULT uint8 INT_DEFAULT int UINT_DEFAULT uint TIME_DEFAULT time.Time )
View Source
var ( IntType = reflect.TypeOf(INT_DEFAULT) Int8Type = reflect.TypeOf(INT8_DEFAULT) Int16Type = reflect.TypeOf(INT16_DEFAULT) Int32Type = reflect.TypeOf(INT32_DEFAULT) Int64Type = reflect.TypeOf(INT64_DEFAULT) UintType = reflect.TypeOf(UINT_DEFAULT) Uint8Type = reflect.TypeOf(UINT8_DEFAULT) Uint16Type = reflect.TypeOf(UINT16_DEFAULT) Uint32Type = reflect.TypeOf(UINT32_DEFAULT) Uint64Type = reflect.TypeOf(UINT64_DEFAULT) Float32Type = reflect.TypeOf(FLOAT32_DEFAULT) Float64Type = reflect.TypeOf(FLOAT64_DEFAULT) Complex64Type = reflect.TypeOf(COMPLEX64_DEFAULT) Complex128Type = reflect.TypeOf(COMPLEX128_DEFAULT) StringType = reflect.TypeOf(EMPTY_STRING) BoolType = reflect.TypeOf(BOOL_DEFAULT) ByteType = reflect.TypeOf(BYTE_DEFAULT) BytesType = reflect.SliceOf(ByteType) TimeType = reflect.TypeOf(TIME_DEFAULT) )
View Source
var ( IntKind = IntType.Kind() Int8Kind = Int8Type.Kind() Int16Kind = Int16Type.Kind() Int32Kind = Int32Type.Kind() Int64Kind = Int64Type.Kind() UintKind = UintType.Kind() Uint8Kind = Uint8Type.Kind() Uint16Kind = Uint16Type.Kind() Uint32Kind = Uint32Type.Kind() Uint64Kind = Uint64Type.Kind() Float32Kind = Float32Type.Kind() Float64Kind = Float64Type.Kind() Complex64Kind = Complex64Type.Kind() Complex128Kind = Complex128Type.Kind() StringKind = StringType.Kind() BoolKind = BoolType.Kind() ByteKind = ByteType.Kind() BytesKind = BytesType.Kind() TimeKind = TimeType.Kind() )
View Source
var SqlType2GoType = map[string]reflect.Type{ "int": IntType, "integer": IntType, "tinyint": IntType, "smallint": IntType, "mediumint": IntType, "bigint": Int64Type, "int unsigned": UintType, "integer unsigned": UintType, "tinyint unsigned": UintType, "smallint unsigned": UintType, "mediumint unsigned": UintType, "bigint unsigned": Uint64Type, "bit": Int8Type, "bool": BoolType, "enum": StringType, "set": StringType, "varchar": StringType, "char": StringType, "tinytext": StringType, "mediumtext": StringType, "text": StringType, "longtext": StringType, "blob": StringType, "tinyblob": StringType, "mediumblob": StringType, "longblob": StringType, "date": TimeType, "datetime": TimeType, "timestamp": TimeType, "time": TimeType, "float": Float64Type, "double": Float64Type, "decimal": Float64Type, "binary": StringType, "varbinary": StringType, }
View Source
var (
StructAliasTag = "alias"
)
Functions ¶
func CheckValueNilSafe ¶
func CopyMapInterface ¶
func CopySliceInterface ¶
func GetBeanClassName ¶
func GetBeanClassName(model interface{}) string
func GetTypeClassName ¶
func MustPtrValue ¶
func SetFieldValue ¶
func SetFieldValueByTag ¶
func SetFieldValueEx ¶
func SetModelNameType ¶
func SetStrcutFieldValue ¶
func SetStrcutFieldValueEx ¶
func SetValueInterface ¶
func SetValueInterface(dst interface{}, v interface{}) error
Types ¶
type MapInfo ¶
func (*MapInfo) CanAddValue ¶
func (*MapInfo) CanSetField ¶
func (*MapInfo) GetClassName ¶
type Object ¶
type Object interface { Kind() int // New 生成克隆空对象 New() Object // NewElem 获得对象的元素 NewElem() Object // SetField 设置字段 SetField(name string, v reflect.Value) bool // AddValue 添加元素值 AddValue(v reflect.Value) bool // GetClassName 获得对象名称 GetClassName() string // CanSetField 是否能设置field CanSetField() bool // CanAddValue 是否能添加值 CanAddValue() bool // NewValue 获得值 NewValue() reflect.Value // CanSet 是否能够设置 CanSet(v reflect.Value) bool // SetValue 设置值 SetValue(v reflect.Value) bool // GetValue 获得值 GetValue() reflect.Value // ResetValue 变换value对象 ResetValue(v reflect.Value) }
func GetObjectInfo ¶
func GetReflectObjectInfo ¶
type Settable ¶
func (*Settable) ResetValue ¶
type SimpleTypeInfo ¶
func (*SimpleTypeInfo) AddValue ¶
func (simpleTypeInfo *SimpleTypeInfo) AddValue(v reflect.Value) bool
func (*SimpleTypeInfo) CanAddValue ¶
func (simpleTypeInfo *SimpleTypeInfo) CanAddValue() bool
func (*SimpleTypeInfo) CanSet ¶
func (simpleTypeInfo *SimpleTypeInfo) CanSet(v reflect.Value) bool
CanSet 直接返回true,需要通过SetValue判断
func (*SimpleTypeInfo) CanSetField ¶
func (simpleTypeInfo *SimpleTypeInfo) CanSetField() bool
func (*SimpleTypeInfo) GetClassName ¶
func (simpleTypeInfo *SimpleTypeInfo) GetClassName() string
func (*SimpleTypeInfo) Kind ¶
func (simpleTypeInfo *SimpleTypeInfo) Kind() int
func (*SimpleTypeInfo) New ¶
func (simpleTypeInfo *SimpleTypeInfo) New() Object
func (*SimpleTypeInfo) NewElem ¶
func (simpleTypeInfo *SimpleTypeInfo) NewElem() Object
type SliceInfo ¶
func (*SliceInfo) CanAddValue ¶
func (*SliceInfo) CanSetField ¶
func (*SliceInfo) GetClassName ¶
type StructInfo ¶
type StructInfo struct { //包含pkg的名称 ClassName string //Model名称(目前用于xml解析是struct的前缀:#{x.username} 中的x) Name string //表字段和实体字段映射关系 FieldNameMap map[string]string Settable Newable }
func GetReflectStructInfo ¶
func GetStructInfo ¶
func GetStructInfo(bean interface{}) (*StructInfo, error)
GetStructInfo 解析结构体,使用: 1、如果结构体中含有gobatis.ModelName类型的字段,则: a)、如果含有tag,则使用tag作为tablename; b)、如果不含有tag,则使用fieldName作为tablename。 2、如果结构体中不含有gobatis.ModelName类型的字段,则使用结构体名称作为tablename 3、如果结构体中含有column的tag,则: a)、如果tag为‘-’,则不进行columne与field的映射; b)、如果tag不为‘-’使用tag name作为column名称与field映射。 4、如果结构体中不含有column的tag,则使用field name作为column名称与field映射 5、如果字段的tag为‘-’,则不进行columne与field的映射;
func (*StructInfo) CanAddValue ¶
func (structInfo *StructInfo) CanAddValue() bool
func (*StructInfo) CanSetField ¶
func (structInfo *StructInfo) CanSetField() bool
func (*StructInfo) FillMapValue ¶
func (structInfo *StructInfo) FillMapValue(paramMap *map[string]interface{})
func (*StructInfo) GetClassName ¶
func (structInfo *StructInfo) GetClassName() string
func (*StructInfo) Kind ¶
func (structInfo *StructInfo) Kind() int
func (*StructInfo) MapValue ¶
func (structInfo *StructInfo) MapValue() map[string]interface{}
func (*StructInfo) New ¶
func (structInfo *StructInfo) New() Object
func (*StructInfo) NewElem ¶
func (structInfo *StructInfo) NewElem() Object
Click to show internal directories.
Click to hide internal directories.