Update usage grpc call

This commit is contained in:
2025-03-10 22:15:59 +08:00
parent 69be460e13
commit e3ca50c4ae
6 changed files with 248 additions and 60 deletions

View File

@ -238,3 +238,13 @@ func DeleteAttachment(item models.Attachment, txs ...*gorm.DB) error {
return nil
}
func CountAttachmentUsage(id []uint, delta int) (int64, error) {
if tx := database.C.Model(&models.Attachment{}).
Where("id IN ?", id).
Update("used_count", gorm.Expr("used_count + ?", delta)); tx.Error != nil {
return tx.RowsAffected, tx.Error
} else {
return tx.RowsAffected, nil
}
}