No need to expose implementations

This commit is contained in:
Deluan 2016-03-01 19:17:30 -05:00
parent 78805ac465
commit 6092076fad
4 changed files with 13 additions and 13 deletions

View File

@ -11,30 +11,30 @@ type ArtistIndex interface {
GetAll() ([]models.ArtistIndex, error)
}
type ArtistIndexImpl struct {
type artistIndex struct {
BaseRepository
}
func NewArtistIndexRepository() ArtistIndex {
r := &ArtistIndexImpl{}
r := &artistIndex{}
r.init("index", &models.ArtistIndex{})
return r
}
func (r *ArtistIndexImpl) Put(m *models.ArtistIndex) error {
func (r *artistIndex) Put(m *models.ArtistIndex) error {
if m.Id == "" {
return errors.New("Id is not set")
}
return r.saveOrUpdate(m.Id, m)
}
func (r *ArtistIndexImpl) Get(id string) (*models.ArtistIndex, error) {
func (r *artistIndex) Get(id string) (*models.ArtistIndex, error) {
var rec interface{}
rec, err := r.readEntity(id)
return rec.(*models.ArtistIndex), err
}
func (r *ArtistIndexImpl) GetAll() ([]models.ArtistIndex, error) {
func (r *artistIndex) GetAll() ([]models.ArtistIndex, error) {
var indices = make([]models.ArtistIndex, 0)
err := r.loadAll(&indices)
return indices, err

View File

@ -11,17 +11,17 @@ type Property interface {
DefaultGet(id string, defaultValue string) (string, error)
}
type PropertyImpl struct {
type property struct {
BaseRepository
}
func NewPropertyRepository() *PropertyImpl {
r := &PropertyImpl{}
func NewPropertyRepository() *property {
r := &property{}
r.init("property", &models.Property{})
return r
}
func (r *PropertyImpl) Put(id string, value string) error {
func (r *property) Put(id string, value string) error {
m := &models.Property{Id: id, Value: value}
if m.Id == "" {
return errors.New("Id is required")
@ -29,13 +29,13 @@ func (r *PropertyImpl) Put(id string, value string) error {
return r.saveOrUpdate(m.Id, m)
}
func (r *PropertyImpl) Get(id string) (string, error) {
func (r *property) Get(id string) (string, error) {
var rec interface{}
rec, err := r.readEntity(id)
return rec.(*models.Property).Value, err
}
func (r* PropertyImpl) DefaultGet(id string, defaultValue string) (string, error) {
func (r*property) DefaultGet(id string, defaultValue string) (string, error) {
v, err := r.Get(id)
if v == "" {

View File

@ -13,7 +13,7 @@ func CreateMockArtistIndexRepo() *MockArtistIndex {
}
type MockArtistIndex struct {
repositories.ArtistIndexImpl
repositories.ArtistIndex
data []models.ArtistIndex
err bool
}

View File

@ -10,7 +10,7 @@ func CreateMockPropertyRepo() *MockProperty {
}
type MockProperty struct {
repositories.PropertyImpl
repositories.Property
data map[string]string
err bool
}