From 99d48e18167b7b3320ca0c11f61246f35b0dd04b Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Sat, 14 Dec 2024 11:20:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=87=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rule/user_upgrade.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/rule/user_upgrade.go b/rule/user_upgrade.go index 690cf08..6a7d161 100644 --- a/rule/user_upgrade.go +++ b/rule/user_upgrade.go @@ -11,20 +11,20 @@ import ( "xorm.io/xorm" ) -func UserUpgradeInsert(uid, level int) error { - userDb := implement.NewUserDb(db.Db) +func UserUpgradeInsert(eg *xorm.Engine, uid, level int) error { + userDb := implement.NewUserDb(eg) user, _ := userDb.GetUser(int64(uid)) if level == user.Level { return errors.New("等级相同") } - task, err := UserUpgradeTask(db.Db, int(user.Id), level) + task, err := UserUpgradeTask(eg, int(user.Id), level) if err != nil { return err } //升级 oldLevel := user.Level user.Level = level - _, err = db.Db.Where("id=?", user.Id).Cols("level").Update(user) + _, err = eg.Where("id=?", user.Id).Cols("level").Update(user) if err != nil { return err } @@ -35,7 +35,7 @@ func UserUpgradeInsert(uid, level int) error { CreateTime: time.Now(), Task: utils.SerializeStr(task), } - db.Db.Insert(&tmp) + eg.Insert(&tmp) return nil }