Make sheet not include composer
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -3,3 +3,4 @@ sheetless-server
|
|||||||
sheetless.db
|
sheetless.db
|
||||||
/result
|
/result
|
||||||
/.env
|
/.env
|
||||||
|
/src/vendor/
|
||||||
|
|||||||
@@ -25,24 +25,8 @@ func UploadSheet(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
composerUUIDStr := c.PostForm("composer_uuid")
|
// TODO: create new composer with this name if it does not exist here
|
||||||
if composerUUIDStr == "" {
|
composer := c.PostForm("composer")
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"error": "Composer UUID is required"})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
composerUUID, err := uuid.Parse(composerUUIDStr)
|
|
||||||
if err != nil {
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"error": "Invalid composer UUID"})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
var composer models.Composer
|
|
||||||
if err := database.DB.First(&composer, composerUUID).Error; err != nil {
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"error": "Composer not found"})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
description := c.PostForm("description")
|
description := c.PostForm("description")
|
||||||
|
|
||||||
// Get uploaded file
|
// Get uploaded file
|
||||||
@@ -104,7 +88,7 @@ func UploadSheet(c *gin.Context) {
|
|||||||
FilePath: filePath,
|
FilePath: filePath,
|
||||||
FileSize: fileInfo.Size(),
|
FileSize: fileInfo.Size(),
|
||||||
FileHash: fileHash,
|
FileHash: fileHash,
|
||||||
ComposerUuid: composer.Uuid,
|
Composer: composer,
|
||||||
CreatedAt: time.Now(),
|
CreatedAt: time.Now(),
|
||||||
UpdatedAt: time.Now(),
|
UpdatedAt: time.Now(),
|
||||||
}
|
}
|
||||||
@@ -125,7 +109,7 @@ func UploadSheet(c *gin.Context) {
|
|||||||
func ListSheets(c *gin.Context) {
|
func ListSheets(c *gin.Context) {
|
||||||
var sheets []models.Sheet
|
var sheets []models.Sheet
|
||||||
|
|
||||||
if err := database.DB.Preload("Composer").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"})
|
c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to fetch sheets"})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,9 +14,9 @@ type Sheet struct {
|
|||||||
FilePath string `json:"file_path" gorm:"not null"`
|
FilePath string `json:"file_path" gorm:"not null"`
|
||||||
FileSize int64 `json:"file_size"`
|
FileSize int64 `json:"file_size"`
|
||||||
FileHash string `json:"file_hash"`
|
FileHash string `json:"file_hash"`
|
||||||
ComposerUuid uuid.UUID `json:"composer_uuid"`
|
Composer string `json:"composer"`
|
||||||
Composer Composer `json:"composer" gorm:"foreignKey:ComposerUuid"`
|
|
||||||
CreatedAt time.Time `json:"created_at"`
|
CreatedAt time.Time `json:"created_at"`
|
||||||
UpdatedAt time.Time `json:"updated_at"`
|
UpdatedAt time.Time `json:"updated_at"`
|
||||||
DeletedAt gorm.DeletedAt `json:"-" gorm:"index"`
|
DeletedAt gorm.DeletedAt `json:"-" gorm:"index"`
|
||||||
|
Annotations string `json:"annotations"`
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user