parent
afad52b41f
commit
9d1ad9e708
@ -1,16 +0,0 @@
|
||||
package dorm
|
||||
|
||||
import (
|
||||
"xorm.io/xorm"
|
||||
)
|
||||
|
||||
type XormClientConfigXorm struct {
|
||||
Dns string // 地址
|
||||
}
|
||||
|
||||
// XormClient
|
||||
// https://xorm.io/
|
||||
type XormClient struct {
|
||||
db *xorm.Engine // 驱动
|
||||
config *XormClientConfigXorm // 配置
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
package dorm
|
||||
|
||||
import (
|
||||
"xorm.io/builder"
|
||||
"xorm.io/xorm"
|
||||
)
|
||||
|
||||
// GetDb 获取驱动
|
||||
func (c *XormClient) GetDb() *xorm.Engine {
|
||||
return c.db
|
||||
}
|
||||
|
||||
func (c *XormClient) GetBuilder(dialect string) *builder.Builder {
|
||||
return builder.Dialect(dialect)
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
package dorm
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
_ "github.com/go-sql-driver/mysql"
|
||||
"xorm.io/xorm"
|
||||
)
|
||||
|
||||
func NewXormMysqlClient(config *XormClientConfigXorm) (*XormClient, error) {
|
||||
|
||||
var err error
|
||||
c := &XormClient{config: config}
|
||||
|
||||
c.db, err = xorm.NewEngine("mysql", c.config.Dns)
|
||||
if err != nil {
|
||||
return nil, errors.New(fmt.Sprintf("连接失败:%v", err))
|
||||
}
|
||||
|
||||
return c, nil
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
package dorm
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
_ "github.com/lib/pq"
|
||||
"xorm.io/xorm"
|
||||
)
|
||||
|
||||
func NewXormPostgresClient(config *XormClientConfigXorm) (*XormClient, error) {
|
||||
|
||||
var err error
|
||||
c := &XormClient{config: config}
|
||||
|
||||
c.db, err = xorm.NewEngine("postgres", c.config.Dns)
|
||||
if err != nil {
|
||||
return nil, errors.New(fmt.Sprintf("连接失败:%v", err))
|
||||
}
|
||||
|
||||
return c, nil
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
package dorm
|
||||
|
||||
import (
|
||||
"xorm.io/xorm"
|
||||
)
|
||||
|
||||
// XormClientSession https://xorm.io/zh/docs/chapter-10/readme/
|
||||
type XormClientSession struct {
|
||||
*xorm.Session
|
||||
}
|
||||
|
||||
// Begin 开始事务,需要创建 Session 对象
|
||||
//func (c *XormClient) Begin() (*XormClientSession, error) {
|
||||
// session := c.db.NewSession()
|
||||
// defer session.Close()
|
||||
// return &session, session.Begin()
|
||||
//}
|
||||
|
||||
// Rollback 回滚事务
|
||||
//func (c *XormClientSession) Rollback() error {
|
||||
// return c.Rollback()
|
||||
//}
|
||||
|
||||
// Commit 提交事务
|
||||
//func (c *XormClientSession) Commit() error {
|
||||
// return c.Commit()
|
||||
//}
|
@ -1,13 +0,0 @@
|
||||
package gfcron
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/v2/os/gcron"
|
||||
"github.com/gogf/gf/v2/os/gctx"
|
||||
)
|
||||
|
||||
// https://goframe.org/pages/viewpage.action?pageId=30736411
|
||||
|
||||
var (
|
||||
Cron *gcron.Cron
|
||||
Ctx = gctx.New()
|
||||
)
|
Loading…
Reference in new issue