qs no gorm
This commit is contained in:
parent
052e2ee6fe
commit
8c73a1d9bf
@ -13,26 +13,6 @@ import (
|
||||
// XaClient XA client connection
|
||||
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 {
|
||||
return common.DbGet(config.DB)
|
||||
}
|
||||
|
||||
@ -8,7 +8,6 @@ import (
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/yedf/dtm/common"
|
||||
"github.com/yedf/dtm/dtmcli"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// 启动命令:go run app/main.go qs
|
||||
@ -44,13 +43,8 @@ func QsFireRequest() string {
|
||||
}
|
||||
|
||||
func qsAdjustBalance(uid int, amount int) (interface{}, error) {
|
||||
err := dbGet().Transaction(func(tx *gorm.DB) error {
|
||||
return tx.Model(&UserAccount{}).Where("user_id = ?", uid).Update("balance", gorm.Expr("balance + ?", amount)).Error
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return M{"dtm_result": "SUCCESS"}, nil
|
||||
_, err := common.SdbExec(sdbGet(), "update dtm_busi.user_account set balance = balance + ? where user_id = ?", amount, uid)
|
||||
return M{"dtm_result": "SUCCESS"}, err
|
||||
}
|
||||
|
||||
func qsAddRoute(app *gin.Engine) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user