#### 我的业务代码如何
```
var sql string
if req.UpgradeType == UPGRADE_EQUIP {
sql = "update user_info set equip_id=equip_id+1,coin=coin-? where coin>=? and open_id=?"
} else if req.UpgradeType == UPGRADE_HELPER {
sql = "update user_info set helper_id=helper_id+1,coin=coin-? where coin>=? and open_id=?"
}
res, err := trans.Exec(sql, models.COIN_WASTE, models.COIN_WASTE, userInfo.OpenId)
...中间没有任何sql执行,代码量很少,几乎可以忽略执行时间...
m := new(models.CoinLog)
m.Type = Type
m.Nums = coinNums
m.Uid = uid
_, err := trans.InsertOne(m)
if err != nil {
return logs.SysErr(err)
}
return nil
```
#### postman平均执行时间**370ms**,开启事物了的,但也不至于这么长时间吧,我初步推断是**xorm**导致的时间消耗
有疑问加站长微信联系(非本文作者)