feat: add batch update support (close #414)

This commit is contained in:
JustSong
2023-09-03 14:58:20 +08:00
parent 8e0a744da3
commit cf0ae05d50
7 changed files with 136 additions and 1 deletions
+8
View File
@@ -141,6 +141,14 @@ func UpdateChannelStatusById(id int, status int) {
}
func UpdateChannelUsedQuota(id int, quota int) {
if common.BatchUpdateEnabled {
addNewRecord(BatchUpdateTypeChannelUsedQuota, id, quota)
return
}
updateChannelUsedQuota(id, quota)
}
func updateChannelUsedQuota(id int, quota int) {
err := DB.Model(&Channel{}).Where("id = ?", id).Update("used_quota", gorm.Expr("used_quota + ?", quota)).Error
if err != nil {
common.SysError("failed to update channel used quota: " + err.Error())