1
This commit is contained in:
parent
58720a2435
commit
133548133d
@ -56,16 +56,26 @@ func (this *User) DecDice(num int32) error {
|
||||
if this.Score < int64(num) {
|
||||
return errors.New("")
|
||||
}
|
||||
oldScore := this.Score
|
||||
this.Score -= int64(num)
|
||||
oldDice := this.Dice
|
||||
this.Dice -= num
|
||||
if result := f5.GetApp().GetOrmDb(constant.WHEEL_DB).Model(this).Select(
|
||||
"dice").Updates(this); result.Error != nil {
|
||||
this.Score = oldScore
|
||||
this.Dice = oldDice
|
||||
return result.Error
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (this *User) AddScore(score int32) error {
|
||||
if score <= 0 {
|
||||
return nil
|
||||
}
|
||||
oldScore := this.Score
|
||||
this.Score += int64(score)
|
||||
if result := f5.GetApp().GetOrmDb(constant.WHEEL_DB).Model(this).Select(
|
||||
"score").Updates(this); result.Error != nil {
|
||||
this.Score = oldScore
|
||||
return result.Error
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user