Documentation ¶
Index ¶
- Constants
- Variables
- func AopProxyService(service interface{}, engine SessionEngine)
- func AopProxyServiceValue(service reflect.Value, engine SessionEngine)
- func LoadMapperXml(bytes []byte) (items map[string]etree.Token)
- func Proxy(proxyPtr interface{}, ...)
- func ProxyValue(mapperValue reflect.Value, ...)
- func WriteMapper(bean reflect.Value, xml []byte, sessionEngine SessionEngine)
- func WriteMapperByValue(value reflect.Value, xml []byte, sessionEngine SessionEngine)
- func WriteMapperPtrByEngine(ptr interface{}, xml []byte, sessionEngine SessionEngine)
- type CallBack
- type DataSourceRouter
- type ElementType
- type ExpressionEngineLexerCache
- type ExpressionEngineLexerCacheable
- type ExpressionEngineLexerMapCache
- func (it *ExpressionEngineLexerMapCache) Get(expression string) (interface{}, error)
- func (it *ExpressionEngineLexerMapCache) Name() string
- func (it ExpressionEngineLexerMapCache) New() ExpressionEngineLexerMapCache
- func (it *ExpressionEngineLexerMapCache) Set(expression string, lexer interface{}) error
- type ExpressionEngineProxy
- func (it *ExpressionEngineProxy) Eval(lexerResult interface{}, arg interface{}, operation int) (interface{}, error)
- func (it *ExpressionEngineProxy) Lexer(expression string) (interface{}, error)
- func (it *ExpressionEngineProxy) LexerAndEval(expression string, arg interface{}) (interface{}, error)
- func (it *ExpressionEngineProxy) LexerCache() ExpressionEngineLexerCache
- func (it *ExpressionEngineProxy) LexerCacheable() bool
- func (it ExpressionEngineProxy) Name() string
- func (ExpressionEngineProxy) New(engine ast.ExpressionEngine, useLexerCache bool) ExpressionEngineProxy
- func (it *ExpressionEngineProxy) SetExpressionEngine(engine ast.ExpressionEngine)
- func (it *ExpressionEngineProxy) SetLexerCache(cache ExpressionEngineLexerCache)
- func (it *ExpressionEngineProxy) SetUseLexerCache(isUseCache bool) error
- type GoMybatisDataSourceRouter
- func (it *GoMybatisDataSourceRouter) Name() string
- func (it GoMybatisDataSourceRouter) New(routerFunc func(mapperName string) *string) GoMybatisDataSourceRouter
- func (it *GoMybatisDataSourceRouter) Router(mapperName string, engine SessionEngine) (Session, error)
- func (it *GoMybatisDataSourceRouter) SetDB(driver string, url string, db *sql.DB)
- type GoMybatisEngine
- func (it *GoMybatisEngine) DataSourceRouter() DataSourceRouter
- func (it *GoMybatisEngine) ExpressionEngine() ast.ExpressionEngine
- func (it *GoMybatisEngine) GetObj(name string) interface{}
- func (it *GoMybatisEngine) GoroutineIDEnable() bool
- func (it *GoMybatisEngine) GoroutineSessionMap() *GoroutineSessionMap
- func (it *GoMybatisEngine) Log() Log
- func (it *GoMybatisEngine) LogEnable() bool
- func (it *GoMybatisEngine) Name() string
- func (it GoMybatisEngine) New() GoMybatisEngine
- func (it *GoMybatisEngine) NewSession(mapperName string) (Session, error)
- func (it *GoMybatisEngine) Open(driverName, dataSourceName string) (*sql.DB, error)
- func (it *GoMybatisEngine) RegisterObj(ptr interface{}, name string)
- func (it *GoMybatisEngine) SessionFactory() *SessionFactory
- func (it *GoMybatisEngine) SetDataSourceRouter(router DataSourceRouter)
- func (it *GoMybatisEngine) SetExpressionEngine(engine ast.ExpressionEngine)
- func (it *GoMybatisEngine) SetGoroutineIDEnable(enable bool)
- func (it *GoMybatisEngine) SetLog(log Log)
- func (it *GoMybatisEngine) SetLogEnable(enable bool)
- func (it *GoMybatisEngine) SetSessionFactory(factory *SessionFactory)
- func (it *GoMybatisEngine) SetSqlArgTypeConvert(convert ast.SqlArgTypeConvert)
- func (it *GoMybatisEngine) SetSqlBuilder(builder SqlBuilder)
- func (it *GoMybatisEngine) SetSqlResultDecoder(decoder SqlResultDecoder)
- func (it *GoMybatisEngine) SetTempleteDecoder(decoder TempleteDecoder)
- func (it *GoMybatisEngine) SqlArgTypeConvert() ast.SqlArgTypeConvert
- func (it *GoMybatisEngine) SqlBuilder() SqlBuilder
- func (it *GoMybatisEngine) SqlResultDecoder() SqlResultDecoder
- func (it *GoMybatisEngine) TempleteDecoder() TempleteDecoder
- func (it *GoMybatisEngine) WriteMapperPtr(ptr interface{}, xml []byte)
- type GoMybatisSqlArgTypeConvert
- type GoMybatisSqlBuilder
- func (it *GoMybatisSqlBuilder) BuildSql(paramMap map[string]interface{}, nodes []ast.Node) (string, error)
- func (it *GoMybatisSqlBuilder) EnableLog() bool
- func (it *GoMybatisSqlBuilder) ExpressionEngineProxy() *ExpressionEngineProxy
- func (it *GoMybatisSqlBuilder) LogSystem() *LogSystem
- func (it GoMybatisSqlBuilder) New(SqlArgTypeConvert ast.SqlArgTypeConvert, ...) GoMybatisSqlBuilder
- func (it *GoMybatisSqlBuilder) NodeParser() ast.NodeParser
- func (it *GoMybatisSqlBuilder) SetEnableLog(enable bool)
- func (it *GoMybatisSqlBuilder) SqlArgTypeConvert() ast.SqlArgTypeConvert
- type GoMybatisSqlResultDecoder
- type GoMybatisTempleteDecoder
- func (it *GoMybatisTempleteDecoder) Decode(method *reflect.StructField, mapper *etree.Element, ...) error
- func (it *GoMybatisTempleteDecoder) DecodeSets(arg string, mapper *etree.Element, logic LogicDeleteData, ...)
- func (it *GoMybatisTempleteDecoder) DecodeTree(tree map[string]etree.Token, beanType reflect.Type) error
- func (it *GoMybatisTempleteDecoder) DecodeWheres(arg string, mapper *etree.Element, logic LogicDeleteData, ...)
- type GoroutineSessionMap
- type LocalSession
- func (it *LocalSession) Begin(p *tx.Propagation) error
- func (it *LocalSession) Close()
- func (it *LocalSession) Commit() error
- func (it *LocalSession) Exec(sqlorArgs string) (*Result, error)
- func (it *LocalSession) Id() string
- func (it LocalSession) New(driver string, url string, db *sql.DB, logSystem Log) LocalSession
- func (it *LocalSession) Query(sqlorArgs string) ([]map[string][]byte, error)
- func (it *LocalSession) Rollback() error
- type Log
- type LogStandard
- type LogSystem
- type LogicDeleteData
- type Mapper
- type ProxyArg
- type Result
- type ResultProperty
- type ReturnType
- type Session
- type SessionEngine
- type SessionFactory
- func (it *SessionFactory) Close(id string)
- func (it *SessionFactory) CloseAll(id string)
- func (it *SessionFactory) GetSession(id string) Session
- func (it SessionFactory) New(Engine SessionEngine) SessionFactory
- func (it *SessionFactory) NewSession(mapperName string, sessionType SessionType) Session
- func (it *SessionFactory) SetSession(id string, session Session)
- type SessionFactorySession
- func (it *SessionFactorySession) Begin(p *tx.Propagation) error
- func (it *SessionFactorySession) Close()
- func (it *SessionFactorySession) Commit() error
- func (it *SessionFactorySession) Exec(sqlorArgs string) (*Result, error)
- func (it *SessionFactorySession) Id() string
- func (it *SessionFactorySession) Query(sqlorArgs string) ([]map[string][]byte, error)
- func (it *SessionFactorySession) Rollback() error
- type SessionSupport
- type SessionType
- type SqlBuilder
- type SqlResultDecoder
- type TagArg
- type TempleteDecoder
- type VersionData
Constants ¶
const Adapter_FormateDate = `2006-01-02 15:04:05`
const DefaultOneArg = `[default]`
const Element_Mapper = "mapper"
const GoMybatis_Session = `GoMybatis.Session`
const GoMybatis_Session_Ptr = `*GoMybatis.Session`
const GoMybatis_Time = `time.Time`
const GoMybatis_Time_Ptr = `*time.Time`
const ID = `id`
const NewSessionFunc = "NewSession" //NewSession method,auto write implement body code
Variables ¶
var ( IntType = reflect.TypeOf(c_INT_DEFAULT) Int8Type = reflect.TypeOf(c_INT8_DEFAULT) Int16Type = reflect.TypeOf(c_INT16_DEFAULT) Int32Type = reflect.TypeOf(c_INT32_DEFAULT) Int64Type = reflect.TypeOf(c_INT64_DEFAULT) UintType = reflect.TypeOf(c_UINT_DEFAULT) Uint8Type = reflect.TypeOf(c_UINT8_DEFAULT) Uint16Type = reflect.TypeOf(c_UINT16_DEFAULT) Uint32Type = reflect.TypeOf(c_UINT32_DEFAULT) Uint64Type = reflect.TypeOf(c_UINT64_DEFAULT) Float32Type = reflect.TypeOf(c_FLOAT32_DEFAULT) Float64Type = reflect.TypeOf(c_FLOAT64_DEFAULT) Complex64Type = reflect.TypeOf(c_COMPLEX64_DEFAULT) Complex128Type = reflect.TypeOf(c_COMPLEX128_DEFAULT) StringType = reflect.TypeOf(c_EMPTY_STRING) BoolType = reflect.TypeOf(c_BOOL_DEFAULT) ByteType = reflect.TypeOf(c_BYTE_DEFAULT) BytesType = reflect.SliceOf(ByteType) TimeType = reflect.TypeOf(c_TIME_DEFAULT) )
var ( PtrIntType = reflect.PtrTo(IntType) PtrInt8Type = reflect.PtrTo(Int8Type) PtrInt16Type = reflect.PtrTo(Int16Type) PtrInt32Type = reflect.PtrTo(Int32Type) PtrInt64Type = reflect.PtrTo(Int64Type) PtrUintType = reflect.PtrTo(UintType) PtrUint8Type = reflect.PtrTo(Uint8Type) PtrUint16Type = reflect.PtrTo(Uint16Type) PtrUint32Type = reflect.PtrTo(Uint32Type) PtrUint64Type = reflect.PtrTo(Uint64Type) PtrFloat32Type = reflect.PtrTo(Float32Type) PtrFloat64Type = reflect.PtrTo(Float64Type) PtrComplex64Type = reflect.PtrTo(Complex64Type) PtrComplex128Type = reflect.PtrTo(Complex128Type) PtrStringType = reflect.PtrTo(StringType) PtrBoolType = reflect.PtrTo(BoolType) PtrByteType = reflect.PtrTo(ByteType) PtrTimeType = reflect.PtrTo(TimeType) )
Functions ¶
func AopProxyService ¶
func AopProxyService(service interface{}, engine SessionEngine)
使用AOP切面 代理目标服务,如果服务painc()它的事务会回滚 默认为单协程模型,如果是多协程调用的情况请开启engine.SetGoroutineIDEnable(true)
func AopProxyServiceValue ¶
func AopProxyServiceValue(service reflect.Value, engine SessionEngine)
使用AOP切面 代理目标服务,如果服务painc()它的事务会回滚
func Proxy ¶
func Proxy(proxyPtr interface{}, buildFunc func(funcField reflect.StructField, field reflect.Value) func(arg ProxyArg) []reflect.Value)
AopProxy 可写入每个函数代理方法.proxyPtr:代理对象指针,buildFunc:构建代理函数
func ProxyValue ¶
func ProxyValue(mapperValue reflect.Value, buildFunc func(funcField reflect.StructField, field reflect.Value) func(arg ProxyArg) []reflect.Value)
AopProxy 可写入每个函数代理方法
func WriteMapper ¶
func WriteMapper(bean reflect.Value, xml []byte, sessionEngine SessionEngine)
写入方法内容,例如
type ExampleActivityMapperImpl struct { SelectAll func(result *[]Activity) error SelectByCondition func(name string, startTime time.Time, endTime time.Time, page int, size int, result *[]Activity) error `mapperParams:"name,startTime,endTime,page,size"` UpdateById func(session *GoMybatis.Session, arg Activity, result *int64) error //只要参数中包含有*GoMybatis.Session的类型,框架默认使用传入的session对象,用于自定义事务 Insert func(arg Activity, result *int64) error CountByCondition func(name string, startTime time.Time, endTime time.Time, result *int) error `mapperParams:"name,startTime,endTime"` }
func的基本类型的参数(例如string,int,time.Time,int64,float....)个数无限制(并且需要用Tag指定参数名逗号隔开,例如`mapperParams:"id,phone"`),返回值必须有error func的结构体参数无需指定mapperParams的tag,框架会自动扫描它的属性,封装为map处理掉 使用WriteMapper函数设置代理后即可正常使用。
func WriteMapperByValue ¶
func WriteMapperByValue(value reflect.Value, xml []byte, sessionEngine SessionEngine)
推荐默认使用单例传入 根据sessionEngine写入到mapperPtr,value:指向mapper指针反射对象,xml:xml数据,sessionEngine:session引擎,enableLog:是否允许日志输出,log:日志实现
func WriteMapperPtrByEngine ¶
func WriteMapperPtrByEngine(ptr interface{}, xml []byte, sessionEngine SessionEngine)
推荐默认使用单例传入 根据sessionEngine写入到mapperPtr,ptr:指向mapper指针,xml:xml数据,sessionEngine:session引擎,enableLog:是否允许日志输出,log:日志实现
Types ¶
type CallBack ¶
type CallBack struct { //sql 查询之前执行,可以写指针改变sql内容(func 可以为nil) BeforeQuery func(args []reflect.Value, sqlorArgs *string) //sql 查询之前执行,可以写指针改变sql内容(func 可以为nil) BeforeExec func(args []reflect.Value, sqlorArgs *string) //sql 查询之后执行,可以写指针改变返回结果(func 可以为nil) AfterQuery func(args []reflect.Value, sqlorArgs string, result *[]map[string][]byte, err *error) //sql 查询之后执行,可以写指针改变返回结果(func 可以为nil) AfterExec func(args []reflect.Value, sqlorArgs string, result *Result, err *error) }
sql 运行时 回调
type DataSourceRouter ¶
type DataSourceRouter interface { //路由规则 //参数:mapperName mapper文件包名+名称例如(example.ExampleActivityMapper) //返回(session,error)路由选择后的session,error异常 Router(mapperName string, engine SessionEngine) (Session, error) //设置sql.DB,该方法会被GoMybatis框架内调用 SetDB(driver string, url string, db *sql.DB) Name() string }
数据源路由接口
type ElementType ¶
type ElementType = string
const ( //root elements Element_ResultMap ElementType = "resultMap" Element_Insert ElementType = "insert" Element_Delete ElementType = "delete" Element_Update ElementType = `update` Element_Select ElementType = "select" Element_Sql ElementType = "sql" //root templete elements Element_Insert_Templete ElementType = "insertTemplete" Element_Delete_Templete ElementType = "deleteTemplete" Element_Update_Templete ElementType = `updateTemplete` Element_Select_Templete ElementType = "selectTemplete" //child elements Element_bind ElementType = "bind" Element_String ElementType = "string" Element_If ElementType = `if` Element_Trim ElementType = "trim" Element_Foreach ElementType = "foreach" Element_Set ElementType = "set" Element_choose ElementType = "choose" Element_when ElementType = "when" Element_otherwise ElementType = "otherwise" Element_where ElementType = "where" Element_Include ElementType = "include" )
type ExpressionEngineLexerCache ¶
type ExpressionEngineLexerCache interface { Set(expression string, lexer interface{}) error Get(expression string) (interface{}, error) Name() string }
Lexer 结果缓存
type ExpressionEngineLexerMapCache ¶
type ExpressionEngineLexerMapCache struct {
// contains filtered or unexported fields
}
func (*ExpressionEngineLexerMapCache) Get ¶
func (it *ExpressionEngineLexerMapCache) Get(expression string) (interface{}, error)
func (*ExpressionEngineLexerMapCache) Name ¶
func (it *ExpressionEngineLexerMapCache) Name() string
func (ExpressionEngineLexerMapCache) New ¶
func (it ExpressionEngineLexerMapCache) New() ExpressionEngineLexerMapCache
func (*ExpressionEngineLexerMapCache) Set ¶
func (it *ExpressionEngineLexerMapCache) Set(expression string, lexer interface{}) error
type ExpressionEngineProxy ¶
type ExpressionEngineProxy struct {
// contains filtered or unexported fields
}
func (*ExpressionEngineProxy) Eval ¶
func (it *ExpressionEngineProxy) Eval(lexerResult interface{}, arg interface{}, operation int) (interface{}, error)
执行一个表达式 参数:lexerResult=编译结果,arg=参数 返回:执行结果,错误
func (*ExpressionEngineProxy) Lexer ¶
func (it *ExpressionEngineProxy) Lexer(expression string) (interface{}, error)
编译一个表达式 参数:lexerArg 表达式内容 返回:interface{} 编译结果,error 错误
func (*ExpressionEngineProxy) LexerAndEval ¶
func (it *ExpressionEngineProxy) LexerAndEval(expression string, arg interface{}) (interface{}, error)
执行
func (*ExpressionEngineProxy) LexerCache ¶
func (it *ExpressionEngineProxy) LexerCache() ExpressionEngineLexerCache
func (*ExpressionEngineProxy) LexerCacheable ¶
func (it *ExpressionEngineProxy) LexerCacheable() bool
func (ExpressionEngineProxy) New ¶
func (ExpressionEngineProxy) New(engine ast.ExpressionEngine, useLexerCache bool) ExpressionEngineProxy
engine :表达式引擎,useLexerCache:是否缓存Lexer表达式编译结果
func (*ExpressionEngineProxy) SetExpressionEngine ¶
func (it *ExpressionEngineProxy) SetExpressionEngine(engine ast.ExpressionEngine)
引擎名称
func (*ExpressionEngineProxy) SetLexerCache ¶
func (it *ExpressionEngineProxy) SetLexerCache(cache ExpressionEngineLexerCache)
func (*ExpressionEngineProxy) SetUseLexerCache ¶
func (it *ExpressionEngineProxy) SetUseLexerCache(isUseCache bool) error
type GoMybatisDataSourceRouter ¶
type GoMybatisDataSourceRouter struct {
// contains filtered or unexported fields
}
动态数据源路由
func (*GoMybatisDataSourceRouter) Name ¶
func (it *GoMybatisDataSourceRouter) Name() string
func (GoMybatisDataSourceRouter) New ¶
func (it GoMybatisDataSourceRouter) New(routerFunc func(mapperName string) *string) GoMybatisDataSourceRouter
初始化路由,routerFunc为nil或者routerFunc返回nil,则框架自行选择第一个数据库作为数据源
func (*GoMybatisDataSourceRouter) Router ¶
func (it *GoMybatisDataSourceRouter) Router(mapperName string, engine SessionEngine) (Session, error)
type GoMybatisEngine ¶
type GoMybatisEngine struct {
// contains filtered or unexported fields
}
func (*GoMybatisEngine) DataSourceRouter ¶
func (it *GoMybatisEngine) DataSourceRouter() DataSourceRouter
func (*GoMybatisEngine) ExpressionEngine ¶
func (it *GoMybatisEngine) ExpressionEngine() ast.ExpressionEngine
表达式执行引擎
func (*GoMybatisEngine) GetObj ¶
func (it *GoMybatisEngine) GetObj(name string) interface{}
func (*GoMybatisEngine) GoroutineIDEnable ¶
func (it *GoMybatisEngine) GoroutineIDEnable() bool
func (*GoMybatisEngine) GoroutineSessionMap ¶
func (it *GoMybatisEngine) GoroutineSessionMap() *GoroutineSessionMap
func (*GoMybatisEngine) Name ¶
func (it *GoMybatisEngine) Name() string
func (GoMybatisEngine) New ¶
func (it GoMybatisEngine) New() GoMybatisEngine
func (*GoMybatisEngine) NewSession ¶
func (it *GoMybatisEngine) NewSession(mapperName string) (Session, error)
func (*GoMybatisEngine) Open ¶
func (it *GoMybatisEngine) Open(driverName, dataSourceName string) (*sql.DB, error)
打开数据库 driverName: 驱动名称例如"mysql", dataSourceName: string 数据库url
func (*GoMybatisEngine) RegisterObj ¶
func (it *GoMybatisEngine) RegisterObj(ptr interface{}, name string)
func (*GoMybatisEngine) SessionFactory ¶
func (it *GoMybatisEngine) SessionFactory() *SessionFactory
session工厂
func (*GoMybatisEngine) SetDataSourceRouter ¶
func (it *GoMybatisEngine) SetDataSourceRouter(router DataSourceRouter)
func (*GoMybatisEngine) SetExpressionEngine ¶
func (it *GoMybatisEngine) SetExpressionEngine(engine ast.ExpressionEngine)
设置表达式执行引擎
func (*GoMybatisEngine) SetGoroutineIDEnable ¶
func (it *GoMybatisEngine) SetGoroutineIDEnable(enable bool)
func (*GoMybatisEngine) SetLogEnable ¶
func (it *GoMybatisEngine) SetLogEnable(enable bool)
设置日志实现类,是否启用日志
func (*GoMybatisEngine) SetSessionFactory ¶
func (it *GoMybatisEngine) SetSessionFactory(factory *SessionFactory)
设置session工厂
func (*GoMybatisEngine) SetSqlArgTypeConvert ¶
func (it *GoMybatisEngine) SetSqlArgTypeConvert(convert ast.SqlArgTypeConvert)
设置sql类型转换器
func (*GoMybatisEngine) SetSqlBuilder ¶
func (it *GoMybatisEngine) SetSqlBuilder(builder SqlBuilder)
设置sql构建器
func (*GoMybatisEngine) SetSqlResultDecoder ¶
func (it *GoMybatisEngine) SetSqlResultDecoder(decoder SqlResultDecoder)
设置sql查询结果解析器
func (*GoMybatisEngine) SetTempleteDecoder ¶
func (it *GoMybatisEngine) SetTempleteDecoder(decoder TempleteDecoder)
设置模板解析器
func (*GoMybatisEngine) SqlArgTypeConvert ¶
func (it *GoMybatisEngine) SqlArgTypeConvert() ast.SqlArgTypeConvert
sql类型转换器
func (*GoMybatisEngine) SqlResultDecoder ¶
func (it *GoMybatisEngine) SqlResultDecoder() SqlResultDecoder
sql查询结果解析器
func (*GoMybatisEngine) TempleteDecoder ¶
func (it *GoMybatisEngine) TempleteDecoder() TempleteDecoder
模板解析器
func (*GoMybatisEngine) WriteMapperPtr ¶
func (it *GoMybatisEngine) WriteMapperPtr(ptr interface{}, xml []byte)
type GoMybatisSqlBuilder ¶
type GoMybatisSqlBuilder struct {
// contains filtered or unexported fields
}
func (*GoMybatisSqlBuilder) EnableLog ¶
func (it *GoMybatisSqlBuilder) EnableLog() bool
func (*GoMybatisSqlBuilder) ExpressionEngineProxy ¶
func (it *GoMybatisSqlBuilder) ExpressionEngineProxy() *ExpressionEngineProxy
func (*GoMybatisSqlBuilder) LogSystem ¶
func (it *GoMybatisSqlBuilder) LogSystem() *LogSystem
func (GoMybatisSqlBuilder) New ¶
func (it GoMybatisSqlBuilder) New(SqlArgTypeConvert ast.SqlArgTypeConvert, expressionEngine ExpressionEngineProxy, log Log, enableLog bool) GoMybatisSqlBuilder
func (*GoMybatisSqlBuilder) NodeParser ¶
func (it *GoMybatisSqlBuilder) NodeParser() ast.NodeParser
func (*GoMybatisSqlBuilder) SetEnableLog ¶
func (it *GoMybatisSqlBuilder) SetEnableLog(enable bool)
func (*GoMybatisSqlBuilder) SqlArgTypeConvert ¶
func (it *GoMybatisSqlBuilder) SqlArgTypeConvert() ast.SqlArgTypeConvert
type GoMybatisSqlResultDecoder ¶
type GoMybatisSqlResultDecoder struct {
SqlResultDecoder
}
func (GoMybatisSqlResultDecoder) Decode ¶
func (it GoMybatisSqlResultDecoder) Decode(resultMap map[string]*ResultProperty, sqlResult []map[string][]byte, result interface{}) error
type GoMybatisTempleteDecoder ¶
type GoMybatisTempleteDecoder struct { }
* TODO sqlTemplete解析器,目前直接操作*etree.Element实现,后期应该改成操作xml,换取更好的维护性
func (*GoMybatisTempleteDecoder) Decode ¶
func (it *GoMybatisTempleteDecoder) Decode(method *reflect.StructField, mapper *etree.Element, tree map[string]etree.Token) error
func (*GoMybatisTempleteDecoder) DecodeSets ¶
func (it *GoMybatisTempleteDecoder) DecodeSets(arg string, mapper *etree.Element, logic LogicDeleteData, versionData *VersionData)
func (*GoMybatisTempleteDecoder) DecodeTree ¶
func (*GoMybatisTempleteDecoder) DecodeWheres ¶
func (it *GoMybatisTempleteDecoder) DecodeWheres(arg string, mapper *etree.Element, logic LogicDeleteData, versionData *VersionData)
解码逗号分隔的where
type GoroutineSessionMap ¶
type GoroutineSessionMap struct {
// contains filtered or unexported fields
}
func (*GoroutineSessionMap) Delete ¶
func (it *GoroutineSessionMap) Delete(k int64)
func (*GoroutineSessionMap) Get ¶
func (it *GoroutineSessionMap) Get(k int64) Session
func (GoroutineSessionMap) New ¶
func (it GoroutineSessionMap) New() GoroutineSessionMap
func (*GoroutineSessionMap) Put ¶
func (it *GoroutineSessionMap) Put(k int64, session Session)
type LocalSession ¶
type LocalSession struct { SessionId string // contains filtered or unexported fields }
本地直连session
func (*LocalSession) Begin ¶
func (it *LocalSession) Begin(p *tx.Propagation) error
func (*LocalSession) Close ¶
func (it *LocalSession) Close()
func (*LocalSession) Commit ¶
func (it *LocalSession) Commit() error
func (*LocalSession) Id ¶
func (it *LocalSession) Id() string
func (LocalSession) New ¶
func (it LocalSession) New(driver string, url string, db *sql.DB, logSystem Log) LocalSession
func (*LocalSession) Query ¶
func (it *LocalSession) Query(sqlorArgs string) ([]map[string][]byte, error)
func (*LocalSession) Rollback ¶
func (it *LocalSession) Rollback() error
type LogStandard ¶
type LogStandard struct {
PrintlnFunc func(messages []byte) //日志输出方法实现
}
type LogSystem ¶
type LogSystem struct {
// contains filtered or unexported fields
}
type LogicDeleteData ¶
type ResultProperty ¶
type ReturnType ¶
type SessionEngine ¶
type SessionEngine interface { //打开数据库 Open(driverName, dataSourceName string) (*sql.DB, error) //写方法到mapper WriteMapperPtr(ptr interface{}, xml []byte) //引擎名称 Name() string //创建session NewSession(mapperName string) (Session, error) //获取数据源路由 DataSourceRouter() DataSourceRouter //设置数据源路由 SetDataSourceRouter(router DataSourceRouter) //是否启用日志 LogEnable() bool //是否启用日志 SetLogEnable(enable bool) //获取日志实现类 Log() Log //设置日志实现类 SetLog(log Log) //session工厂 SessionFactory() *SessionFactory //设置session工厂 SetSessionFactory(factory *SessionFactory) //sql类型转换器 SqlArgTypeConvert() ast.SqlArgTypeConvert //设置sql类型转换器 SetSqlArgTypeConvert(convert ast.SqlArgTypeConvert) //表达式执行引擎 ExpressionEngine() ast.ExpressionEngine //设置表达式执行引擎 SetExpressionEngine(engine ast.ExpressionEngine) //sql构建器 SqlBuilder() SqlBuilder //设置sql构建器 SetSqlBuilder(builder SqlBuilder) //sql查询结果解析器 SqlResultDecoder() SqlResultDecoder //设置sql查询结果解析器 SetSqlResultDecoder(decoder SqlResultDecoder) //模板解析器 TempleteDecoder() TempleteDecoder //设置模板解析器 SetTempleteDecoder(decoder TempleteDecoder) RegisterObj(ptr interface{}, name string) GetObj(name string) interface{} //(注意(该方法需要在多协程环境下调用)启用会从栈获取协程id,有一定性能消耗,换取最大的事务定义便捷) GoroutineSessionMap() *GoroutineSessionMap //是否启用goroutineIDEnable(注意(该方法需要在多协程环境下调用)启用会从栈获取协程id,有一定性能消耗,换取最大的事务定义便捷) SetGoroutineIDEnable(enable bool) //是否启用goroutineIDEnable(注意(该方法需要在多协程环境下调用)启用会从栈获取协程id,有一定性能消耗,换取最大的事务定义便捷) GoroutineIDEnable() bool }
产生session的引擎
type SessionFactory ¶
type SessionFactory struct { Engine SessionEngine SessionMap map[string]Session }
func (*SessionFactory) Close ¶
func (it *SessionFactory) Close(id string)
func (*SessionFactory) CloseAll ¶
func (it *SessionFactory) CloseAll(id string)
func (*SessionFactory) GetSession ¶
func (it *SessionFactory) GetSession(id string) Session
func (SessionFactory) New ¶
func (it SessionFactory) New(Engine SessionEngine) SessionFactory
func (*SessionFactory) NewSession ¶
func (it *SessionFactory) NewSession(mapperName string, sessionType SessionType) Session
func (*SessionFactory) SetSession ¶
func (it *SessionFactory) SetSession(id string, session Session)
type SessionFactorySession ¶
type SessionFactorySession struct { Session Session Factory *SessionFactory }
func (*SessionFactorySession) Begin ¶
func (it *SessionFactorySession) Begin(p *tx.Propagation) error
func (*SessionFactorySession) Close ¶
func (it *SessionFactorySession) Close()
func (*SessionFactorySession) Commit ¶
func (it *SessionFactorySession) Commit() error
func (*SessionFactorySession) Exec ¶
func (it *SessionFactorySession) Exec(sqlorArgs string) (*Result, error)
func (*SessionFactorySession) Id ¶
func (it *SessionFactorySession) Id() string
func (*SessionFactorySession) Query ¶
func (it *SessionFactorySession) Query(sqlorArgs string) ([]map[string][]byte, error)
func (*SessionFactorySession) Rollback ¶
func (it *SessionFactorySession) Rollback() error
type SessionSupport ¶
type SessionType ¶
type SessionType = int
const ( SessionType_Default SessionType = iota //默认session类型 SessionType_Local //本地session )
type SqlBuilder ¶
type SqlBuilder interface { BuildSql(paramMap map[string]interface{}, nodes []ast.Node) (string, error) ExpressionEngineProxy() *ExpressionEngineProxy SqlArgTypeConvert() ast.SqlArgTypeConvert LogSystem() *LogSystem SetEnableLog(enable bool) EnableLog() bool NodeParser() ast.NodeParser }
sql文本构建
type SqlResultDecoder ¶
type SqlResultDecoder interface { //resultMap = in xml resultMap element //dbData = select the SqlResult //decodeResultPtr = need decode result type Decode(resultMap map[string]*ResultProperty, SqlResult []map[string][]byte, decodeResultPtr interface{}) error }
sql查询结果解码
type TempleteDecoder ¶
type VersionData ¶
Source Files ¶
- CallBack.go
- DataSourceRouter.go
- ElementType.go
- ExpressionEngineLexerCache.go
- ExpressionEngineLexerCacheable.go
- ExpressionEngineLexerMapCache.go
- ExpressionEngineProxy.go
- GoMybatis.go
- GoMybatisConst.go
- GoMybatisDataSourceRouter.go
- GoMybatisEnableType.go
- GoMybatisEngine.go
- GoMybatisProxy.go
- GoMybatisReturnType.go
- GoMybatisRowsDecoder.go
- GoMybatisSqlArgTypeConvert.go
- GoMybatisSqlBuilder.go
- GoMybatisSqlResultDecoder.go
- GoMybatisTempleteDecoder.go
- GoroutineSessionMap.go
- LocalSession.go
- Log.go
- LogStandard.go
- LogSystem.go
- ProxyArg.go
- ResultMap.go
- SessionFactory.go
- SessionFactorySession.go
- SessionSupport.go
- SessionType.go
- SqlBuilder.go
- SqlEngine.go
- SqlResultDecoder.go
- TempleteDecoder.go
- TransactionAspectSupport.go
- XmlLoader.go
- type.go
Directories ¶
Path | Synopsis |
---|---|
lib
|
|
github.com/antonmedv/expr
Package expr is an engine that can evaluate expressions.
|
Package expr is an engine that can evaluate expressions. |
github.com/beevik/etree
Package etree provides XML services through an Element Tree abstraction.
|
Package etree provides XML services through an Element Tree abstraction. |