Moved ledis implementation to a new package
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
package ledis
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/cloudsonic/sonic-server/domain"
|
||||
)
|
||||
|
||||
type artistRepository struct {
|
||||
ledisRepository
|
||||
}
|
||||
|
||||
func NewArtistRepository() domain.ArtistRepository {
|
||||
r := &artistRepository{}
|
||||
r.init("artist", &domain.Artist{})
|
||||
return r
|
||||
}
|
||||
|
||||
func (r *artistRepository) Put(m *domain.Artist) error {
|
||||
if m.Id == "" {
|
||||
return errors.New("artist Id is not set")
|
||||
}
|
||||
return r.saveOrUpdate(m.Id, m)
|
||||
}
|
||||
|
||||
func (r *artistRepository) Get(id string) (*domain.Artist, error) {
|
||||
var rec interface{}
|
||||
rec, err := r.readEntity(id)
|
||||
return rec.(*domain.Artist), err
|
||||
}
|
||||
|
||||
func (r *artistRepository) PurgeInactive(active domain.Artists) ([]string, error) {
|
||||
return r.purgeInactive(active, func(e interface{}) string {
|
||||
return e.(domain.Artist).Id
|
||||
})
|
||||
}
|
||||
|
||||
var _ domain.ArtistRepository = (*artistRepository)(nil)
|
||||
Reference in New Issue
Block a user