(id int, quota int, db bool)
| 663 | } |
| 664 | |
| 665 | func IncreaseUserQuota(id int, quota int, db bool) (err error) { |
| 666 | if quota < 0 { |
| 667 | return errors.New("quota 不能为负数!") |
| 668 | } |
| 669 | gopool.Go(func() { |
| 670 | err := cacheIncrUserQuota(id, int64(quota)) |
| 671 | if err != nil { |
| 672 | common.SysError("failed to increase user quota: " + err.Error()) |
| 673 | } |
| 674 | }) |
| 675 | if !db && common.BatchUpdateEnabled { |
| 676 | addNewRecord(BatchUpdateTypeUserQuota, id, quota) |
| 677 | return nil |
| 678 | } |
| 679 | return increaseUserQuota(id, quota) |
| 680 | } |
| 681 | |
| 682 | func increaseUserQuota(id int, quota int) (err error) { |
| 683 | err = DB.Model(&User{}).Where("id = ?", id).Update("quota", gorm.Expr("quota + ?", quota)).Error |
no test coverage detected