OCT REM:[修改DeviceNodeInfoController类:1、修改获取处置设备版本接口(/information/version)返回json格式 2、修改链路链接状态接口(/information/linkstatus)返回json格式]
This commit is contained in:
parent
37b8322584
commit
81b4e2a393
|
@ -16,9 +16,11 @@ import com.dispose.pojo.vo.information.DeviceInfoData;
|
|||
import com.dispose.pojo.vo.information.DeviceInfoRsp;
|
||||
import com.dispose.pojo.vo.information.DisposeNodeData;
|
||||
import com.dispose.pojo.vo.information.DisposeNodeListRsp;
|
||||
import com.dispose.pojo.vo.information.LinkStatusListRsp;
|
||||
import com.dispose.pojo.vo.information.LinkStatusRsp;
|
||||
import com.dispose.pojo.vo.information.NodeTaskData;
|
||||
import com.dispose.pojo.vo.information.NodeTaskRsp;
|
||||
import com.dispose.pojo.vo.information.VersionListRsp;
|
||||
import com.dispose.pojo.vo.information.VersionRsp;
|
||||
import com.dispose.service.DisposeNodeManager;
|
||||
import com.dispose.service.TaskService;
|
||||
|
@ -93,52 +95,46 @@ public class DisposeNodeInfoController {
|
|||
}
|
||||
|
||||
IDArrayReq reqInfo = mr.getRequestObject(IDArrayReq.class);
|
||||
List<LinkStatusRsp> rspInfo = new ArrayList<>();
|
||||
LinkStatusListRsp linkStatusListRsp = new LinkStatusListRsp();
|
||||
linkStatusListRsp.setItems(new ArrayList<LinkStatusRsp>());
|
||||
|
||||
if (reqInfo.getId().length == 0) {
|
||||
List<DisposeDevice> devs = disposeNodeManager.getAllDisposeDevice();
|
||||
|
||||
if (devs != null && devs.size() > 0) {
|
||||
devs.forEach(v -> {
|
||||
LinkStatusRsp linkStat = LinkStatusRsp.builder()
|
||||
.online(v.getLinkStatus())
|
||||
.build();
|
||||
linkStat.setId(v.getId()
|
||||
.toString());
|
||||
linkStat.setStatus(ErrorCode.ERR_OK.getCode());
|
||||
linkStat.setMessage(ErrorCode.ERR_OK.getMsg());
|
||||
|
||||
rspInfo.add(linkStat);
|
||||
});
|
||||
devs.forEach(v -> linkStatusListRsp.getItems()
|
||||
.add(LinkStatusRsp.builder()
|
||||
.online(v.getLinkStatus())
|
||||
.id(v.getId().toString())
|
||||
.status(ErrorCode.ERR_OK.getCode())
|
||||
.message(ErrorCode.ERR_OK.getMsg())
|
||||
.build()));
|
||||
}
|
||||
} else {
|
||||
for (String v : reqInfo.getId()) {
|
||||
DisposeDevice dev = disposeNodeManager.getDisposeDeviceById(Long.valueOf(v));
|
||||
LinkStatusRsp linkStat;
|
||||
if (dev != null && dev.getId()
|
||||
.equals(Long.valueOf(v))) {
|
||||
linkStat = LinkStatusRsp.builder()
|
||||
.online(dev.getLinkStatus())
|
||||
.build();
|
||||
linkStat.setId(dev.getId()
|
||||
.toString());
|
||||
err = ErrorCode.ERR_OK;
|
||||
linkStatusListRsp.getItems()
|
||||
.add(LinkStatusRsp.builder()
|
||||
.online(dev.getLinkStatus())
|
||||
.id(dev.getId().toString())
|
||||
.status(ErrorCode.ERR_OK.getCode())
|
||||
.message(ErrorCode.ERR_OK.getMsg())
|
||||
.build());
|
||||
} else {
|
||||
linkStat = LinkStatusRsp.builder()
|
||||
.online(0)
|
||||
.build();
|
||||
linkStat.setId(v);
|
||||
err = ErrorCode.ERR_NOSUCHDEVICE;
|
||||
linkStatusListRsp.getItems()
|
||||
.add(LinkStatusRsp.builder()
|
||||
.online(0)
|
||||
.id(v)
|
||||
.status(ErrorCode.ERR_NOSUCHDEVICE.getCode())
|
||||
.message(ErrorCode.ERR_NOSUCHDEVICE.getMsg()).
|
||||
build());
|
||||
}
|
||||
|
||||
linkStat.setStatus(err.getCode());
|
||||
linkStat.setMessage(err.getMsg());
|
||||
|
||||
rspInfo.add(linkStat);
|
||||
}
|
||||
}
|
||||
|
||||
return ProtocolRespDTO.result(ErrorCode.ERR_OK, rspInfo);
|
||||
return ProtocolRespDTO.result(ErrorCode.ERR_OK, linkStatusListRsp);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -163,21 +159,20 @@ public class DisposeNodeInfoController {
|
|||
|
||||
IDArrayReq reqInfo = mr.getRequestObject(IDArrayReq.class);
|
||||
List<VersionRsp> rspInfo = new ArrayList<>();
|
||||
VersionListRsp versionListRsp = new VersionListRsp();
|
||||
versionListRsp.setItems(new ArrayList<>());
|
||||
|
||||
if (reqInfo.getId().length == 0) {
|
||||
List<DisposeDevice> devList = disposeNodeManager.getAllDisposeDevice();
|
||||
|
||||
if (devList != null && devList.size() > 0) {
|
||||
devList.forEach(v -> {
|
||||
VersionRsp ver = VersionRsp.builder().version(v.getVersion()).build();
|
||||
|
||||
ver.setId(v.getId().toString());
|
||||
|
||||
ver.setStatus(ErrorCode.ERR_OK.getCode());
|
||||
ver.setMessage(ErrorCode.ERR_OK.getMsg());
|
||||
|
||||
rspInfo.add(ver);
|
||||
});
|
||||
devList.forEach(v -> versionListRsp.getItems()
|
||||
.add(VersionRsp.builder()
|
||||
.id(v.getId().toString())
|
||||
.version(v.getVersion())
|
||||
.status(ErrorCode.ERR_OK.getCode())
|
||||
.message(ErrorCode.ERR_OK.getMsg())
|
||||
.build()));
|
||||
}
|
||||
} else {
|
||||
for (String v : reqInfo.getId()) {
|
||||
|
@ -185,27 +180,26 @@ public class DisposeNodeInfoController {
|
|||
VersionRsp ver;
|
||||
if (dev != null && dev.getId()
|
||||
.equals(Long.valueOf(v))) {
|
||||
ver = VersionRsp.builder()
|
||||
.version(dev.getVersion())
|
||||
.build();
|
||||
ver.setId(dev.getId()
|
||||
.toString());
|
||||
err = ErrorCode.ERR_OK;
|
||||
versionListRsp.getItems()
|
||||
.add(VersionRsp.builder()
|
||||
.id(dev.getId().toString())
|
||||
.version(dev.getVersion())
|
||||
.status(ErrorCode.ERR_OK.getCode())
|
||||
.message(ErrorCode.ERR_OK.getMsg())
|
||||
.build());
|
||||
} else {
|
||||
ver = VersionRsp.builder()
|
||||
.build();
|
||||
ver.setId(v);
|
||||
err = ErrorCode.ERR_NOSUCHDEVICE;
|
||||
versionListRsp.getItems()
|
||||
.add(VersionRsp.builder()
|
||||
.id(v)
|
||||
.status(ErrorCode.ERR_NOSUCHDEVICE.getCode())
|
||||
.message(ErrorCode.ERR_NOSUCHDEVICE.getMsg())
|
||||
.build());
|
||||
}
|
||||
|
||||
ver.setStatus(err.getCode());
|
||||
ver.setMessage(err.getMsg());
|
||||
|
||||
rspInfo.add(ver);
|
||||
}
|
||||
}
|
||||
|
||||
return ProtocolRespDTO.result(ErrorCode.ERR_OK, rspInfo);
|
||||
return ProtocolRespDTO.result(ErrorCode.ERR_OK, versionListRsp);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* Project: phoenix_ddos_handle2
|
||||
*
|
||||
* File Created at 2020/5/11 10:59
|
||||
*
|
||||
* Copyright 2019 CMCC Corporation Limited.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of
|
||||
* ZYHY Company. ("Confidential Information"). You shall not
|
||||
* disclose such Confidential Information and shall use it only in
|
||||
* accordance with the terms of the license.
|
||||
*/
|
||||
package com.dispose.pojo.vo.information;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author lsx
|
||||
* @Desc
|
||||
* @date
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class LinkStatusListRsp {
|
||||
/**
|
||||
* The Items.
|
||||
*/
|
||||
private List<LinkStatusRsp> items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Revision history
|
||||
* -------------------------------------------------------------------------
|
||||
* <p>
|
||||
* Date Author Note
|
||||
* -------------------------------------------------------------------------
|
||||
* lsx creat
|
||||
*/
|
|
@ -22,4 +22,16 @@ public class LinkStatusRsp extends IDReturnStatus {
|
|||
* The Online.
|
||||
*/
|
||||
private int online;
|
||||
/**
|
||||
* the id
|
||||
*/
|
||||
private String id;
|
||||
/**
|
||||
* the status
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* the message
|
||||
*/
|
||||
private String message;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* Project: phoenix_ddos_handle2
|
||||
*
|
||||
* File Created at 2020/5/11 12:54
|
||||
*
|
||||
* Copyright 2019 CMCC Corporation Limited.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of
|
||||
* ZYHY Company. ("Confidential Information"). You shall not
|
||||
* disclose such Confidential Information and shall use it only in
|
||||
* accordance with the terms of the license.
|
||||
*/
|
||||
package com.dispose.pojo.vo.information;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author lsx
|
||||
* @Desc
|
||||
* @date
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class VersionListRsp {
|
||||
/**
|
||||
* the items
|
||||
*/
|
||||
private List<VersionRsp> items;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Revision history
|
||||
* -------------------------------------------------------------------------
|
||||
* <p>
|
||||
* Date Author Note
|
||||
* -------------------------------------------------------------------------
|
||||
* lsx creat
|
||||
*/
|
|
@ -22,4 +22,20 @@ public class VersionRsp extends IDReturnStatus {
|
|||
* The Version.
|
||||
*/
|
||||
private String version;
|
||||
/**
|
||||
* the id
|
||||
*/
|
||||
private String id;
|
||||
/**
|
||||
* the devId
|
||||
*/
|
||||
private String devId;
|
||||
/**
|
||||
* the status
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* the message
|
||||
*/
|
||||
private String message;
|
||||
}
|
||||
|
|
|
@ -19,7 +19,9 @@ import com.dispose.pojo.entity.DisposeDevice;
|
|||
import com.dispose.pojo.po.ReturnStatus;
|
||||
import com.dispose.pojo.vo.information.DeviceInfoData;
|
||||
import com.dispose.pojo.vo.information.DeviceInfoRsp;
|
||||
import com.dispose.pojo.vo.information.LinkStatusListRsp;
|
||||
import com.dispose.pojo.vo.information.LinkStatusRsp;
|
||||
import com.dispose.pojo.vo.information.VersionListRsp;
|
||||
import com.dispose.pojo.vo.information.VersionRsp;
|
||||
import com.dispose.service.DisposeNodeManager;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
|
@ -94,8 +96,8 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment{
|
|||
.getResponse()
|
||||
.getContentAsString();
|
||||
String msgContent = verifyResp(ver);
|
||||
List<VersionRsp> verList = objectMapper.readValue(msgContent, new TypeReference<List<VersionRsp>>() {
|
||||
});
|
||||
VersionListRsp versionListRsp = objectMapper.readValue(msgContent, VersionListRsp.class);
|
||||
List<VersionRsp> verList = versionListRsp.getItems();
|
||||
Assert.assertEquals(verList.size(), 1);
|
||||
for (VersionRsp versionRsp : verList
|
||||
) {
|
||||
|
@ -135,8 +137,10 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment{
|
|||
.getResponse()
|
||||
.getContentAsString();
|
||||
String msgContent = verifyResp(ver);
|
||||
List<VersionRsp> verList = objectMapper.readValue(msgContent, new TypeReference<List<VersionRsp>>() {
|
||||
});
|
||||
VersionListRsp versionListRsp = objectMapper.readValue(msgContent, VersionListRsp.class);
|
||||
List<VersionRsp> verList = versionListRsp.getItems();
|
||||
// List<VersionRsp> verList = objectMapper.readValue(msgContent, new TypeReference<List<VersionRsp>>() {
|
||||
// });
|
||||
Assert.assertTrue(verList.size() > 1);
|
||||
for (VersionRsp versionRsp : verList
|
||||
) {
|
||||
|
@ -174,8 +178,10 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment{
|
|||
.getResponse()
|
||||
.getContentAsString();
|
||||
String msgContent = verifyResp(ver);
|
||||
List<VersionRsp> verList = objectMapper.readValue(msgContent, new TypeReference<List<VersionRsp>>() {
|
||||
});
|
||||
VersionListRsp versionListRsp = objectMapper.readValue(msgContent, VersionListRsp.class);
|
||||
List<VersionRsp> verList = versionListRsp.getItems();
|
||||
// List<VersionRsp> verList = objectMapper.readValue(msgContent, new TypeReference<List<VersionRsp>>() {
|
||||
// });
|
||||
Assert.assertEquals(verList.size(), 1);
|
||||
for (VersionRsp versionRsp : verList
|
||||
) {
|
||||
|
@ -535,9 +541,10 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment{
|
|||
.getContentAsString();
|
||||
|
||||
String msgContent = verifyResp(linkstatus);
|
||||
|
||||
List<LinkStatusRsp> linkStatusList = objectMapper.readValue(msgContent, new TypeReference<List<LinkStatusRsp>>() {
|
||||
});
|
||||
LinkStatusListRsp linkStatusListRsp = objectMapper.readValue(msgContent, LinkStatusListRsp.class);
|
||||
List<LinkStatusRsp> linkStatusList = linkStatusListRsp.getItems();
|
||||
// List<LinkStatusRsp> linkStatusList = objectMapper.readValue(msgContent, new TypeReference<List<LinkStatusRsp>>() {
|
||||
// });
|
||||
|
||||
Assert.assertEquals(linkStatusList.size(), 1);
|
||||
for (LinkStatusRsp linkStatusRsp : linkStatusList
|
||||
|
@ -549,6 +556,7 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment{
|
|||
Assert.assertNotNull(String.valueOf(linkStatusRsp.getOnline()));
|
||||
Assert.assertEquals(String.valueOf(linkStatusRsp.getOnline()), "1");
|
||||
} else {
|
||||
Assert.assertNotNull(linkStatusRsp.getId());
|
||||
Assert.assertEquals(String.valueOf(linkStatusRsp.getStatus()), String.valueOf(ErrorCode.ERR_NOSUCHDEVICE.getCode()));
|
||||
Assert.assertEquals(linkStatusRsp.getMessage(), ErrorCode.ERR_NOSUCHDEVICE.getMsg());
|
||||
Assert.assertEquals(String.valueOf(linkStatusRsp.getOnline()), "0");
|
||||
|
@ -577,9 +585,10 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment{
|
|||
.getContentAsString();
|
||||
|
||||
String msgContent = verifyResp(linkstatus);
|
||||
|
||||
List<LinkStatusRsp> linkStatusList = objectMapper.readValue(msgContent, new TypeReference<List<LinkStatusRsp>>() {
|
||||
});
|
||||
LinkStatusListRsp linkStatusListRsp = objectMapper.readValue(msgContent, LinkStatusListRsp.class);
|
||||
List<LinkStatusRsp> linkStatusList = linkStatusListRsp.getItems();
|
||||
// List<LinkStatusRsp> linkStatusList = objectMapper.readValue(msgContent, new TypeReference<List<LinkStatusRsp>>() {
|
||||
// });
|
||||
|
||||
for (LinkStatusRsp linkStatusRsp : linkStatusList
|
||||
) {
|
||||
|
@ -590,6 +599,7 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment{
|
|||
Assert.assertNotNull(String.valueOf(linkStatusRsp.getOnline()));
|
||||
Assert.assertEquals(String.valueOf(linkStatusRsp.getOnline()), "1");
|
||||
} else {
|
||||
Assert.assertNotNull(linkStatusRsp.getId());
|
||||
Assert.assertEquals(String.valueOf(linkStatusRsp.getStatus()), String.valueOf(ErrorCode.ERR_NOSUCHDEVICE.getCode()));
|
||||
Assert.assertEquals(linkStatusRsp.getMessage(), ErrorCode.ERR_NOSUCHDEVICE.getMsg());
|
||||
Assert.assertEquals(String.valueOf(linkStatusRsp.getOnline()), "0");
|
||||
|
@ -619,12 +629,15 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment{
|
|||
|
||||
String msgContent = verifyResp(linkstatus);
|
||||
|
||||
List<LinkStatusRsp> linkStatusList = objectMapper.readValue(msgContent, new TypeReference<List<LinkStatusRsp>>() {
|
||||
});
|
||||
LinkStatusListRsp linkStatusListRsp = objectMapper.readValue(msgContent, LinkStatusListRsp.class);
|
||||
List<LinkStatusRsp> linkStatusList = linkStatusListRsp.getItems();
|
||||
// List<LinkStatusRsp> linkStatusList = objectMapper.readValue(msgContent, new TypeReference<List<LinkStatusRsp>>() {
|
||||
// });
|
||||
|
||||
Assert.assertEquals(linkStatusList.size(), 1);
|
||||
for (LinkStatusRsp linkStatusRsp : linkStatusList
|
||||
) {
|
||||
Assert.assertNotNull(linkStatusRsp.getId());
|
||||
Assert.assertEquals(String.valueOf(linkStatusRsp.getStatus()), String.valueOf(ErrorCode.ERR_NOSUCHDEVICE.getCode()));
|
||||
Assert.assertEquals(linkStatusRsp.getMessage(), ErrorCode.ERR_NOSUCHDEVICE.getMsg());
|
||||
Assert.assertEquals(String.valueOf(linkStatusRsp.getOnline()), "0");
|
||||
|
|
|
@ -14,9 +14,11 @@ import com.dispose.pojo.vo.information.DeviceInfoData;
|
|||
import com.dispose.pojo.vo.information.DeviceInfoRsp;
|
||||
import com.dispose.pojo.vo.information.DisposeNodeData;
|
||||
import com.dispose.pojo.vo.information.DisposeNodeListRsp;
|
||||
import com.dispose.pojo.vo.information.LinkStatusListRsp;
|
||||
import com.dispose.pojo.vo.information.LinkStatusRsp;
|
||||
import com.dispose.pojo.vo.information.NodeTaskData;
|
||||
import com.dispose.pojo.vo.information.NodeTaskRsp;
|
||||
import com.dispose.pojo.vo.information.VersionListRsp;
|
||||
import com.dispose.pojo.vo.information.VersionRsp;
|
||||
import com.dispose.service.DisposeNodeManager;
|
||||
import com.dispose.service.UserAccountService;
|
||||
|
@ -153,8 +155,10 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
|
|||
System.out.print("msgContent=" + msgContent);
|
||||
|
||||
//将json字符串转为VersionRsp类
|
||||
List<VersionRsp> verList = objectMapper.readValue(msgContent, new TypeReference<List<VersionRsp>>() {
|
||||
});
|
||||
// List<VersionRsp> verList = objectMapper.readValue(msgContent, new TypeReference<List<VersionRsp>>() {
|
||||
// });
|
||||
VersionListRsp versionListRsp = objectMapper.readValue(msgContent, VersionListRsp.class);
|
||||
List<VersionRsp> verList = versionListRsp.getItems();
|
||||
|
||||
for (VersionRsp versionRsp : verList
|
||||
) {
|
||||
|
@ -204,8 +208,10 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
|
|||
String msgContent = verifyRep(verAll, reqTimeStamp);
|
||||
System.out.print("msgContent=" + msgContent);
|
||||
|
||||
List<VersionRsp> verList = objectMapper.readValue(msgContent, new TypeReference<List<VersionRsp>>() {
|
||||
});
|
||||
// List<VersionRsp> verList = objectMapper.readValue(msgContent, new TypeReference<List<VersionRsp>>() {
|
||||
// });
|
||||
VersionListRsp versionListRsp = objectMapper.readValue(msgContent, VersionListRsp.class);
|
||||
List<VersionRsp> verList = versionListRsp.getItems();
|
||||
|
||||
for (VersionRsp versionRsp : verList
|
||||
) {
|
||||
|
@ -819,8 +825,10 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
|
|||
String msgContent = verifyRep(linkstatus, reqTimeStamp);
|
||||
System.out.print("msgContent=" + msgContent);
|
||||
|
||||
List<LinkStatusRsp> linkStatusList = objectMapper.readValue(msgContent, new TypeReference<List<LinkStatusRsp>>() {
|
||||
});
|
||||
// List<LinkStatusRsp> linkStatusList = objectMapper.readValue(msgContent, new TypeReference<List<LinkStatusRsp>>() {
|
||||
// });
|
||||
LinkStatusListRsp linkStatusListRsp = objectMapper.readValue(msgContent, LinkStatusListRsp.class);
|
||||
List<LinkStatusRsp> linkStatusList = linkStatusListRsp.getItems();
|
||||
|
||||
for (LinkStatusRsp linkStatusRsp : linkStatusList
|
||||
) {
|
||||
|
@ -866,8 +874,10 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
|
|||
String msgContent = verifyRep(linkStatusAll, reqTimeStamp);
|
||||
System.out.print("msgContent=" + msgContent);
|
||||
|
||||
List<LinkStatusRsp> linkStatusList = objectMapper.readValue(msgContent, new TypeReference<List<LinkStatusRsp>>() {
|
||||
});
|
||||
// List<LinkStatusRsp> linkStatusList = objectMapper.readValue(msgContent, new TypeReference<List<LinkStatusRsp>>() {
|
||||
// });
|
||||
LinkStatusListRsp linkStatusListRsp = objectMapper.readValue(msgContent, LinkStatusListRsp.class);
|
||||
List<LinkStatusRsp> linkStatusList = linkStatusListRsp.getItems();
|
||||
|
||||
for (LinkStatusRsp linkStatusRsp : linkStatusList
|
||||
) {
|
||||
|
|
Loading…
Reference in New Issue