-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetting.go
More file actions
35 lines (32 loc) · 705 Bytes
/
setting.go
File metadata and controls
35 lines (32 loc) · 705 Bytes
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
package autop2p
type Conf struct {
Settings []Setting
}
type Setting struct {
Username string
Password string
Company CompanyType
Amount int
PeriodMin int `yaml:"periodMin"`
PeriodMax int `yaml:"periodMax"`
RateMin float64 `yaml:"rateMin"`
RateMax float64 `yaml:"rateMax"`
Categories []Category
}
func (s *Setting) Match(product *Product) bool {
if s.Amount > product.RemainAmount {
return false
}
if s.PeriodMax < product.Period || s.PeriodMin > product.Period {
return false
}
if s.RateMax < product.Rate || s.RateMin > product.Rate {
return false
}
for _, c := range s.Categories {
if c == product.Category {
return true
}
}
return false
}