Introduced interfaces for all repositories, completely isolating the persistence layer from the repositories usage and specification
This commit is contained in:
@@ -5,17 +5,17 @@ import (
|
||||
"errors"
|
||||
)
|
||||
|
||||
type property struct {
|
||||
BaseRepository
|
||||
type propertyRepository struct {
|
||||
baseRepository
|
||||
}
|
||||
|
||||
func NewPropertyRepository() *property {
|
||||
r := &property{}
|
||||
func NewPropertyRepository() domain.PropertyRepository {
|
||||
r := &propertyRepository{}
|
||||
r.init("property", &domain.Property{})
|
||||
return r
|
||||
}
|
||||
|
||||
func (r *property) Put(id string, value string) error {
|
||||
func (r *propertyRepository) Put(id string, value string) error {
|
||||
m := &domain.Property{Id: id, Value: value}
|
||||
if m.Id == "" {
|
||||
return errors.New("Id is required")
|
||||
@@ -23,13 +23,13 @@ func (r *property) Put(id string, value string) error {
|
||||
return r.saveOrUpdate(m.Id, m)
|
||||
}
|
||||
|
||||
func (r *property) Get(id string) (string, error) {
|
||||
func (r *propertyRepository) Get(id string) (string, error) {
|
||||
var rec interface{}
|
||||
rec, err := r.readEntity(id)
|
||||
return rec.(*domain.Property).Value, err
|
||||
}
|
||||
|
||||
func (r*property) DefaultGet(id string, defaultValue string) (string, error) {
|
||||
func (r*propertyRepository) DefaultGet(id string, defaultValue string) (string, error) {
|
||||
v, err := r.Get(id)
|
||||
|
||||
if v == "" {
|
||||
|
||||
Reference in New Issue
Block a user