More slices instead of pointers of slice
This commit is contained in:
@@ -29,10 +29,10 @@ func (r *albumRepository) Get(id string) (*domain.Album, error) {
|
||||
return rec.(*domain.Album), err
|
||||
}
|
||||
|
||||
func (r *albumRepository) FindByArtist(artistId string) (*domain.Albums, error) {
|
||||
func (r *albumRepository) FindByArtist(artistId string) (domain.Albums, error) {
|
||||
var as = make(domain.Albums, 0)
|
||||
err := r.loadChildren("artist", artistId, &as, domain.QueryOptions{SortBy: "Year"})
|
||||
return &as, err
|
||||
return as, err
|
||||
}
|
||||
|
||||
func (r *albumRepository) GetAll(options domain.QueryOptions) (domain.Albums, error) {
|
||||
@@ -63,10 +63,10 @@ func (r *albumRepository) PurgeInactive(active domain.Albums) ([]string, error)
|
||||
})
|
||||
}
|
||||
|
||||
func (r *albumRepository) GetStarred(options domain.QueryOptions) (*domain.Albums, error) {
|
||||
func (r *albumRepository) GetStarred(options domain.QueryOptions) (domain.Albums, error) {
|
||||
var as = make(domain.Albums, 0)
|
||||
err := r.loadRange("Starred", true, true, &as, options)
|
||||
return &as, err
|
||||
return as, err
|
||||
}
|
||||
|
||||
var _ domain.AlbumRepository = (*albumRepository)(nil)
|
||||
|
||||
@@ -36,11 +36,11 @@ func (r *mediaFileRepository) Get(id string) (*domain.MediaFile, error) {
|
||||
return mf, nil
|
||||
}
|
||||
|
||||
func (r *mediaFileRepository) FindByAlbum(albumId string) (*domain.MediaFiles, error) {
|
||||
func (r *mediaFileRepository) FindByAlbum(albumId string) (domain.MediaFiles, error) {
|
||||
var mfs = make(domain.MediaFiles, 0)
|
||||
err := r.loadChildren("album", albumId, &mfs)
|
||||
sort.Sort(mfs)
|
||||
return &mfs, err
|
||||
return mfs, err
|
||||
}
|
||||
|
||||
func (r *mediaFileRepository) PurgeInactive(active domain.MediaFiles) ([]string, error) {
|
||||
|
||||
@@ -13,11 +13,11 @@ func NewMediaFolderRepository() domain.MediaFolderRepository {
|
||||
return &mediaFolderRepository{}
|
||||
}
|
||||
|
||||
func (*mediaFolderRepository) GetAll() (*domain.MediaFolders, error) {
|
||||
func (*mediaFolderRepository) GetAll() (domain.MediaFolders, error) {
|
||||
mediaFolder := domain.MediaFolder{Id: "0", Name: "iTunes Library", Path: beego.AppConfig.String("musicFolder")}
|
||||
result := make(domain.MediaFolders, 1)
|
||||
result[0] = mediaFolder
|
||||
return &result, nil
|
||||
return result, nil
|
||||
}
|
||||
|
||||
var _ domain.MediaFolderRepository = (*mediaFolderRepository)(nil)
|
||||
|
||||
@@ -59,7 +59,7 @@ func (m *MockAlbum) GetAll(qo domain.QueryOptions) (domain.Albums, error) {
|
||||
return m.all, nil
|
||||
}
|
||||
|
||||
func (m *MockAlbum) FindByArtist(artistId string) (*domain.Albums, error) {
|
||||
func (m *MockAlbum) FindByArtist(artistId string) (domain.Albums, error) {
|
||||
if m.err {
|
||||
return nil, errors.New("Error!")
|
||||
}
|
||||
@@ -72,5 +72,5 @@ func (m *MockAlbum) FindByArtist(artistId string) (*domain.Albums, error) {
|
||||
}
|
||||
}
|
||||
|
||||
return &res, nil
|
||||
return res, nil
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ func (m *MockMediaFile) Get(id string) (*domain.MediaFile, error) {
|
||||
return nil, domain.ErrNotFound
|
||||
}
|
||||
|
||||
func (m *MockMediaFile) FindByAlbum(artistId string) (*domain.MediaFiles, error) {
|
||||
func (m *MockMediaFile) FindByAlbum(artistId string) (domain.MediaFiles, error) {
|
||||
if m.err {
|
||||
return nil, errors.New("Error!")
|
||||
}
|
||||
@@ -65,5 +65,5 @@ func (m *MockMediaFile) FindByAlbum(artistId string) (*domain.MediaFiles, error)
|
||||
}
|
||||
}
|
||||
|
||||
return &res, nil
|
||||
return res, nil
|
||||
}
|
||||
|
||||
@@ -29,10 +29,10 @@ func (r *playlistRepository) Get(id string) (*domain.Playlist, error) {
|
||||
return rec.(*domain.Playlist), err
|
||||
}
|
||||
|
||||
func (r *playlistRepository) GetAll(options domain.QueryOptions) (*domain.Playlists, error) {
|
||||
func (r *playlistRepository) GetAll(options domain.QueryOptions) (domain.Playlists, error) {
|
||||
var as = make(domain.Playlists, 0)
|
||||
err := r.loadAll(&as, options)
|
||||
return &as, err
|
||||
return as, err
|
||||
}
|
||||
|
||||
func (r *playlistRepository) PurgeInactive(active domain.Playlists) ([]string, error) {
|
||||
|
||||
Reference in New Issue
Block a user