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) {
|
if this.Score < int64(num) {
|
||||||
return errors.New("")
|
return errors.New("")
|
||||||
}
|
}
|
||||||
oldScore := this.Score
|
oldDice := this.Dice
|
||||||
this.Score -= int64(num)
|
this.Dice -= num
|
||||||
if result := f5.GetApp().GetOrmDb(constant.WHEEL_DB).Model(this).Select(
|
if result := f5.GetApp().GetOrmDb(constant.WHEEL_DB).Model(this).Select(
|
||||||
"dice").Updates(this); result.Error != nil {
|
"dice").Updates(this); result.Error != nil {
|
||||||
this.Score = oldScore
|
this.Dice = oldDice
|
||||||
return result.Error
|
return result.Error
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *User) AddScore(score int32) error {
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user