支持动态更新管理员密码和下载次数逻辑完善,优化相关错误处理和配置更新流程
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user