Rename domain to model
This commit is contained in:
+5
-5
@@ -7,9 +7,9 @@ import (
|
||||
|
||||
"github.com/cloudsonic/sonic-server/api/responses"
|
||||
"github.com/cloudsonic/sonic-server/conf"
|
||||
"github.com/cloudsonic/sonic-server/domain"
|
||||
"github.com/cloudsonic/sonic-server/engine"
|
||||
"github.com/cloudsonic/sonic-server/log"
|
||||
"github.com/cloudsonic/sonic-server/model"
|
||||
"github.com/cloudsonic/sonic-server/utils"
|
||||
)
|
||||
|
||||
@@ -86,7 +86,7 @@ func (c *BrowsingController) GetMusicDirectory(w http.ResponseWriter, r *http.Re
|
||||
id := ParamString(r, "id")
|
||||
dir, err := c.browser.Directory(r.Context(), id)
|
||||
switch {
|
||||
case err == domain.ErrNotFound:
|
||||
case err == model.ErrNotFound:
|
||||
log.Error(r, "Requested ID not found ", "id", id)
|
||||
return nil, NewError(responses.ErrorDataNotFound, "Directory not found")
|
||||
case err != nil:
|
||||
@@ -103,7 +103,7 @@ func (c *BrowsingController) GetArtist(w http.ResponseWriter, r *http.Request) (
|
||||
id := ParamString(r, "id")
|
||||
dir, err := c.browser.Artist(r.Context(), id)
|
||||
switch {
|
||||
case err == domain.ErrNotFound:
|
||||
case err == model.ErrNotFound:
|
||||
log.Error(r, "Requested ArtistID not found ", "id", id)
|
||||
return nil, NewError(responses.ErrorDataNotFound, "Artist not found")
|
||||
case err != nil:
|
||||
@@ -120,7 +120,7 @@ func (c *BrowsingController) GetAlbum(w http.ResponseWriter, r *http.Request) (*
|
||||
id := ParamString(r, "id")
|
||||
dir, err := c.browser.Album(r.Context(), id)
|
||||
switch {
|
||||
case err == domain.ErrNotFound:
|
||||
case err == model.ErrNotFound:
|
||||
log.Error(r, "Requested ID not found ", "id", id)
|
||||
return nil, NewError(responses.ErrorDataNotFound, "Album not found")
|
||||
case err != nil:
|
||||
@@ -137,7 +137,7 @@ func (c *BrowsingController) GetSong(w http.ResponseWriter, r *http.Request) (*r
|
||||
id := ParamString(r, "id")
|
||||
song, err := c.browser.GetSong(id)
|
||||
switch {
|
||||
case err == domain.ErrNotFound:
|
||||
case err == model.ErrNotFound:
|
||||
log.Error(r, "Requested ID not found ", "id", id)
|
||||
return nil, NewError(responses.ErrorDataNotFound, "Song not found")
|
||||
case err != nil:
|
||||
|
||||
@@ -5,9 +5,9 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/cloudsonic/sonic-server/api/responses"
|
||||
"github.com/cloudsonic/sonic-server/domain"
|
||||
"github.com/cloudsonic/sonic-server/engine"
|
||||
"github.com/cloudsonic/sonic-server/log"
|
||||
"github.com/cloudsonic/sonic-server/model"
|
||||
)
|
||||
|
||||
type MediaAnnotationController struct {
|
||||
@@ -36,7 +36,7 @@ func (c *MediaAnnotationController) SetRating(w http.ResponseWriter, r *http.Req
|
||||
err = c.ratings.SetRating(r.Context(), id, rating)
|
||||
|
||||
switch {
|
||||
case err == domain.ErrNotFound:
|
||||
case err == model.ErrNotFound:
|
||||
log.Error(r, err)
|
||||
return nil, NewError(responses.ErrorDataNotFound, "ID not found")
|
||||
case err != nil:
|
||||
@@ -66,7 +66,7 @@ func (c *MediaAnnotationController) Star(w http.ResponseWriter, r *http.Request)
|
||||
log.Debug(r, "Starring items", "ids", ids)
|
||||
err = c.ratings.SetStar(r.Context(), true, ids...)
|
||||
switch {
|
||||
case err == domain.ErrNotFound:
|
||||
case err == model.ErrNotFound:
|
||||
log.Error(r, err)
|
||||
return nil, NewError(responses.ErrorDataNotFound, "ID not found")
|
||||
case err != nil:
|
||||
@@ -85,7 +85,7 @@ func (c *MediaAnnotationController) Unstar(w http.ResponseWriter, r *http.Reques
|
||||
log.Debug(r, "Unstarring items", "ids", ids)
|
||||
err = c.ratings.SetStar(r.Context(), false, ids...)
|
||||
switch {
|
||||
case err == domain.ErrNotFound:
|
||||
case err == model.ErrNotFound:
|
||||
log.Error(r, err)
|
||||
return nil, NewError(responses.ErrorDataNotFound, "Directory not found")
|
||||
case err != nil:
|
||||
|
||||
@@ -6,9 +6,9 @@ import (
|
||||
"os"
|
||||
|
||||
"github.com/cloudsonic/sonic-server/api/responses"
|
||||
"github.com/cloudsonic/sonic-server/domain"
|
||||
"github.com/cloudsonic/sonic-server/engine"
|
||||
"github.com/cloudsonic/sonic-server/log"
|
||||
"github.com/cloudsonic/sonic-server/model"
|
||||
)
|
||||
|
||||
type MediaRetrievalController struct {
|
||||
@@ -42,7 +42,7 @@ func (c *MediaRetrievalController) GetCoverArt(w http.ResponseWriter, r *http.Re
|
||||
err = c.cover.Get(id, size, w)
|
||||
|
||||
switch {
|
||||
case err == domain.ErrNotFound:
|
||||
case err == model.ErrNotFound:
|
||||
log.Error(r, err.Error(), "id", id)
|
||||
return nil, NewError(responses.ErrorDataNotFound, "Cover not found")
|
||||
case err != nil:
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"io"
|
||||
"net/http/httptest"
|
||||
|
||||
"github.com/cloudsonic/sonic-server/domain"
|
||||
"github.com/cloudsonic/sonic-server/model"
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
@@ -58,7 +58,7 @@ var _ = Describe("MediaRetrievalController", func() {
|
||||
})
|
||||
|
||||
It("should fail when the file is not found", func() {
|
||||
cover.err = domain.ErrNotFound
|
||||
cover.err = model.ErrNotFound
|
||||
r := newTestRequest("id=34", "size=128")
|
||||
_, err := controller.GetCoverArt(w, r)
|
||||
|
||||
|
||||
+2
-2
@@ -5,9 +5,9 @@ import (
|
||||
"net/http"
|
||||
|
||||
"github.com/cloudsonic/sonic-server/api/responses"
|
||||
"github.com/cloudsonic/sonic-server/domain"
|
||||
"github.com/cloudsonic/sonic-server/engine"
|
||||
"github.com/cloudsonic/sonic-server/log"
|
||||
"github.com/cloudsonic/sonic-server/model"
|
||||
)
|
||||
|
||||
type PlaylistsController struct {
|
||||
@@ -46,7 +46,7 @@ func (c *PlaylistsController) GetPlaylist(w http.ResponseWriter, r *http.Request
|
||||
}
|
||||
pinfo, err := c.pls.Get(id)
|
||||
switch {
|
||||
case err == domain.ErrNotFound:
|
||||
case err == model.ErrNotFound:
|
||||
log.Error(r, err.Error(), "id", id)
|
||||
return nil, NewError(responses.ErrorDataNotFound, "Directory not found")
|
||||
case err != nil:
|
||||
|
||||
+2
-2
@@ -4,9 +4,9 @@ import (
|
||||
"net/http"
|
||||
|
||||
"github.com/cloudsonic/sonic-server/api/responses"
|
||||
"github.com/cloudsonic/sonic-server/domain"
|
||||
"github.com/cloudsonic/sonic-server/engine"
|
||||
"github.com/cloudsonic/sonic-server/log"
|
||||
"github.com/cloudsonic/sonic-server/model"
|
||||
"github.com/cloudsonic/sonic-server/utils"
|
||||
)
|
||||
|
||||
@@ -26,7 +26,7 @@ func (c *StreamController) getMediaFile(r *http.Request) (mf *engine.Entry, err
|
||||
|
||||
mf, err = c.browser.GetSong(id)
|
||||
switch {
|
||||
case err == domain.ErrNotFound:
|
||||
case err == model.ErrNotFound:
|
||||
log.Error(r, "Mediafile not found", "id", id)
|
||||
return nil, NewError(responses.ErrorDataNotFound)
|
||||
case err != nil:
|
||||
|
||||
Reference in New Issue
Block a user