-
Notifications
You must be signed in to change notification settings - Fork 8.5k
/
WallResult.java
117 lines (104 loc) · 4.91 KB
/
WallResult.java
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
package com.alibaba.druid.admin.model.dto;
import com.alibaba.fastjson2.annotation.JSONField;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* @author linchtech
* @date 2020-09-17 18:18
**/
@Data
@NoArgsConstructor
public class WallResult {
@JSONField(name = "ResultCode")
private int ResultCode;
@JSONField(name = "Content")
private ContentBean Content = new ContentBean();
@NoArgsConstructor
@Data
public static class ContentBean {
@JSONField(name = "checkCount")
private int checkCount;
@JSONField(name = "hardCheckCount")
private int hardCheckCount;
@JSONField(name = "violationCount")
private int violationCount;
@JSONField(name = "violationEffectRowCount")
private int violationEffectRowCount;
@JSONField(name = "blackListHitCount")
private int blackListHitCount;
@JSONField(name = "blackListSize")
private int blackListSize;
@JSONField(name = "whiteListHitCount")
private int whiteListHitCount;
@JSONField(name = "whiteListSize")
private int whiteListSize;
@JSONField(name = "syntaxErrorCount")
private int syntaxErrorCount;
@JSONField(name = "tables")
private List<TablesBean> tables = new ArrayList<>();
@JSONField(name = "functions")
private List<FunctionsBean> functions = new ArrayList<>();
@JSONField(name = "blackList")
private List<Object> blackList = new ArrayList<>();
@JSONField(name = "whiteList")
private List<WhiteListBean> whiteList = new ArrayList<>();
@NoArgsConstructor
@Data
public static class TablesBean {
@JSONField(name = "name")
private String name;
@JSONField(name = "selectCount")
private int selectCount;
@JSONField(name = "fetchRowCount")
private int fetchRowCount;
@JSONField(name = "fetchRowCountHistogram")
private List<Integer> fetchRowCountHistogram;
}
@NoArgsConstructor
@Data
public static class FunctionsBean {
@JSONField(name = "name")
private String name;
@JSONField(name = "invokeCount")
private int invokeCount;
}
@NoArgsConstructor
@Data
public static class WhiteListBean {
@JSONField(name = "sql")
private String sql;
@JSONField(name = "sample")
private String sample;
@JSONField(name = "executeCount")
private int executeCount;
@JSONField(name = "fetchRowCount")
private int fetchRowCount;
}
}
/**
* 累加结果
*
* @param wallResult 需要累加的对象
* @param sumResult 累加后的对象
*/
public void sum(WallResult wallResult, WallResult sumResult) {
sumResult.getContent().setCheckCount(sumResult.getContent().getCheckCount() + wallResult.getContent().getCheckCount());
sumResult.getContent().setHardCheckCount(sumResult.getContent().getHardCheckCount() + wallResult.getContent().getHardCheckCount());
sumResult.getContent().setViolationCount(sumResult.getContent().getViolationCount() + wallResult.getContent().getViolationCount());
sumResult.getContent().setViolationEffectRowCount(sumResult.getContent().getViolationEffectRowCount() + wallResult.getContent().getViolationEffectRowCount());
sumResult.getContent().setBlackListHitCount(sumResult.getContent().getBlackListHitCount() + wallResult.getContent().getBlackListHitCount());
sumResult.getContent().setBlackListSize(sumResult.getContent().getBlackListSize() + wallResult.getContent().getBlackListSize());
sumResult.getContent().setWhiteListHitCount(sumResult.getContent().getWhiteListHitCount() + wallResult.getContent().getWhiteListHitCount());
sumResult.getContent().setWhiteListSize(sumResult.getContent().getWhiteListSize() + wallResult.getContent().getWhiteListSize());
sumResult.getContent().setSyntaxErrorCount(sumResult.getContent().getSyntaxErrorCount() + wallResult.getContent().getSyntaxErrorCount());
sumResult.getContent().getTables().addAll(wallResult.getContent().getTables() == null ? Collections.emptyList() : wallResult.getContent().getTables());
sumResult.getContent().getFunctions().addAll(wallResult.getContent().getFunctions() == null ? Collections.emptyList() :
wallResult.getContent().getFunctions());
sumResult.getContent().getBlackList().addAll(wallResult.getContent().getBlackList() == null ? Collections.emptyList() :
wallResult.getContent().getBlackList());
sumResult.getContent().getWhiteList().addAll(wallResult.getContent().getWhiteList() == null ? Collections.emptyList() : wallResult.getContent().getWhiteList());
}
}