Moved ledis implementation to a new package

This commit is contained in:
Deluan
2020-01-09 23:01:04 -05:00
committed by Deluan Quintão
parent a4a8360a94
commit 018352463f
19 changed files with 56 additions and 56 deletions
+38
View File
@@ -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)