Rename domain to model
This commit is contained in:
@@ -2,7 +2,7 @@ package persistence
|
||||
|
||||
import (
|
||||
"github.com/astaxie/beego/orm"
|
||||
"github.com/cloudsonic/sonic-server/domain"
|
||||
"github.com/cloudsonic/sonic-server/model"
|
||||
)
|
||||
|
||||
// This is used to isolate Storm's struct tags from the domain, to keep it agnostic of persistence details
|
||||
@@ -16,42 +16,42 @@ type artistRepository struct {
|
||||
searchableRepository
|
||||
}
|
||||
|
||||
func NewArtistRepository() domain.ArtistRepository {
|
||||
func NewArtistRepository() model.ArtistRepository {
|
||||
r := &artistRepository{}
|
||||
r.tableName = "artist"
|
||||
return r
|
||||
}
|
||||
|
||||
func (r *artistRepository) Put(a *domain.Artist) error {
|
||||
func (r *artistRepository) Put(a *model.Artist) error {
|
||||
ta := Artist(*a)
|
||||
return withTx(func(o orm.Ormer) error {
|
||||
return r.put(o, a.ID, a.Name, &ta)
|
||||
})
|
||||
}
|
||||
|
||||
func (r *artistRepository) Get(id string) (*domain.Artist, error) {
|
||||
func (r *artistRepository) Get(id string) (*model.Artist, error) {
|
||||
ta := Artist{ID: id}
|
||||
err := Db().Read(&ta)
|
||||
if err == orm.ErrNoRows {
|
||||
return nil, domain.ErrNotFound
|
||||
return nil, model.ErrNotFound
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
a := domain.Artist(ta)
|
||||
a := model.Artist(ta)
|
||||
return &a, nil
|
||||
}
|
||||
|
||||
func (r *artistRepository) PurgeInactive(activeList domain.Artists) error {
|
||||
func (r *artistRepository) PurgeInactive(activeList model.Artists) error {
|
||||
return withTx(func(o orm.Ormer) error {
|
||||
_, err := r.purgeInactive(o, activeList, func(item interface{}) string {
|
||||
return item.(domain.Artist).ID
|
||||
return item.(model.Artist).ID
|
||||
})
|
||||
return err
|
||||
})
|
||||
}
|
||||
|
||||
func (r *artistRepository) Search(q string, offset int, size int) (domain.Artists, error) {
|
||||
func (r *artistRepository) Search(q string, offset int, size int) (model.Artists, error) {
|
||||
if len(q) <= 2 {
|
||||
return nil, nil
|
||||
}
|
||||
@@ -65,13 +65,13 @@ func (r *artistRepository) Search(q string, offset int, size int) (domain.Artist
|
||||
return r.toArtists(results), nil
|
||||
}
|
||||
|
||||
func (r *artistRepository) toArtists(all []Artist) domain.Artists {
|
||||
result := make(domain.Artists, len(all))
|
||||
func (r *artistRepository) toArtists(all []Artist) model.Artists {
|
||||
result := make(model.Artists, len(all))
|
||||
for i, a := range all {
|
||||
result[i] = domain.Artist(a)
|
||||
result[i] = model.Artist(a)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
var _ domain.ArtistRepository = (*artistRepository)(nil)
|
||||
var _ = domain.Artist(Artist{})
|
||||
var _ model.ArtistRepository = (*artistRepository)(nil)
|
||||
var _ = model.Artist(Artist{})
|
||||
|
||||
Reference in New Issue
Block a user