Documentation
¶
Index ¶
- Constants
- Variables
- func CanSet(i interface{}) bool
- func GetBeanClassName(model interface{}) string
- func GetTypeClassName(rt reflect.Type) string
- func IsNil(i interface{}) bool
- func IsSimpleObject(bean 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 ParseParams(params ...interface{}) map[string]interface{}
- func ParseSliceParamString(src string) []string
- func ReflectValue(bean interface{}) reflect.Value
- func SafeSetValue(f reflect.Value, v interface{}) bool
- func SetModelNameType(mtype reflect.Type)
- func SetValue(f reflect.Value, v interface{}) bool
- func ToSlice(arr interface{}) []interface{}
- type MapInfo
- func (mapInfo *MapInfo) AddValue(v reflect.Value)
- 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, ov interface{})
- func (mapInfo *MapInfo) SetValue(v reflect.Value)
- 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)
- 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, ov interface{})
- func (simpleTypeInfo *SimpleTypeInfo) SetValue(v reflect.Value)
- type SliceInfo
- func (sliceInfo *SliceInfo) AddValue(v reflect.Value)
- 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 interface{})
- type StructInfo
- func (structInfo *StructInfo) AddValue(v reflect.Value)
- 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, ov interface{})
Constants ¶
View Source
const ( ObjectUnknown = iota ObjectSimpletype ObjectStruct ObjectSlice ObjectMap ObjectCustom = 50000 )
Variables ¶
View Source
var ( EmptyString string BoolDefault bool ByteDefault byte Complex64Default complex64 Complex128Default complex128 Float32Default float32 Float64Default float64 Int64Default int64 Uint64Default uint64 Int32Default int32 Uint32Default uint32 Int16Default int16 Uint16Default uint16 Int8Default int8 Uint8Default uint8 IntDefault int UintDefault uint TimeDefault time.Time )
View Source
var ( IntType = reflect.TypeOf(IntDefault) Int8Type = reflect.TypeOf(Int8Default) Int16Type = reflect.TypeOf(Int16Default) Int32Type = reflect.TypeOf(Int32Default) Int64Type = reflect.TypeOf(Int64Default) UintType = reflect.TypeOf(UintDefault) Uint8Type = reflect.TypeOf(Uint8Default) Uint16Type = reflect.TypeOf(Uint16Default) Uint32Type = reflect.TypeOf(Uint32Default) Uint64Type = reflect.TypeOf(Uint64Default) Float32Type = reflect.TypeOf(Float32Default) Float64Type = reflect.TypeOf(Float64Default) Complex64Type = reflect.TypeOf(Complex64Default) Complex128Type = reflect.TypeOf(Complex128Default) StringType = reflect.TypeOf(EmptyString) BoolType = reflect.TypeOf(BoolDefault) ByteType = reflect.TypeOf(ByteDefault) BytesType = reflect.SliceOf(ByteType) TimeType = reflect.TypeOf(TimeDefault) )
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, }
Functions ¶
func GetBeanClassName ¶
func GetBeanClassName(model interface{}) string
func GetTypeClassName ¶
func IsSimpleObject ¶
func IsSimpleObject(bean interface{}) bool
func MustPtrValue ¶
func ParseParams ¶
func ParseParams(params ...interface{}) map[string]interface{}
func ParseSliceParamString ¶
func ReflectValue ¶
func SafeSetValue ¶
func SetModelNameType ¶
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 interface{}) // AddValue 添加元素值 AddValue(v reflect.Value) // 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) // GetValue 获得值 GetValue() reflect.Value // ResetValue 变换value对象 ResetValue(v reflect.Value) }
func GetObjectInfo ¶
func GetReflectObjectInfo ¶
type Settable ¶ added in v0.2.7
func (*Settable) ResetValue ¶ added in v0.2.7
type SimpleTypeInfo ¶
func (*SimpleTypeInfo) AddValue ¶
func (simpleTypeInfo *SimpleTypeInfo) AddValue(v reflect.Value)
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
func (*SimpleTypeInfo) SetField ¶
func (simpleTypeInfo *SimpleTypeInfo) SetField(name string, ov interface{})
func (*SimpleTypeInfo) SetValue ¶
func (simpleTypeInfo *SimpleTypeInfo) SetValue(v reflect.Value)
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) AddValue ¶
func (structInfo *StructInfo) AddValue(v reflect.Value)
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
func (*StructInfo) SetField ¶
func (structInfo *StructInfo) SetField(name string, ov interface{})
Click to show internal directories.
Click to hide internal directories.