-
Notifications
You must be signed in to change notification settings - Fork 1
/
info.go
87 lines (72 loc) · 1.76 KB
/
info.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package source
import "github.com/webx-top/echo"
type (
// InfoGetter 查询单个数据
InfoGetter func(ctx echo.Context, sourceId string) (echo.KV, error)
// InfoMapGetter 查询多个数据
InfoMapGetter func(ctx echo.Context, sourceId ...string) (map[string]echo.KV, error)
// TagsGetter 查询标签
TagsGetter func(ctx echo.Context, sourceId interface{}) ([]echo.H, error)
// Info 资源信息
Info struct {
isBought Detector
isAgent Detector
getInfo InfoGetter
getInfoMap InfoMapGetter
getTags TagsGetter
selectPageHandler func(echo.Context) error
}
// Infor 数据接口
Infor interface {
BoughtDetector() Detector
AgentDetector() Detector
InfoGetter() InfoGetter
TagsGetter() TagsGetter
SelectPage() func(echo.Context) error
}
)
func NewInfo() *Info {
return &Info{}
}
func (s *Info) BoughtDetector() Detector {
return s.isBought
}
func (s *Info) SetBoughtDetector(fn Detector) *Info {
s.isBought = fn
return s
}
func (s *Info) AgentDetector() Detector {
return s.isAgent
}
func (s *Info) SetAgentDetector(fn Detector) *Info {
s.isAgent = fn
return s
}
func (s *Info) InfoGetter() InfoGetter {
return s.getInfo
}
func (s *Info) SetInfoGetter(fn InfoGetter) *Info {
s.getInfo = fn
return s
}
func (s *Info) InfoMapGetter() InfoMapGetter {
return s.getInfoMap
}
func (s *Info) SetInfoMapGetter(fn InfoMapGetter) *Info {
s.getInfoMap = fn
return s
}
func (s *Info) TagsGetter() TagsGetter {
return s.getTags
}
func (s *Info) SetTagsGetter(fn TagsGetter) *Info {
s.getTags = fn
return s
}
func (s *Info) SetSelectPageHandler(h func(echo.Context) error) *Info {
s.selectPageHandler = h
return s
}
func (s *Info) SelectPage() func(echo.Context) error {
return s.selectPageHandler
}