支持动态更新管理员密码和下载次数逻辑完善,优化相关错误处理和配置更新流程

This commit is contained in:
2026-01-14 19:49:07 +08:00
parent 903d5b865e
commit e456d3a823
6 changed files with 75 additions and 19 deletions

View File

@@ -85,8 +85,18 @@ func (s *BatchService) DeleteBatch(ctx context.Context, batchID string) error {
}
func (s *BatchService) IncrementDownloadCount(batchID string) error {
return s.db.Model(&model.FileBatch{}).Where("id = ?", batchID).
UpdateColumn("download_count", gorm.Expr("download_count + ?", 1)).Error
if batchID == "" {
return errors.New("batch id is empty")
}
result := s.db.Model(&model.FileBatch{}).Where("id = ?", batchID).
UpdateColumn("download_count", gorm.Expr("download_count + ?", 1))
if result.Error != nil {
return result.Error
}
if result.RowsAffected == 0 {
return errors.New("batch not found or already deleted")
}
return nil
}
func (s *BatchService) GeneratePickupCode(length int) (string, error) {