Add composers

This commit is contained in:
2026-01-23 21:55:21 +01:00
parent 4540c0d880
commit 5141bfe673
7 changed files with 127 additions and 10 deletions

View File

@@ -142,26 +142,23 @@ func ListSheets(c *gin.Context) {
}
func DownloadSheet(c *gin.Context) {
idStr := c.Param("id")
id, err := strconv.ParseUint(idStr, 10, 32)
uuid, err := uuid.Parse(c.Param("uuid"))
if err != nil {
c.JSON(http.StatusBadRequest, gin.H{"error": "Invalid sheet ID"})
c.JSON(http.StatusBadRequest, gin.H{"error": "Invalid sheet uuid"})
return
}
var sheet models.Sheet
if err := database.DB.First(&sheet, uint(id)).Error; err != nil {
if err := database.DB.First(&sheet, uuid).Error; err != nil {
c.JSON(http.StatusNotFound, gin.H{"error": "Sheet not found"})
return
}
// Check if file exists
if _, err := os.Stat(sheet.FilePath); os.IsNotExist(err) {
c.JSON(http.StatusNotFound, gin.H{"error": "File not found"})
return
}
// Set headers for file download
c.Header("Content-Disposition", fmt.Sprintf("attachment; filename=\"%s\"", filepath.Base(sheet.FilePath)))
c.Header("Content-Type", "application/pdf")
c.File(sheet.FilePath)