Implemented ProperyRepository. Now the Scanner stores the LastScan timestamp

This commit is contained in:
Deluan
2016-03-01 14:40:26 -05:00
parent 1ceefda6ca
commit 841d8f457f
10 changed files with 178 additions and 38 deletions
+35
View File
@@ -0,0 +1,35 @@
package repositories
import (
"github.com/deluan/gosonic/models"
"errors"
)
type Property interface {
Put(id string, value string) error
Get(id string) (string, error)
}
type PropertyImpl struct {
BaseRepository
}
func NewPropertyRepository() *PropertyImpl {
r := &PropertyImpl{}
r.init("property", &models.Property{})
return r
}
func (r *PropertyImpl) Put(id string, value string) error {
m := &models.Property{Id: id, Value: value}
if m.Id == "" {
return errors.New("Id is required")
}
return r.saveOrUpdate(m.Id, m)
}
func (r *PropertyImpl) Get(id string) (string, error) {
var rec interface{}
rec, err := r.readEntity(id)
return rec.(*models.Property).Value, err
}