REM:
1. 过滤入参数组中存在null的信息,将该类信息直接判断为参数错误
This commit is contained in:
chenlinghy 2020-05-27 17:12:17 +08:00
parent add96e6bae
commit 9f3d968c50
1 changed files with 41 additions and 4 deletions

View File

@ -42,6 +42,7 @@ import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
@ -86,6 +87,11 @@ public class DisposeNodeInfoController {
LinkStatusListRsp linkStatusListRsp = new LinkStatusListRsp();
linkStatusListRsp.setItems(new ArrayList<>());
if (Arrays.stream(reqInfo.getId()).anyMatch(Objects::isNull)) {
log.error("Request params error, error:{}", mr.getMsgContent());
return ProtocolRespDTO.result(ErrorCode.ERR_PARAMS);
}
if (reqInfo.getId().length == 0) {
List<DisposeDevice> devs = disposeNodeManager.getAllDisposeDevice();
@ -147,6 +153,11 @@ public class DisposeNodeInfoController {
VersionListRsp versionListRsp = new VersionListRsp();
versionListRsp.setItems(new ArrayList<>());
if (Arrays.stream(reqInfo.getId()).anyMatch(Objects::isNull)) {
log.error("Request params error, error:{}", mr.getMsgContent());
return ProtocolRespDTO.result(ErrorCode.ERR_PARAMS);
}
if (reqInfo.getId().length == 0) {
List<DisposeDevice> devList = disposeNodeManager.getAllDisposeDevice();
if (devList != null && devList.size() > 0) {
@ -204,9 +215,13 @@ public class DisposeNodeInfoController {
IDArrayReq reqInfo = mr.getRequestObject(IDArrayReq.class);
DeviceInfoRsp rspInfo = new DeviceInfoRsp();
rspInfo.setItems(new ArrayList<>());
if (Arrays.stream(reqInfo.getId()).anyMatch(Objects::isNull)) {
log.error("Request params error, error:{}", mr.getMsgContent());
return ProtocolRespDTO.result(ErrorCode.ERR_PARAMS);
}
if (reqInfo.getId().length == 0) {
List<DisposeDevice> devList = disposeNodeManager.getAllDisposeDevice();
@ -273,10 +288,14 @@ public class DisposeNodeInfoController {
}
IDArrayReq reqInfo = mr.getRequestObject(IDArrayReq.class);
DeviceCapacityRsp rspInfo = new DeviceCapacityRsp();
rspInfo.setItems(new ArrayList<>());
if (Arrays.stream(reqInfo.getId()).anyMatch(Objects::isNull)) {
log.error("Request params error, error:{}", mr.getMsgContent());
return ProtocolRespDTO.result(ErrorCode.ERR_PARAMS);
}
if (reqInfo.getId().length == 0) {
List<DisposeDevice> devList = disposeNodeManager.getAllDisposeDevice();
@ -338,10 +357,14 @@ public class DisposeNodeInfoController {
}
IDArrayReq reqInfo = mr.getRequestObject(IDArrayReq.class);
DeviceCapacityRsp rspInfo = new DeviceCapacityRsp();
rspInfo.setItems(new ArrayList<>());
if (Arrays.stream(reqInfo.getId()).anyMatch(Objects::isNull)) {
log.error("Request params error, error:{}", mr.getMsgContent());
return ProtocolRespDTO.result(ErrorCode.ERR_PARAMS);
}
if (reqInfo.getId().length == 0) {
List<DisposeDevice> devList = disposeNodeManager.getAllDisposeDevice();
@ -482,10 +505,14 @@ public class DisposeNodeInfoController {
}
IDArrayReq reqInfo = mr.getRequestObject(IDArrayReq.class);
DisposeNodeListRsp rspInfo = new DisposeNodeListRsp();
rspInfo.setItems(new ArrayList<>());
if (Arrays.stream(reqInfo.getId()).anyMatch(Objects::isNull)) {
log.error("Request params error, error:{}", mr.getMsgContent());
return ProtocolRespDTO.result(ErrorCode.ERR_PARAMS);
}
if (reqInfo.getId().length == 0) {
List<DisposeDevice> devList = disposeNodeManager.getAllDisposeDevice();
@ -564,6 +591,11 @@ public class DisposeNodeInfoController {
IDArrayReq reqInfo = mr.getRequestObject(IDArrayReq.class);
NodeTaskRsp rspInfo = new NodeTaskRsp();
if (Arrays.stream(reqInfo.getId()).anyMatch(Objects::isNull)) {
log.error("Request params error, error:{}", mr.getMsgContent());
return ProtocolRespDTO.result(ErrorCode.ERR_PARAMS);
}
List<DisposeDevice> valuableData = disposeNodeManager.getAllDisposeDevice()
.stream()
.filter(v -> reqInfo.getId().length == 0
@ -644,6 +676,11 @@ public class DisposeNodeInfoController {
IDArrayReq reqInfo = mr.getRequestObject(IDArrayReq.class);
NodeTaskRsp rspInfo = new NodeTaskRsp();
if (Arrays.stream(reqInfo.getId()).anyMatch(Objects::isNull)) {
log.error("Request params error, error:{}", mr.getMsgContent());
return ProtocolRespDTO.result(ErrorCode.ERR_PARAMS);
}
List<DisposeDevice> valuableData = disposeNodeManager.getAllDisposeDevice()
.stream()
.filter(v -> reqInfo.getId().length == 0