fix file upload

This commit is contained in:
2025-05-15 12:40:27 +02:00
parent 16d25f034e
commit 79df1243e6
3 changed files with 8 additions and 4 deletions

View File

@@ -74,7 +74,7 @@ func GetUploadingFilesOlderThan(time time.Time) ([]model.UploadingFile, error) {
return files, nil
}
func CreateFile(filename string, description string, resourceID uint, storageID *uint, storageKey string, redirectUrl string, size int64) (*model.File, error) {
func CreateFile(filename string, description string, resourceID uint, storageID *uint, storageKey string, redirectUrl string, size int64, userID uint) (*model.File, error) {
if storageID == nil && redirectUrl == "" {
return nil, errors.New("storageID and redirectUrl cannot be both empty")
}
@@ -87,6 +87,7 @@ func CreateFile(filename string, description string, resourceID uint, storageID
RedirectUrl: redirectUrl,
StorageKey: storageKey,
Size: size,
UserID: userID,
}
if err := db.Create(f).Error; err != nil {
return nil, err

View File

@@ -15,7 +15,9 @@ func SetStatistic(key string, value int64) error {
func GetStatistic(key string) int64 {
statistic := &model.Statistic{}
if err := db.Where("key = ?", key).First(statistic).Error; err != nil {
if err := db.Where(&model.Statistic{
Key: key,
}).First(statistic).Error; err != nil {
return 0
}
return statistic.Value