1
This commit is contained in:
parent
87f923d42f
commit
35b8c1a72d
@ -53,9 +53,8 @@ func (this *User) Find(accountId string, nowTime int64) (error, bool) {
|
||||
if int32(q5.GetDaySeconds(nowTime, 0)) > this.LastPresentDiceTime {
|
||||
this.Dice = mt.Table.Global.GetDailyDiceNum()
|
||||
this.LastPresentDiceTime = q5.ToInt32(nowTime)
|
||||
if result := f5.GetApp().GetOrmDb(constant.WHEEL_DB).Model(this).Select(
|
||||
"dice", "last_present_dice_time").Updates(this); result.Error != nil {
|
||||
return result.Error, false
|
||||
if err := this.UpdateFields([]string{"dice", "last_present_dice_time"}); err != nil {
|
||||
return err, false
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -76,19 +75,17 @@ func (this *User) DecDice(num int32) error {
|
||||
}
|
||||
oldDice := this.Dice
|
||||
this.Dice -= num
|
||||
if result := f5.GetApp().GetOrmDb(constant.WHEEL_DB).Model(this).Select(
|
||||
"dice").Updates(this); result.Error != nil {
|
||||
if err := this.UpdateFields([]string{"dice"}); err != nil {
|
||||
this.Dice = oldDice
|
||||
return result.Error
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (this *User) AddSpecDice(num int32) error {
|
||||
this.SpecDice += num
|
||||
if result := f5.GetApp().GetOrmDb(constant.WHEEL_DB).Model(this).Select(
|
||||
"spec_dice").Updates(this); result.Error != nil {
|
||||
return result.Error
|
||||
if err := this.UpdateFields([]string{"spec_dice"}); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@ -99,10 +96,9 @@ func (this *User) DecScore(num int32) error {
|
||||
}
|
||||
oldScore := this.Score
|
||||
this.Score -= int64(num)
|
||||
if result := f5.GetApp().GetOrmDb(constant.WHEEL_DB).Model(this).Select(
|
||||
"score").Updates(this); result.Error != nil {
|
||||
if err := this.UpdateFields([]string{"score"}); err != nil {
|
||||
this.Score = oldScore
|
||||
return result.Error
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@ -113,18 +109,13 @@ func (this *User) AddScore(score int32) error {
|
||||
}
|
||||
oldScore := this.Score
|
||||
this.Score += int64(score)
|
||||
if result := f5.GetApp().GetOrmDb(constant.WHEEL_DB).Model(this).Select(
|
||||
"score").Updates(this); result.Error != nil {
|
||||
if err := this.UpdateFields([]string{"score"}); err != nil {
|
||||
this.Score = oldScore
|
||||
return result.Error
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (this *User) UpdateName() error {
|
||||
if result := f5.GetApp().GetOrmDb(constant.WHEEL_DB).Model(this).Select(
|
||||
"nickname").Updates(this); result.Error != nil {
|
||||
return result.Error
|
||||
}
|
||||
return nil
|
||||
return this.UpdateFields([]string{"nickname"});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user