diff --git a/api/get_indexes.go b/api/get_indexes.go index ac3c95a09..11aa00e7a 100644 --- a/api/get_indexes.go +++ b/api/get_indexes.go @@ -2,9 +2,9 @@ package api import ( "fmt" + "github.com/astaxie/beego" "github.com/deluan/gosonic/api/responses" - "github.com/deluan/gosonic/domain" "github.com/deluan/gosonic/engine" "github.com/deluan/gosonic/utils" "github.com/karlkfi/inject" @@ -12,13 +12,11 @@ import ( type GetIndexesController struct { BaseAPIController - properties domain.PropertyRepository - browser engine.Browser + browser engine.Browser } func (c *GetIndexesController) Prepare() { inject.ExtractAssignable(utils.Graph, &c.browser) - inject.ExtractAssignable(utils.Graph, &c.properties) } // TODO: Shortcuts amd validate musicFolder parameter diff --git a/api/get_indexes_test.go b/api/get_indexes_test.go index 7df7790e5..56aab2d87 100644 --- a/api/get_indexes_test.go +++ b/api/get_indexes_test.go @@ -6,6 +6,7 @@ import ( "github.com/deluan/gosonic/api/responses" "github.com/deluan/gosonic/consts" "github.com/deluan/gosonic/domain" + "github.com/deluan/gosonic/engine" . "github.com/deluan/gosonic/tests" "github.com/deluan/gosonic/tests/mocks" "github.com/deluan/gosonic/utils" @@ -24,7 +25,7 @@ func TestGetIndexes(t *testing.T) { return mockRepo }) propRepo := mocks.CreateMockPropertyRepo() - utils.DefineSingleton(new(domain.PropertyRepository), func() domain.PropertyRepository { + utils.DefineSingleton(new(engine.PropertyRepository), func() engine.PropertyRepository { return propRepo }) diff --git a/conf/inject_definitions.go b/conf/inject_definitions.go index eea0accd8..2ffc7f3b3 100644 --- a/conf/inject_definitions.go +++ b/conf/inject_definitions.go @@ -10,12 +10,12 @@ import ( func init() { // Persistence utils.DefineSingleton(new(domain.ArtistIndexRepository), persistence.NewArtistIndexRepository) - utils.DefineSingleton(new(domain.PropertyRepository), persistence.NewPropertyRepository) utils.DefineSingleton(new(domain.MediaFolderRepository), persistence.NewMediaFolderRepository) utils.DefineSingleton(new(domain.ArtistRepository), persistence.NewArtistRepository) utils.DefineSingleton(new(domain.AlbumRepository), persistence.NewAlbumRepository) utils.DefineSingleton(new(domain.MediaFileRepository), persistence.NewMediaFileRepository) // Engine (Use cases) + utils.DefineSingleton(new(engine.PropertyRepository), persistence.NewPropertyRepository) utils.DefineSingleton(new(engine.Browser), engine.NewBrowser) } diff --git a/engine/browser.go b/engine/browser.go index 1ed9d5b09..725035b76 100644 --- a/engine/browser.go +++ b/engine/browser.go @@ -22,13 +22,13 @@ type Browser interface { Directory(id string) (*DirectoryInfo, error) } -func NewBrowser(pr domain.PropertyRepository, fr domain.MediaFolderRepository, ir domain.ArtistIndexRepository, +func NewBrowser(pr PropertyRepository, fr domain.MediaFolderRepository, ir domain.ArtistIndexRepository, ar domain.ArtistRepository, alr domain.AlbumRepository, mr domain.MediaFileRepository) Browser { return browser{pr, fr, ir, ar, alr, mr} } type browser struct { - propRepo domain.PropertyRepository + propRepo PropertyRepository folderRepo domain.MediaFolderRepository indexRepo domain.ArtistIndexRepository artistRepo domain.ArtistRepository diff --git a/domain/property.go b/engine/properties.go similarity index 93% rename from domain/property.go rename to engine/properties.go index d5e75eb7f..5a7702e3c 100644 --- a/domain/property.go +++ b/engine/properties.go @@ -1,4 +1,4 @@ -package domain +package engine type Property struct { Id string diff --git a/persistence/property_repository.go b/persistence/property_repository.go index 6667b2c4f..f1cc5433f 100644 --- a/persistence/property_repository.go +++ b/persistence/property_repository.go @@ -2,21 +2,22 @@ package persistence import ( "errors" - "github.com/deluan/gosonic/domain" + + "github.com/deluan/gosonic/engine" ) type propertyRepository struct { ledisRepository } -func NewPropertyRepository() domain.PropertyRepository { +func NewPropertyRepository() engine.PropertyRepository { r := &propertyRepository{} - r.init("property", &domain.Property{}) + r.init("property", &engine.Property{}) return r } func (r *propertyRepository) Put(id string, value string) error { - m := &domain.Property{Id: id, Value: value} + m := &engine.Property{Id: id, Value: value} if m.Id == "" { return errors.New("Id is required") } @@ -26,7 +27,7 @@ func (r *propertyRepository) Put(id string, value string) error { func (r *propertyRepository) Get(id string) (string, error) { var rec interface{} rec, err := r.readEntity(id) - return rec.(*domain.Property).Value, err + return rec.(*engine.Property).Value, err } func (r *propertyRepository) DefaultGet(id string, defaultValue string) (string, error) { @@ -39,4 +40,4 @@ func (r *propertyRepository) DefaultGet(id string, defaultValue string) (string, return v, err } -var _ domain.PropertyRepository = (*propertyRepository)(nil) \ No newline at end of file +var _ engine.PropertyRepository = (*propertyRepository)(nil) diff --git a/scanner/importer.go b/scanner/importer.go index edd8f2b01..5645cce9e 100644 --- a/scanner/importer.go +++ b/scanner/importer.go @@ -9,6 +9,7 @@ import ( "github.com/astaxie/beego" "github.com/deluan/gosonic/consts" "github.com/deluan/gosonic/domain" + "github.com/deluan/gosonic/engine" "github.com/deluan/gosonic/persistence" "github.com/deluan/gosonic/utils" ) @@ -45,7 +46,7 @@ type Importer struct { albumRepo domain.AlbumRepository artistRepo domain.ArtistRepository idxRepo domain.ArtistIndexRepository - propertyRepo domain.PropertyRepository + propertyRepo engine.PropertyRepository lastScan time.Time } diff --git a/tests/mocks/mock_property_repo.go b/tests/mocks/mock_property_repo.go index 9736fa241..92862968f 100644 --- a/tests/mocks/mock_property_repo.go +++ b/tests/mocks/mock_property_repo.go @@ -2,7 +2,8 @@ package mocks import ( "errors" - "github.com/deluan/gosonic/domain" + + "github.com/deluan/gosonic/engine" ) func CreateMockPropertyRepo() *MockProperty { @@ -10,7 +11,7 @@ func CreateMockPropertyRepo() *MockProperty { } type MockProperty struct { - domain.PropertyRepository + engine.PropertyRepository data map[string]string err bool }