check.go
892 字节
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
package protocol
import "strings"
/*机会-自查内容*/
//自查结果列表
type SelfCheckResults []selfCheckResult
type selfCheckResult struct {
CheckItem string `json:"checkItem"`
Total int `json:"total"`
}
//自查项列表
type SelfChecks []SelfCheck
type SelfCheck struct {
Id int64 `json:"id"`
CheckItem string `json:"checkItem"`
Answer string `json:"answer,omitempty"`
Reason string `json:"reason,omitempty"`
Group int `json:"group"` //分组
}
//统计自查结果
func (s SelfChecks) Static() SelfCheckResults {
results := []selfCheckResult{{CheckItem: "是"}, {CheckItem: "否"}, {CheckItem: "不清楚"}}
for i := range s {
check := (s)[i]
for k := range results {
if strings.EqualFold(results[k].CheckItem, check.CheckItem) {
results[k].Total = results[k].Total + 1
break
}
}
}
return SelfCheckResults(results)
}