正在显示
1 个修改的文件
包含
37 行增加
和
0 行删除
protocol/check.go
0 → 100644
| 1 | +package protocol | ||
| 2 | + | ||
| 3 | +import "strings" | ||
| 4 | + | ||
| 5 | +/*机会-自查内容*/ | ||
| 6 | + | ||
| 7 | +//自查结果列表 | ||
| 8 | +type SelfCheckResults []selfCheckResult | ||
| 9 | +type selfCheckResult struct { | ||
| 10 | + CheckItem string `json:"checkItem"` | ||
| 11 | + Total int `json:"total"` | ||
| 12 | +} | ||
| 13 | + | ||
| 14 | +//自查项列表 | ||
| 15 | +type SelfChecks []SelfCheck | ||
| 16 | +type SelfCheck struct { | ||
| 17 | + Id int64 `json:"id"` | ||
| 18 | + CheckItem string `json:"checkItem"` | ||
| 19 | + Answer string `json:"answer,omitempty"` | ||
| 20 | + Reason string `json:"reason,omitempty"` | ||
| 21 | + Group int `json:"group"` //分组 | ||
| 22 | +} | ||
| 23 | + | ||
| 24 | +//统计自查结果 | ||
| 25 | +func (s SelfChecks) Static() SelfCheckResults { | ||
| 26 | + results := []selfCheckResult{{CheckItem: "是"}, {CheckItem: "否"}, {CheckItem: "不清楚"}} | ||
| 27 | + for i := range s { | ||
| 28 | + check := (s)[i] | ||
| 29 | + for k := range results { | ||
| 30 | + if strings.EqualFold(results[k].CheckItem, check.CheckItem) { | ||
| 31 | + results[k].Total = results[k].Total + 1 | ||
| 32 | + break | ||
| 33 | + } | ||
| 34 | + } | ||
| 35 | + } | ||
| 36 | + return SelfCheckResults(results) | ||
| 37 | +} |
-
请 注册 或 登录 后发表评论