qs no gorm

This commit is contained in:
yedf2 2021-07-31 18:16:00 +08:00
parent 052e2ee6fe
commit 8c73a1d9bf
2 changed files with 2 additions and 28 deletions

View File

@ -13,26 +13,6 @@ import (
// XaClient XA client connection // XaClient XA client connection
var XaClient *dtmcli.XaClient = nil var XaClient *dtmcli.XaClient = nil
// UserAccount busi model
type UserAccount struct {
common.ModelBase
UserID int
Balance string
}
// TableName gorm table name
func (u *UserAccount) TableName() string { return "dtm_busi.user_account" }
// UserAccountTrading freeze user account table
type UserAccountTrading struct {
common.ModelBase
UserID int
TradingBalance string
}
// TableName gorm table name
func (u *UserAccountTrading) TableName() string { return "dtm_busi.user_account_trading" }
func dbGet() *common.DB { func dbGet() *common.DB {
return common.DbGet(config.DB) return common.DbGet(config.DB)
} }

View File

@ -8,7 +8,6 @@ import (
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"github.com/yedf/dtm/common" "github.com/yedf/dtm/common"
"github.com/yedf/dtm/dtmcli" "github.com/yedf/dtm/dtmcli"
"gorm.io/gorm"
) )
// 启动命令go run app/main.go qs // 启动命令go run app/main.go qs
@ -44,13 +43,8 @@ func QsFireRequest() string {
} }
func qsAdjustBalance(uid int, amount int) (interface{}, error) { func qsAdjustBalance(uid int, amount int) (interface{}, error) {
err := dbGet().Transaction(func(tx *gorm.DB) error { _, err := common.SdbExec(sdbGet(), "update dtm_busi.user_account set balance = balance + ? where user_id = ?", amount, uid)
return tx.Model(&UserAccount{}).Where("user_id = ?", uid).Update("balance", gorm.Expr("balance + ?", amount)).Error return M{"dtm_result": "SUCCESS"}, err
})
if err != nil {
return nil, err
}
return M{"dtm_result": "SUCCESS"}, nil
} }
func qsAddRoute(app *gin.Engine) { func qsAddRoute(app *gin.Engine) {