-
Notifications
You must be signed in to change notification settings - Fork 0
/
report.go
73 lines (66 loc) · 2.13 KB
/
report.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
package main
import (
"encoding/json"
"log"
"os"
)
type Report struct {
UpReport UpReport `json:"upReport"`
UpBindingReport UpBindingReport `json:"upBindingReport"`
FilterReport FilterReport `json:"filterReport"`
ActionReport ActionReport `json:"actionReport"`
}
type UpReport struct {
GetCsvUpNum int `json:"getCsvUpNum"`
GetConfigRulebaseNum int `json:"getConfigRulebaseNum"`
OnlyCsvHaveUserProfile []string `json:"onlyCsvHaveUserProfile"`
OnlyConfigHaveUserProfile []string `json:"onlyConfigHaveUserProfile"`
}
type UpBindingReport struct {
GetCsvUpBindingReportRuleNum int `json:"getCsvUpBindingReportRuleNum"`
GetConfigRuleNum int `json:"getConfigRuleNum"`
Diffs []Diff `json:"diffs"`
}
type Diff struct {
Line int `json:"line"`
CsvPara CsvRule `json:"CsvRule"`
ConfigPara ConfigRule `json:"ConfigRule"`
Msg string `json:"msg"`
}
type FilterReport struct {
CsvGroupCount int `json:"csvGroupCount"`
CsvFilterActionCount int `json:"csvFilterActionCount"`
ConfigRuleDefCount int `json:"configRuleDefCount"`
ConfigActionCount int `json:"configActionCount"`
FilterDiffs []FilterDiff `json:"filterDiffs"`
}
type FilterDiff struct {
Msg string `json:"msg"`
CsvPara CsvFilter `json:"csvPara"`
ConfigPara string `json:"configPara"`
}
type ActionReport struct {
CsvChargingNameCount int `json:"csvChargingCount"`
ConfigChargingNameCount int `json:"configChargingCount"`
ActionDiffs []ActionDiff `json:"actionDiffs"`
}
type ActionDiff struct {
Msg string `json:"msg"`
CsvChargingName string `json:"CsvChargingName"`
ConfigChargingName string `json:"configChargingName"`
}
func (r *Report) WriteReport() {
file, err := os.OpenFile("./data/report.txt", os.O_CREATE|os.O_RDWR, 0755)
if err != nil {
panic(err)
}
marshal, err := json.Marshal(r)
if err != nil {
panic(err)
}
_, err = file.WriteString(string(marshal))
if err != nil {
panic(err)
}
log.Printf("work finished success")
}