(id int, quota int)
| 688 | } |
| 689 | |
| 690 | func DecreaseUserQuota(id int, quota int) (err error) { |
| 691 | if quota < 0 { |
| 692 | return errors.New("quota 不能为负数!") |
| 693 | } |
| 694 | gopool.Go(func() { |
| 695 | err := cacheDecrUserQuota(id, int64(quota)) |
| 696 | if err != nil { |
| 697 | common.SysError("failed to decrease user quota: " + err.Error()) |
| 698 | } |
| 699 | }) |
| 700 | if common.BatchUpdateEnabled { |
| 701 | addNewRecord(BatchUpdateTypeUserQuota, id, -quota) |
| 702 | return nil |
| 703 | } |
| 704 | return decreaseUserQuota(id, quota) |
| 705 | } |
| 706 | |
| 707 | func decreaseUserQuota(id int, quota int) (err error) { |
| 708 | err = DB.Model(&User{}).Where("id = ?", id).Update("quota", gorm.Expr("quota - ?", quota)).Error |
no test coverage detected