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