...
|
...
|
@@ -4,6 +4,8 @@ import java.util.Collections; |
|
|
import java.util.Comparator;
|
|
|
import java.util.List;
|
|
|
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.apache.commons.lang.math.NumberUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
...
|
...
|
@@ -67,7 +69,7 @@ public class MaliciousIpServiceImpl implements MaliciousIpService { |
|
|
* 从Redis中获取恶意ip的内容
|
|
|
*/
|
|
|
@Override
|
|
|
public BaseResponse<List<MaliciousDetailIp>> getDetail(String ip) {
|
|
|
public BaseResponse<List<MaliciousDetailIp>> getDetail(String ip, String count) {
|
|
|
BaseResponse<List<MaliciousDetailIp>> response = new BaseResponse<>();
|
|
|
List<MaliciousDetailIp> listMaliciousDetailIp;
|
|
|
try{
|
...
|
...
|
@@ -76,6 +78,11 @@ public class MaliciousIpServiceImpl implements MaliciousIpService { |
|
|
return response;
|
|
|
}
|
|
|
listMaliciousDetailIp = (List<MaliciousDetailIp>) JSON.parseArray(detail_json, MaliciousDetailIp.class);
|
|
|
if(NumberUtils.isNumber(count) && CollectionUtils.isNotEmpty(listMaliciousDetailIp)){
|
|
|
for (MaliciousDetailIp maliciousDetailIp : listMaliciousDetailIp) {
|
|
|
maliciousDetailIp.setPercent(maliciousDetailIp.getCount() * 100 / Integer.parseInt(count));
|
|
|
}
|
|
|
}
|
|
|
Comparator comp = new ComparatorDetailIp();
|
|
|
Collections.sort(listMaliciousDetailIp, comp);
|
|
|
response.setData(listMaliciousDetailIp);
|
...
|
...
|
@@ -108,9 +115,9 @@ public class MaliciousIpServiceImpl implements MaliciousIpService { |
|
|
public int compare(MaliciousIp e1, MaliciousIp e2) {
|
|
|
int count1 = e1.getCount();
|
|
|
int count2 = e2.getCount();
|
|
|
if (count1 > count2) {
|
|
|
if (count1 < count2) {
|
|
|
return 1;
|
|
|
} else if (count1 < count2) {
|
|
|
} else if (count1 > count2) {
|
|
|
return -1;
|
|
|
} else {
|
|
|
return 0;
|
...
|
...
|
@@ -122,9 +129,9 @@ public class MaliciousIpServiceImpl implements MaliciousIpService { |
|
|
public int compare(MaliciousDetailIp e1, MaliciousDetailIp e2) {
|
|
|
int count1 = e1.getCount();
|
|
|
int count2 = e2.getCount();
|
|
|
if (count1 > count2) {
|
|
|
if (count1 < count2) {
|
|
|
return 1;
|
|
|
} else if (count1 < count2) {
|
|
|
} else if (count1 > count2) {
|
|
|
return -1;
|
|
|
} else {
|
|
|
return 0;
|
...
|
...
|
|