getRandomSongs.view (partially) implemented

This commit is contained in:
Deluan
2016-03-29 00:01:27 -04:00
parent 880521360f
commit 768764bea7
7 changed files with 70 additions and 5 deletions
+20 -2
View File
@@ -40,7 +40,7 @@ func (c *AlbumListController) GetAlbumList() {
}
offset := c.ParamInt("offset", 0)
size := utils.MinInt(c.ParamInt("size", 0), 500)
size := utils.MinInt(c.ParamInt("size", 10), 500)
albums, err := method(offset, size)
if err != nil {
@@ -63,7 +63,7 @@ func (c *AlbumListController) GetAlbumList2() {
}
offset := c.ParamInt("offset", 0)
size := utils.MinInt(c.ParamInt("size", 0), 500)
size := utils.MinInt(c.ParamInt("size", 10), 500)
albums, err := method(offset, size)
if err != nil {
@@ -125,3 +125,21 @@ func (c *AlbumListController) GetNowPlaying() {
}
c.SendResponse(response)
}
func (c *AlbumListController) GetRandomSongs() {
size := utils.MinInt(c.ParamInt("size", 10), 500)
songs, err := c.listGen.GetRandomSongs(size)
if err != nil {
beego.Error("Error retrieving random songs:", err)
c.SendError(responses.ErrorGeneric, "Internal Error")
}
response := c.NewEmpty()
response.RandomSongs = &responses.Songs{}
response.RandomSongs.Songs = make([]responses.Child, len(songs))
for i, entry := range songs {
response.RandomSongs.Songs[i] = c.ToChild(entry)
}
c.SendResponse(response)
}