mirror of
https://github.com/navidrome/navidrome.git
synced 2025-06-06 10:23:21 +03:00
Storm IndexRepository complete.
This commit is contained in:
parent
9ccd9545e8
commit
a1d837cb9b
@ -4,7 +4,6 @@ import "github.com/google/wire"
|
|||||||
|
|
||||||
var Set = wire.NewSet(
|
var Set = wire.NewSet(
|
||||||
NewCheckSumRepository,
|
NewCheckSumRepository,
|
||||||
NewArtistIndexRepository,
|
|
||||||
NewMediaFolderRepository,
|
NewMediaFolderRepository,
|
||||||
NewNowPlayingRepository,
|
NewNowPlayingRepository,
|
||||||
NewPlaylistRepository,
|
NewPlaylistRepository,
|
||||||
|
59
persistence/storm/index_repository.go
Normal file
59
persistence/storm/index_repository.go
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
package storm
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/cloudsonic/sonic-server/domain"
|
||||||
|
)
|
||||||
|
|
||||||
|
type _ArtistIndex struct {
|
||||||
|
Id string
|
||||||
|
Artists domain.ArtistInfos
|
||||||
|
}
|
||||||
|
|
||||||
|
type artistIndexRepository struct {
|
||||||
|
stormRepository
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewArtistIndexRepository() domain.ArtistIndexRepository {
|
||||||
|
r := &artistIndexRepository{}
|
||||||
|
r.init(&_ArtistIndex{})
|
||||||
|
return r
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *artistIndexRepository) Put(i *domain.ArtistIndex) error {
|
||||||
|
ti := _ArtistIndex(*i)
|
||||||
|
return Db().Save(&ti)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *artistIndexRepository) Get(id string) (*domain.ArtistIndex, error) {
|
||||||
|
ta := &_ArtistIndex{}
|
||||||
|
err := r.getByID(id, ta)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
a := domain.ArtistIndex(*ta)
|
||||||
|
return &a, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *artistIndexRepository) GetAll() (domain.ArtistIndexes, error) {
|
||||||
|
var all []_ArtistIndex
|
||||||
|
err := r.getAll(&all, &domain.QueryOptions{})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return r.toArtistIndexes(all)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *artistIndexRepository) toArtistIndexes(all []_ArtistIndex) (domain.ArtistIndexes, error) {
|
||||||
|
result := make(domain.ArtistIndexes, len(all))
|
||||||
|
for i, a := range all {
|
||||||
|
result[i] = domain.ArtistIndex(a)
|
||||||
|
}
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *artistIndexRepository) DeleteAll() error {
|
||||||
|
return Db().Drop(&_ArtistIndex{})
|
||||||
|
}
|
||||||
|
|
||||||
|
var _ domain.ArtistIndexRepository = (*artistIndexRepository)(nil)
|
||||||
|
var _ = domain.ArtistIndex(_ArtistIndex{})
|
@ -7,4 +7,5 @@ var Set = wire.NewSet(
|
|||||||
NewArtistRepository,
|
NewArtistRepository,
|
||||||
NewAlbumRepository,
|
NewAlbumRepository,
|
||||||
NewMediaFileRepository,
|
NewMediaFileRepository,
|
||||||
|
NewArtistIndexRepository,
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user