dont insert if no need
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"github.com/sentriz/gonic/db"
|
||||
@@ -12,6 +13,7 @@ func (c *Controller) GetIndexes(w http.ResponseWriter, r *http.Request) {
|
||||
// for this, so we're going to return root directories as "artists"
|
||||
var folders []*db.Folder
|
||||
c.DB.Where("parent_id = ?", 1).Find(&folders)
|
||||
fmt.Println(folders, "++++++++")
|
||||
var indexMap = make(map[rune]*subsonic.Index)
|
||||
var indexes []*subsonic.Index
|
||||
for _, folder := range folders {
|
||||
@@ -60,10 +62,11 @@ func (c *Controller) GetMusicDirectory(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
for _, folder := range folders {
|
||||
sub.Directory.Children = append(sub.Directory.Children, &subsonic.Child{
|
||||
Parent: cFolder.ID,
|
||||
ID: folder.ID,
|
||||
Title: folder.Name,
|
||||
IsDir: true,
|
||||
Parent: cFolder.ID,
|
||||
ID: folder.ID,
|
||||
Title: folder.Name,
|
||||
IsDir: true,
|
||||
CoverID: folder.CoverID,
|
||||
})
|
||||
}
|
||||
respond(w, r, sub)
|
||||
|
||||
@@ -64,7 +64,7 @@ func (c *Controller) GetArtist(w http.ResponseWriter, r *http.Request) {
|
||||
Created: album.CreatedAt,
|
||||
Artist: artist.Name,
|
||||
ArtistID: artist.ID,
|
||||
CoverID: album.ID,
|
||||
CoverID: album.CoverID,
|
||||
})
|
||||
}
|
||||
respond(w, r, sub)
|
||||
@@ -85,7 +85,7 @@ func (c *Controller) GetAlbum(w http.ResponseWriter, r *http.Request) {
|
||||
sub.Album = &subsonic.Album{
|
||||
ID: album.ID,
|
||||
Name: album.Title,
|
||||
CoverID: album.ID,
|
||||
CoverID: album.CoverID,
|
||||
Created: album.CreatedAt,
|
||||
Artist: album.AlbumArtist.Name,
|
||||
}
|
||||
@@ -103,7 +103,7 @@ func (c *Controller) GetAlbum(w http.ResponseWriter, r *http.Request) {
|
||||
Album: album.Title,
|
||||
AlbumID: album.ID,
|
||||
ArtistID: album.AlbumArtist.ID, // album artist
|
||||
CoverID: album.ID,
|
||||
CoverID: album.CoverID,
|
||||
Type: "music",
|
||||
})
|
||||
}
|
||||
@@ -136,7 +136,7 @@ func (c *Controller) GetAlbumList(w http.ResponseWriter, r *http.Request) {
|
||||
ID: album.ID,
|
||||
Name: album.Title,
|
||||
Created: album.CreatedAt,
|
||||
CoverID: album.ID,
|
||||
CoverID: album.CoverID,
|
||||
Artist: album.AlbumArtist.Name,
|
||||
ArtistID: album.AlbumArtist.ID,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user