Documentation
¶
Index ¶
- Constants
- Variables
- func AopProxyService(service interface{}, engine IEngine)
- func AopProxyServiceValue(service reflect.Value, engine IEngine)
- func ByteConvertXml(bytes []byte) (items map[string]etree.Token)
- func CreateXml(tableName string, bean interface{}) []byte
- func IsDir(path string) bool
- func IsExist(path string) bool
- func IsFile(path string) bool
- func OutPutXml(pointer interface{}, xmlFilePath string)
- func Proxy(proxyPtr interface{}, ...)
- func ProxyValue(mapperValue reflect.Value, ...)
- func Snake(arg interface{}) string
- func SnakeStr(s string) string
- type Config
- type DataSource
- type ElementType
- type Engine
- func (it *Engine) GetDBRouter() IDataSource
- func (it *Engine) GetExpression() ast.IExpression
- func (it *Engine) GetGoroutine() *SessionMap
- func (it *Engine) GetLog() ILog
- func (it *Engine) GetSessionFactory() *SessionFactory
- func (it *Engine) GetSqlBuilder() ISqlBuilder
- func (it *Engine) GetSqlResultDecoder() ISqlResultDecoder
- func (it *Engine) GetTpl() ITplDecoder
- func (it *Engine) ID(node int64) ids.ID
- func (it *Engine) IsGoroutine() bool
- func (it *Engine) IsLog() bool
- func (it *Engine) IsPrintWarn() bool
- func (it *Engine) LogSystem() *LogSystem
- func (it *Engine) Name() string
- func (it *Engine) NewSession(mapperName string) (ISession, error)
- func (it *Engine) One(mapperPtr interface{}) IEngine
- func (it *Engine) Register(filePath string, h H) IEngine
- func (it *Engine) Run()
- func (it *Engine) SetExpression(engine ast.IExpression)
- func (it *Engine) SetGoroutine(enable bool)
- func (it *Engine) SetLog(log ILog)
- func (it *Engine) SetLogEnable(enable bool)
- func (it *Engine) SetPrintWarn(print bool)
- func (it *Engine) SetSessionFactory(factory *SessionFactory)
- func (it *Engine) SetSqlArgTypeConvert(convert ast.SqlArgTypeConvert)
- func (it *Engine) SetSqlBuilder(builder ISqlBuilder)
- func (it *Engine) SetSqlResultDecoder(decoder ISqlResultDecoder)
- func (it *Engine) SetTpl(decoder ITplDecoder)
- func (it *Engine) Use(router IDataSource)
- type ExpressionCache
- type ExpressionProxy
- func (it *ExpressionProxy) Eval(lexerResult interface{}, arg interface{}, operation int) (interface{}, error)
- func (it *ExpressionProxy) Lexer(expression string) (interface{}, error)
- func (it *ExpressionProxy) LexerAndEval(expression string, arg interface{}) (interface{}, error)
- func (it *ExpressionProxy) LexerCache() IExpressionLexerCache
- func (it *ExpressionProxy) LexerCacheable() bool
- func (it ExpressionProxy) Name() string
- func (it *ExpressionProxy) SetExpressionEngine(engine ast.IExpression)
- func (it *ExpressionProxy) SetLexerCache(cache IExpressionLexerCache)
- func (it *ExpressionProxy) SetUseLexerCache(isUseCache bool) error
- type H
- type IDataSource
- type IEngine
- type IExpressionLexerCache
- type IExpressionLexerCacheable
- type ILog
- type ISession
- type ISqlBuilder
- type ISqlResultDecoder
- type ITplDecoder
- type LogStandard
- type LogSystem
- type LogicDeleteData
- type Mapper
- type ProxyArg
- type Result
- type ResultProperty
- type ReturnType
- type Session
- func (it *Session) Begin(p *tx.Propagation) error
- func (it *Session) Close()
- func (it *Session) Commit() error
- func (it *Session) Exec(args string) (*Result, error)
- func (it *Session) ExecPrepare(sqlPrepare string, args ...interface{}) (*Result, error)
- func (it *Session) Id() string
- func (it *Session) LastPropagation() *tx.Propagation
- func (it Session) New(driverType string, driverLink string, db *sql.DB, logSystem ILog) Session
- func (it *Session) Query(args string) ([]map[string][]byte, error)
- func (it *Session) QueryPrepare(sqlPrepare string, args ...interface{}) ([]map[string][]byte, error)
- func (it *Session) Rollback() error
- func (it *Session) StmtConvert() (stmt.IConvert, error)
- type SessionFactory
- func (it *SessionFactory) Close(id string)
- func (it *SessionFactory) CloseAll(id string)
- func (it *SessionFactory) GetSession(id string) ISession
- func (it *SessionFactory) NewSession(mapperName string, sessionType SessionType) ISession
- func (it *SessionFactory) SetSession(id string, session ISession)
- type SessionFactorySession
- func (it *SessionFactorySession) Begin(p *tx.Propagation) error
- func (it *SessionFactorySession) Close()
- func (it *SessionFactorySession) Commit() error
- func (it *SessionFactorySession) Exec(sqlOrArg string) (*Result, error)
- func (it *SessionFactorySession) ExecPrepare(sqlOrArg string, args ...interface{}) (*Result, error)
- func (it *SessionFactorySession) Id() string
- func (it *SessionFactorySession) LastPropagation() *tx.Propagation
- func (it *SessionFactorySession) Query(sqlOrArg string) ([]map[string][]byte, error)
- func (it *SessionFactorySession) QueryPrepare(sqlOrArg string, args ...interface{}) ([]map[string][]byte, error)
- func (it *SessionFactorySession) Rollback() error
- func (it *SessionFactorySession) StmtConvert() (stmt.IConvert, error)
- type SessionMap
- type SessionType
- type SqlArgTypeConvert
- type SqlBuilder
- func (it *SqlBuilder) BuildSql(args map[string]interface{}, node []ast.Node, array *[]interface{}, ...) (string, error)
- func (it *SqlBuilder) EnableLog() bool
- func (it *SqlBuilder) ExpressionEngineProxy() *ExpressionProxy
- func (it *SqlBuilder) NodeParser() ast.NodeParser
- func (it *SqlBuilder) SetSqlLog(enable bool)
- type SqlResultDecoder
- type TagArg
- type TplDecoder
- func (it *TplDecoder) Decode(method *reflect.StructField, mapper *etree.Element, ...) (bool, error)
- func (it *TplDecoder) DecodeCollectionName(method *reflect.StructField) string
- func (it *TplDecoder) DecodeSets(arg string, mapper *etree.Element, logic LogicDeleteData, ...)
- func (it *TplDecoder) DecodeTree(tree map[string]etree.Token, beanType reflect.Type) error
- func (it *TplDecoder) DecodeWheres(arg string, mapper *etree.Element, logic LogicDeleteData, ...)
- func (it *TplDecoder) PrintElement(print bool)
- type Tx
- type VersionData
Constants ¶
const ( MSessionPtr = `*mbt.ISession` MSession = `mbt.ISession` GoMybatisTime = `time.Time` GoMybatisTimePtr = `*time.Time` DefaultOneArg = `arg` //默认参数前缀,例如arg0 arg1 arg2 .... )
const ( ElementMapper = "mapper" ID = `id` )
const AdapterFormatDate = `2006-01-02 15:04:05`
const SessionFunc = "Session"
(原NewSessionFunc)Session method,auto write implement body code
Variables ¶
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) )
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) )
var ( XmlLogicEnable = `logic_enable="true" logic_undelete="1" logic_deleted="0"` XmlVersionEnable = `version_enable="true"` ResultItem = `<result column="#{column}" langType="#{langType}" #{version} #{logic}/>` )
var XmlData = `` /* 711-byte string literal not displayed */
Functions ¶
func AopProxyService ¶
func AopProxyService(service interface{}, engine IEngine)
使用AOP切面 代理目标服务,如果服务panic()它的事务会回滚 默认为单协程模型,如果是多协程调用的情况请开启engine.SetGoroutineIDEnable(true)
func AopProxyServiceValue ¶
使用AOP切面 代理目标服务,如果服务panic()它的事务会回滚
func ByteConvertXml ¶ added in v1.0.4
ByteConvertXml(原LoadMapperXml): 将输入的 byte 形式的 xml 文件转换成 map[string]etree.Token形式的 xml
返回值 map[string]etree.Token 就是个这么个玩意儿,例如: &{ select [{ id selectByIds} { resultMap BaseResultMap}] [0xc0000de260 0xc0000b04e0 0xc0000de2c0 0xc0000b05a0 0xc0000de460 0xc0000b0720 0xc0000de4c0] 0xc0000b0300} &{ select [{ id selectByIdsMap}] [0xc0000de520 0xc0000b0840 0xc0000de5a0] 0xc0000b0300} &{ update [{ id updateById}] [0xc0000de600 0xc0000b0960 0xc0000de8e0] 0xc0000b0300} &{ select [{ id choose} { resultMap BaseResultMap}] [0xc0000de940 0xc0000b0d20 0xc0000deb00] 0xc0000b0300}
func OutPutXml ¶
func OutPutXml(pointer interface{}, xmlFilePath string)
输出文件 参数<pointer>为struct/*struct
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 可写入每个函数代理方法
Types ¶
type Config ¶ added in v1.0.2
type Config struct { DriverName string // 驱动名称。例如: mysql,postgreSQL... DSN string // 数据库连接信息。例如: "root:root@(127.0.0.1:3306)/test?charset=utf8&parseTime=True&loc=Local" MaxOpenConn int // 最大的并发打开连接数。例如: 这个值是5则表示==>连接池中最多有5个并发打开的连接,如果5个连接都已经打开被使用,并且应用程序需要另一个连接的话,那么应用程序将被迫等待,直到5个打开的连接其中的一个被释放并变为空闲。 MaxIdleConn int // 最大的空闲连接数。注意: MaxIdleConn 应该始终小于或等于 MaxOpenConn,设置比 MaxOpenConn 更多的空闲连接数是没有意义的,因为你最多也就能拿到所有打开的连接,剩余的空闲连接依然保持的空闲。 ConnMaxLifetime time.Duration // 连接的最大生命周期(默认值:0)。设置为0的话意味着没有最大生命周期,连接总是可重用。注意: ConnMaxLifetime 越短,从零开始创建连接的频率就越高! ConnMaxIdleTime time.Duration }
数据库配置信息
type DataSource ¶ added in v1.0.3
type DataSource struct {
// contains filtered or unexported fields
}
动态数据源路由(原GoMybatisDataSourceRouter)
func NewRouter ¶
func NewRouter(routerFunc func(mapperName string) *string) DataSource
初始化路由,routerFunc为nil或者routerFunc返回nil,则框架自行选择第一个数据库作为数据源
func (*DataSource) Name ¶ added in v1.0.3
func (it *DataSource) Name() string
type ElementType ¶
type ElementType = string
const ( //root elements ElementResultMap ElementType = "resultMap" ElementInsert ElementType = "insert" ElementDelete ElementType = "delete" ElementUpdate ElementType = `update` ElementSelect ElementType = "select" ElementSql ElementType = "sql" //root template elements ElementInsertTemplate ElementType = "insertTemplate" ElementDeleteTemplate ElementType = "deleteTemplate" ElementUpdateTemplate ElementType = `updateTemplate` ElementSelectTemplate ElementType = "selectTemplate" //child elements ElementBind ElementType = "bind" ElementString ElementType = "string" // ElementIf ElementType = `if` ElementTrim ElementType = "trim" ElementForeach ElementType = "for" // ElementSet ElementType = "set" ElementChoose ElementType = "switch" // ElementWhen ElementType = "case" // ElementOtherwise ElementType = "default" // ElementWhere ElementType = "where" ElementInclude ElementType = "include" )
type Engine ¶
Engine 一个 Engine 对象只操作一个SQL数据库!
func (*Engine) GetDBRouter ¶
func (it *Engine) GetDBRouter() IDataSource
func (*Engine) GetExpression ¶
func (it *Engine) GetExpression() ast.IExpression
(原ExpressionEngine)获取表达式执行引擎
func (*Engine) GetSqlResultDecoder ¶
func (it *Engine) GetSqlResultDecoder() ISqlResultDecoder
sql查询结果解析器
func (*Engine) NewSession ¶
mapperName 即: mapperDao
func (*Engine) One ¶ added in v1.1.3
One 运行单个 dao 对象,该方法主要用于测试 dao 对象中的方法!
参数<mapperPtr>是指dao结构体(真正操作数据库的结构体)
func (*Engine) Register ¶ added in v1.1.0
Register 注册 mapperPtr 与 modelPtr的映射关系.参数<filePath>不能为空! H 的key是:指针类型的mapperPtr,value是:指针类型的modelPtr
func (*Engine) SetGoroutine ¶
func (*Engine) SetSessionFactory ¶
func (it *Engine) SetSessionFactory(factory *SessionFactory)
设置session工厂
func (*Engine) SetSqlArgTypeConvert ¶
func (it *Engine) SetSqlArgTypeConvert(convert ast.SqlArgTypeConvert)
设置sql类型转换器
func (*Engine) SetSqlResultDecoder ¶
func (it *Engine) SetSqlResultDecoder(decoder ISqlResultDecoder)
设置sql查询结果解析器
func (*Engine) Use ¶ added in v1.0.2
func (it *Engine) Use(router IDataSource)
Use 原(SetDataSourceRouter)设置动态数据库,参数<router>是mbt.NewRouter()的返回值。
type ExpressionCache ¶ added in v1.1.5
type ExpressionCache struct {
// contains filtered or unexported fields
}
原 (ExpressionEngineLexerMapCache)表达式引擎缓存
func (*ExpressionCache) Get ¶ added in v1.1.5
func (it *ExpressionCache) Get(expression string) (interface{}, error)
func (*ExpressionCache) Name ¶ added in v1.1.5
func (it *ExpressionCache) Name() string
func (ExpressionCache) New ¶ added in v1.1.5
func (it ExpressionCache) New() ExpressionCache
func (*ExpressionCache) Set ¶ added in v1.1.5
func (it *ExpressionCache) Set(expression string, lexer interface{}) error
type ExpressionProxy ¶
type ExpressionProxy struct {
// contains filtered or unexported fields
}
表达式引擎代理
func NewExpressionProxy ¶
func NewExpressionProxy(engine ast.IExpression, useLexerCache bool) ExpressionProxy
engine :表达式引擎,useLexerCache:是否缓存Lexer表达式编译结果
func (*ExpressionProxy) Eval ¶
func (it *ExpressionProxy) Eval(lexerResult interface{}, arg interface{}, operation int) (interface{}, error)
执行一个表达式 参数:lexerResult=编译结果,arg=参数 返回:执行结果,错误
func (*ExpressionProxy) Lexer ¶
func (it *ExpressionProxy) Lexer(expression string) (interface{}, error)
编译一个表达式 参数:lexerArg 表达式内容 返回:interface{} 编译结果,error 错误
func (*ExpressionProxy) LexerAndEval ¶
func (it *ExpressionProxy) LexerAndEval(expression string, arg interface{}) (interface{}, error)
执行
func (*ExpressionProxy) LexerCache ¶
func (it *ExpressionProxy) LexerCache() IExpressionLexerCache
func (*ExpressionProxy) LexerCacheable ¶
func (it *ExpressionProxy) LexerCacheable() bool
func (*ExpressionProxy) SetExpressionEngine ¶
func (it *ExpressionProxy) SetExpressionEngine(engine ast.IExpression)
引擎名称
func (*ExpressionProxy) SetLexerCache ¶
func (it *ExpressionProxy) SetLexerCache(cache IExpressionLexerCache)
func (*ExpressionProxy) SetUseLexerCache ¶
func (it *ExpressionProxy) SetUseLexerCache(isUseCache bool) error
type IDataSource ¶ added in v1.0.3
type IDataSource interface { //路由规则 //参数:mapperName mapper文件包名+名称例如(example.ActivityDao) //返回(session,error)路由选择后的session,error异常 Router(mapperName string, engine IEngine) (ISession, error) //设置sql.DB,该方法会被GoMybatis框架内调用 SetDB(driverName string, dsn string, db *sql.DB) Name() string }
数据源路由接口
type IEngine ¶ added in v1.0.2
type IEngine interface { // One 运行单个 dao 对象,该方法主要用于测试 dao 对象中的方法! // 参数<mapperPtr>是指dao结构体(真正操作数据库的结构体) One(mapperPtr interface{}) IEngine Register(filePath string, h H) IEngine Run() //引擎名称 Name() string //创建session NewSession(mapperName string) (ISession, error) //获取数据源路由 GetDBRouter() IDataSource //设置数据源路由 //SetDBRouter(router IDataSourceRouter) Use(router IDataSource) //是否启用日志 IsLog() bool //是否启用日志 SetLogEnable(enable bool) //(原Log)获取日志实现类 GetLog() ILog //设置日志实现类 SetLog(log ILog) //session工厂 GetSessionFactory() *SessionFactory //设置session工厂 SetSessionFactory(factory *SessionFactory) //设置sql类型转换器 SetSqlArgTypeConvert(convert ast.SqlArgTypeConvert) //表达式执行引擎 GetExpression() ast.IExpression //设置表达式执行引擎 SetExpression(engine ast.IExpression) //sql构建器 GetSqlBuilder() ISqlBuilder //设置sql构建器 SetSqlBuilder(builder ISqlBuilder) //sql查询结果解析器 GetSqlResultDecoder() ISqlResultDecoder //设置sql查询结果解析器 SetSqlResultDecoder(decoder ISqlResultDecoder) //模板解析器 GetTpl() ITplDecoder //设置模板解析器 SetTpl(decoder ITplDecoder) //(注意(该方法需要在多协程环境下调用)启用会从栈获取协程id,有一定性能消耗,换取最大的事务定义便捷) GetGoroutine() *SessionMap //是否启用goroutineIDEnable(注意(该方法需要在多协程环境下调用)启用会从栈获取协程id,有一定性能消耗,换取最大的事务定义便捷) SetGoroutine(enable bool) //(原GoroutineIDEnable)是否启用goroutineIDEnable(注意(该方法需要在多协程环境下调用)启用会从栈获取协程id,有一定性能消耗,换取最大的事务定义便捷) IsGoroutine() bool LogSystem() *LogSystem IsPrintWarn() bool // contains filtered or unexported methods }
IEngine (原SessionEngine)框架的引擎,对外暴露方法。
type IExpressionLexerCache ¶ added in v1.0.3
type IExpressionLexerCache interface { Set(expression string, lexer interface{}) error Get(expression string) (interface{}, error) Name() string }
原(ExpressionEngineLexerCache)Lexer 结果缓存
type IExpressionLexerCacheable ¶ added in v1.0.3
原(ExpressionEngineLexerCacheable)
type ISession ¶ added in v1.0.2
type ISession interface { Query(sqlOrArgs string) ([]map[string][]byte, error) Exec(sqlOrArgs string) (*Result, error) //Prepare sql, example sqlPrepare: select * from table where id = ? , args:'1' QueryPrepare(sqlPrepare string, args ...interface{}) ([]map[string][]byte, error) //Prepare sql, example sqlPrepare: select * from table where id = ? , args:'1' ExecPrepare(sqlPrepare string, args ...interface{}) (*Result, error) Begin(p *tx.Propagation) error Commit() error Rollback() error Id() string Close() LastPropagation() *tx.Propagation StmtConvert() (stmt.IConvert, error) }
ISession (原Session) 与数据库的一次会话(包括了 *sql.DB 和 *sql.Tx 操作)
调用这个接口,既可以,以非事务方式操作数据库,也可以,以事务方式操作数据库! 这个接口,封装了 *sql.DB 中方法,也封装了 *sql.Tx 中的方法!
type ISqlBuilder ¶
type ISqlBuilder interface { BuildSql(paramMap map[string]interface{}, nodes []ast.Node, array *[]interface{}, stmtConvert stmt.IConvert) (string, error) ExpressionEngineProxy() *ExpressionProxy SetSqlLog(enable bool) // (原SetEnableLog) EnableLog() bool NodeParser() ast.NodeParser }
sql文本构建
type ISqlResultDecoder ¶ added in v1.0.3
type ISqlResultDecoder 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 ITplDecoder ¶ added in v1.0.3
type ITplDecoder interface { PrintElement(print bool) DecodeTree(tree map[string]etree.Token, beanType reflect.Type) error }
ITplDecoder templateDecoder 接口,该接口由 TplDecoder实现
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 Session ¶
type Session struct { SessionId string // contains filtered or unexported fields }
Session 实现了 ISession 接口。
Session 进一步封装了 *sql.DB 和 *sql.Tx Session 将 *sql.DB 和 *sql.Tx 整合到了一起,并再其原有的功能上增加了新功能。
func (*Session) ExecPrepare ¶
func (*Session) LastPropagation ¶ added in v1.0.3
func (it *Session) LastPropagation() *tx.Propagation
func (*Session) QueryPrepare ¶
type SessionFactory ¶
func NewSessionFactory ¶
func NewSessionFactory(Engine IEngine) SessionFactory
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) ISession
func (*SessionFactory) NewSession ¶
func (it *SessionFactory) NewSession(mapperName string, sessionType SessionType) ISession
func (*SessionFactory) SetSession ¶
func (it *SessionFactory) SetSession(id string, session ISession)
type SessionFactorySession ¶
type SessionFactorySession struct { Session ISession 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(sqlOrArg string) (*Result, error)
func (*SessionFactorySession) ExecPrepare ¶
func (it *SessionFactorySession) ExecPrepare(sqlOrArg string, args ...interface{}) (*Result, error)
func (*SessionFactorySession) Id ¶
func (it *SessionFactorySession) Id() string
func (*SessionFactorySession) LastPropagation ¶ added in v1.0.2
func (it *SessionFactorySession) LastPropagation() *tx.Propagation
func (*SessionFactorySession) Query ¶
func (it *SessionFactorySession) Query(sqlOrArg string) ([]map[string][]byte, error)
func (*SessionFactorySession) QueryPrepare ¶
func (it *SessionFactorySession) QueryPrepare(sqlOrArg string, args ...interface{}) ([]map[string][]byte, error)
func (*SessionFactorySession) Rollback ¶
func (it *SessionFactorySession) Rollback() error
func (*SessionFactorySession) StmtConvert ¶
func (it *SessionFactorySession) StmtConvert() (stmt.IConvert, error)
type SessionMap ¶ added in v1.1.5
type SessionMap struct {
// contains filtered or unexported fields
}
(原GoroutineSessionMap)
func (*SessionMap) Delete ¶ added in v1.1.5
func (it *SessionMap) Delete(k int64)
func (*SessionMap) Get ¶ added in v1.1.5
func (it *SessionMap) Get(k int64) ISession
func (SessionMap) New ¶ added in v1.1.5
func (it SessionMap) New() SessionMap
func (*SessionMap) Put ¶ added in v1.1.5
func (it *SessionMap) Put(k int64, session ISession)
type SessionType ¶
type SessionType = int
const ( SessionTypeDefault SessionType = iota //默认session类型 SessionTypeLocal //本地session )
type SqlArgTypeConvert ¶ added in v1.0.4
type SqlArgTypeConvert struct{}
Sql内容类型转换器 (原GoMybatisSqlArgTypeConvert)
func (SqlArgTypeConvert) Convert ¶ added in v1.0.4
func (it SqlArgTypeConvert) Convert(argValue interface{}) string
Sql内容类型转换器
type SqlBuilder ¶
type SqlBuilder struct {
// contains filtered or unexported fields
}
func NewSqlBuilder ¶
func NewSqlBuilder(expressionEngine ExpressionProxy, log ILog, enableLog bool) SqlBuilder
func (*SqlBuilder) EnableLog ¶
func (it *SqlBuilder) EnableLog() bool
func (*SqlBuilder) ExpressionEngineProxy ¶
func (it *SqlBuilder) ExpressionEngineProxy() *ExpressionProxy
func (*SqlBuilder) NodeParser ¶
func (it *SqlBuilder) NodeParser() ast.NodeParser
func (*SqlBuilder) SetSqlLog ¶
func (it *SqlBuilder) SetSqlLog(enable bool)
type SqlResultDecoder ¶
type SqlResultDecoder struct {
ISqlResultDecoder
}
func (SqlResultDecoder) Decode ¶
func (it SqlResultDecoder) Decode(resultMap map[string]*ResultProperty, sqlResult []map[string][]byte, result interface{}) error
type TplDecoder ¶ added in v1.0.3
type TplDecoder struct {
// contains filtered or unexported fields
}
这个文件里各个方法中,函数中的字符串不要随便改,因为这些字符串与 ("gitee.com/gopher2011/mbt/pkg/etree"中的一一对应!) * TODO sqlTemplate解析器,目前直接操作*etree.Element实现,后期应该改成操作xml,换取更好的维护性
GoMybatisTemplateDecoder
func (*TplDecoder) Decode ¶ added in v1.0.3
func (it *TplDecoder) Decode(method *reflect.StructField, mapper *etree.Element, tree map[string]etree.Token) (bool, error)
Decode 该方法只对 <selectTemplate/> <insertTemplate/> <updateTemplate/> <deleteTemplate/> 这四个标签解码。
func (*TplDecoder) DecodeCollectionName ¶ added in v1.0.3
func (it *TplDecoder) DecodeCollectionName(method *reflect.StructField) string
反射解码得到 集合名词
func (*TplDecoder) DecodeSets ¶ added in v1.0.3
func (it *TplDecoder) DecodeSets(arg string, mapper *etree.Element, logic LogicDeleteData, versionData *VersionData)
func (*TplDecoder) DecodeTree ¶ added in v1.0.3
对 tree进行解码 参数 beanType 是被解析的 mapperPtr,例如 :example_test.go中的 ActivityDao 结构体!
func (*TplDecoder) DecodeWheres ¶ added in v1.0.3
func (it *TplDecoder) DecodeWheres(arg string, mapper *etree.Element, logic LogicDeleteData, versionData *VersionData)
解码逗号分隔的where
func (*TplDecoder) PrintElement ¶ added in v1.0.3
func (it *TplDecoder) PrintElement(print bool)
type VersionData ¶
Source Files
¶
- 10_sql_rows_decoder.go
- 11_data_source_router.go
- 12_templete_decoder.go
- 13_mbt_func.go
- 14_mbt_engine.go
- 15_log.go
- 1_element_type.go
- 1_interface.go
- 1_type_and_variable.go
- 2_expression_cache.go
- 2_expression_proxy.go
- 3_session_factory.go
- 3_session_factory_session.go
- 3_session_goroutine_map.go
- 3_session_local.go
- 3_session_local_transaction.go
- 4_proxy_func.go
- 5_xml_create.go
- 6_xml_loader.go
- 7_sql_builder.go
- 8_sql_result_decoder.go
- 9_sql_argtype_convert.go
Directories
¶
Path | Synopsis |
---|---|
internal
|
|
etree
软件包etree通过元素树抽象提供XML服务。
|
软件包etree通过元素树抽象提供XML服务。 |
pkg
|
|
ids
Package snowflake provides a very simple Twitter snowflake generator and parser.
|
Package snowflake provides a very simple Twitter snowflake generator and parser. |
uuid
Package uuid generates and inspects UUIDs.
|
Package uuid generates and inspects UUIDs. |