/
ItemMemoryPersistence.go
65 lines (55 loc) · 1.82 KB
/
ItemMemoryPersistence.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package test_persistence
import (
"reflect"
cdata "github.com/pip-services3-go/pip-services3-commons-go/data"
cpersist "github.com/pip-services3-go/pip-services3-data-go/persistence"
)
// extends IdentifiableMemoryPersistence
// implements IItemPersistence
type ItemMemoryPersistence struct {
cpersist.IdentifiableMemoryPersistence
}
func NewItemMemoryPersistence() *ItemMemoryPersistence {
proto := reflect.TypeOf(Item{})
return &ItemMemoryPersistence{*cpersist.NewIdentifiableMemoryPersistence(proto)}
}
func (c *ItemMemoryPersistence) Create(correlationId string, item Item) (result Item, err error) {
value, err := c.IdentifiableMemoryPersistence.Create(correlationId, item)
if value != nil {
val, _ := value.(Item)
result = val
}
return result, err
}
func (c *ItemMemoryPersistence) GetOneById(correlationId string, id string) (item Item, err error) {
result, err := c.IdentifiableMemoryPersistence.GetOneById(correlationId, id)
if result != nil {
val, _ := result.(Item)
item = val
}
return item, err
}
func (c *ItemMemoryPersistence) Update(correlationId string, item Item) (result Item, err error) {
value, err := c.IdentifiableMemoryPersistence.Update(correlationId, item)
if value != nil {
val, _ := value.(Item)
result = val
}
return result, err
}
func (c *ItemMemoryPersistence) UpdatePartially(correlationId string, id string, data *cdata.AnyValueMap) (item Item, err error) {
result, err := c.IdentifiableMemoryPersistence.UpdatePartially(correlationId, id, data)
if result != nil {
val, _ := result.(Item)
item = val
}
return item, err
}
func (c *ItemMemoryPersistence) DeleteById(correlationId string, id string) (item Item, err error) {
result, err := c.IdentifiableMemoryPersistence.DeleteById(correlationId, id)
if result != nil {
val, _ := result.(Item)
item = val
}
return item, err
}