From c540da69d8b6fad8b429fe279545416ef5c7107d Mon Sep 17 00:00:00 2001 From: Hjj <582604932@qq.com> Date: Tue, 10 May 2022 14:50:34 +0800 Subject: [PATCH] add Reverse: for v1.0.7 --- coupon_test.go | 5 +---- db/db.go | 36 +++++++++++++++++------------------- 2 files changed, 18 insertions(+), 23 deletions(-) diff --git a/coupon_test.go b/coupon_test.go index 025c07c..ab365c9 100644 --- a/coupon_test.go +++ b/coupon_test.go @@ -7,10 +7,7 @@ import ( ) func TestCouponCommCheck(t *testing.T) { - err := Init("119.23.182.117:3306", "fnuoos_test1", "root", "Fnuo123com@") - if err != nil { - t.Errorf("Reverse == %s", err) - } + req := md.CouponCheckRequest{ CouponAmount: "", Uid: "21702", diff --git a/db/db.go b/db/db.go index a3266e0..cf5ded2 100644 --- a/db/db.go +++ b/db/db.go @@ -5,10 +5,8 @@ import ( "database/sql" "fmt" _ "github.com/go-sql-driver/mysql" //必须导入mysql驱动,否则会panic - "os" "time" "xorm.io/xorm" - "xorm.io/xorm/log" ) var Db *xorm.Engine @@ -17,7 +15,7 @@ var Db *xorm.Engine func InitDB(c *md.DBCfg) error { var ( err error - f *os.File + //f *os.File ) //创建Orm引擎 if Db, err = xorm.NewEngine("mysql", fmt.Sprintf("%s:%s@tcp(%s)/%s?charset=utf8mb4", c.User, c.Psw, c.Host, c.Name)); err != nil { @@ -29,22 +27,22 @@ func InitDB(c *md.DBCfg) error { if err = Db.Ping(); err != nil { //尝试ping数据库 return err } - if c.ShowLog { //根据配置文件设置日志 - Db.ShowSQL(true) //设置是否打印sql - Db.Logger().SetLevel(0) //设置日志等级 - //修改日志文件存放路径文件名是%s.log - path := fmt.Sprintf(c.Path, c.Name) - f, err = os.OpenFile(path, os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0777) - if err != nil { - os.RemoveAll(c.Path) - if f, err = os.OpenFile(c.Path, os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0777); err != nil { - return err - } - } - logger := log.NewSimpleLogger(f) - logger.ShowSQL(true) - Db.SetLogger(logger) - } + //if c.ShowLog { //根据配置文件设置日志 + // Db.ShowSQL(true) //设置是否打印sql + // Db.Logger().SetLevel(0) //设置日志等级 + // //修改日志文件存放路径文件名是%s.log + // path := fmt.Sprintf(c.Path, c.Name) + // f, err = os.OpenFile(path, os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0777) + // if err != nil { + // os.RemoveAll(c.Path) + // if f, err = os.OpenFile(c.Path, os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0777); err != nil { + // return err + // } + // } + // logger := log.NewSimpleLogger(f) + // logger.ShowSQL(true) + // Db.SetLogger(logger) + //} return nil }