-
Notifications
You must be signed in to change notification settings - Fork 1
/
detector.go
102 lines (94 loc) · 1.95 KB
/
detector.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
package source
import (
"github.com/admpub/webx/application/dbschema"
"github.com/webx-top/echo"
)
type (
// Detector 确认逻辑 如果sourceId为空白字符串,则代表不限制具体资源
// 例如 BoughtDetector(customer, ``) 则代表判断是否购买过任一产品
Detector func(customer *dbschema.OfficialCustomer, sourceId string) bool
)
func (s *Source) GetBoughtDetector(sourceTable string) Detector {
item := s.GetItem(sourceTable)
if item == nil {
return nil
}
switch v := item.X.(type) {
case *Info:
return v.BoughtDetector()
case Info:
return (&v).BoughtDetector()
default:
return nil
}
}
func (s *Source) GetAgentDetector(sourceTable string) Detector {
item := s.GetItem(sourceTable)
if item == nil {
return nil
}
switch v := item.X.(type) {
case *Info:
return v.AgentDetector()
case Info:
return (&v).AgentDetector()
default:
return nil
}
}
func (s *Source) GetInfoGetter(sourceTable string) InfoGetter {
item := s.GetItem(sourceTable)
if item == nil {
return nil
}
switch v := item.X.(type) {
case *Info:
return v.InfoGetter()
case Info:
return (&v).InfoGetter()
default:
return nil
}
}
func (s *Source) GetInfoMapGetter(sourceTable string) InfoMapGetter {
item := s.GetItem(sourceTable)
if item == nil {
return nil
}
switch v := item.X.(type) {
case *Info:
return v.InfoMapGetter()
case Info:
return (&v).InfoMapGetter()
default:
return nil
}
}
func (s *Source) GetTagsGetter(sourceTable string) TagsGetter {
item := s.GetItem(sourceTable)
if item == nil {
return nil
}
switch v := item.X.(type) {
case *Info:
return v.TagsGetter()
case Info:
return (&v).TagsGetter()
default:
return nil
}
}
func (s *Source) GetSelectPageHandler(sourceTable string) func(echo.Context) error {
item := s.GetItem(sourceTable)
if item == nil {
return nil
}
switch v := item.X.(type) {
case *Info:
return v.SelectPage()
case Info:
return (&v).SelectPage()
default:
return nil
}
}