-
Notifications
You must be signed in to change notification settings - Fork 0
/
reward.go
45 lines (35 loc) · 933 Bytes
/
reward.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
package db
import (
"github.com/ivzb/achievers_server/app/model"
"github.com/ivzb/achievers_server/app/shared/consts"
)
type Rewarder interface {
Exists(id interface{}) (bool, error)
Single(id string) (interface{}, error)
Create(reward interface{}) (string, error)
LastID() (string, error)
After(id string) ([]interface{}, error)
}
type Reward struct {
*Context
}
func (db *DB) Reward() Rewarder {
return &Reward{
newContext(db, consts.Reward, new(model.Reward)),
}
}
func (ctx *Reward) Exists(id interface{}) (bool, error) {
return ctx.exists(&model.Reward{ID: id.(string)})
}
func (ctx *Reward) Single(id string) (interface{}, error) {
return ctx.single(id)
}
func (ctx *Reward) Create(reward interface{}) (string, error) {
return ctx.create(reward)
}
func (ctx *Reward) LastID() (string, error) {
return ctx.lastID()
}
func (ctx *Reward) After(id string) ([]interface{}, error) {
return ctx.after(id)
}