diff --git a/src/handlers/sheets.go b/src/handlers/sheets.go index 943cd5b..4dc9d1c 100644 --- a/src/handlers/sheets.go +++ b/src/handlers/sheets.go @@ -10,7 +10,6 @@ import ( "sheetless-server/database" "sheetless-server/models" "sheetless-server/utils" - "strconv" "time" "github.com/gin-gonic/gin" @@ -27,12 +26,6 @@ func init() { } func UploadSheet(c *gin.Context) { - userID, exists := c.Get("user_id") - if !exists { - c.JSON(http.StatusUnauthorized, gin.H{"error": "User not authenticated"}) - return - } - // Get form data title := c.PostForm("title") if title == "" { @@ -58,7 +51,7 @@ func UploadSheet(c *gin.Context) { } // Generate unique filename - filename := fmt.Sprintf("%d_%d%s", userID.(uint), time.Now().Unix(), filepath.Ext(header.Filename)) + filename := fmt.Sprintf("%d%s", time.Now().Unix(), filepath.Ext(header.Filename)) filePath := filepath.Join(uploadDir, filename) // Save file @@ -123,17 +116,7 @@ func UploadSheet(c *gin.Context) { func ListSheets(c *gin.Context) { var sheets []models.Sheet - query := database.DB.Preload("User") - - // Filter by user if specified - if userIDStr := c.Query("user_id"); userIDStr != "" { - userID, err := strconv.ParseUint(userIDStr, 10, 32) - if err == nil { - query = query.Where("user_id = ?", uint(userID)) - } - } - - if err := query.Find(&sheets).Error; err != nil { + if err := database.DB.Find(&sheets).Error; err != nil { c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to fetch sheets"}) return } diff --git a/src/models/sheet.go b/src/models/sheet.go index 55d907f..080db2d 100644 --- a/src/models/sheet.go +++ b/src/models/sheet.go @@ -15,7 +15,6 @@ type Sheet struct { FilePath string `json:"file_path" gorm:"not null"` FileSize int64 `json:"file_size"` FileHash uint64 `json:"file_hash"` - User User `json:"user" gorm:"foreignKey:UserID"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` DeletedAt gorm.DeletedAt `json:"-" gorm:"index"`