REM:
1. 修正某些协议直接返回匿名的JSON数组, 避免使用泛型类
This commit is contained in:
HuangXin 2020-09-10 20:58:49 +08:00
parent e65f0e6ca4
commit a17c589774
6 changed files with 68 additions and 40 deletions

View File

@ -10,7 +10,6 @@ import com.dispose.common.Helper;
import com.dispose.common.HttpType;
import com.dispose.common.IpAddrType;
import com.dispose.common.PrivacyHelper;
import com.dispose.pojo.dto.protocol.base.BaseListResp;
import com.dispose.pojo.dto.protocol.base.BaseRespStatus;
import com.dispose.pojo.dto.protocol.base.IdArraysReq;
import com.dispose.pojo.dto.protocol.base.ProtocolReqDTO;
@ -20,6 +19,7 @@ import com.dispose.pojo.dto.protocol.device.manager.AddDeviceReq;
import com.dispose.pojo.dto.protocol.device.manager.AddDeviceRet;
import com.dispose.pojo.dto.protocol.device.manager.AddDeviceRsp;
import com.dispose.pojo.dto.protocol.device.manager.BasePagesGetReq;
import com.dispose.pojo.dto.protocol.device.manager.CommDeviceListRsp;
import com.dispose.pojo.dto.protocol.device.manager.DeviceInfoRsp;
import com.dispose.pojo.dto.protocol.device.manager.GetDeviceDetail;
import com.dispose.pojo.dto.protocol.device.manager.GetDeviceRsp;
@ -129,7 +129,7 @@ public class DisposeDeviceManagerController {
@PutMapping("/device")
@ResponseBody
@ApiOperation("添加处置能力节点")
public ProtocolRespDTO<? extends AddDeviceRsp> addDisposeDevice(
public ProtocolRespDTO<AddDeviceRsp> addDisposeDevice(
@Validated(ValidGroups.AddDeviceValid.class)
@RequestBody ProtocolReqDTO<AddDeviceReq> mr) {
@ -172,7 +172,7 @@ public class DisposeDeviceManagerController {
@DeleteMapping("/device")
@ResponseBody
@ApiOperation("删除处置能力节点")
public ProtocolRespDTO<BaseListResp<DeviceInfoRsp>> removeDisposeDevice(
public ProtocolRespDTO<CommDeviceListRsp> removeDisposeDevice(
@Validated(ValidGroups.ExplicitIdArrayValid.class)
@RequestBody ProtocolReqDTO<IdArraysReq> mr) {
@ -186,7 +186,7 @@ public class DisposeDeviceManagerController {
List<MulReturnType<ErrorCode, DisposeDevice>> ret =
disposeDeviceManagerService.removeDisposeDevice(idList);
BaseListResp<DeviceInfoRsp> rspInfo = new BaseListResp<>();
CommDeviceListRsp rspInfo = new CommDeviceListRsp();
rspInfo.setItems(new ArrayList<>());
ret.forEach(v -> {
@ -194,7 +194,7 @@ public class DisposeDeviceManagerController {
DisposeDevice dev = v.getSecondParam();
rsp.setId(String.valueOf(dev.getId()));
rsp.setDevStatus(dev.getStatus());
rsp.setDevStatus(dev.getStatus().getValue());
rsp.setStatus(v.getFirstParam().getCode());
rsp.setMessage(new String[]{v.getFirstParam().getMsg()});
@ -213,7 +213,7 @@ public class DisposeDeviceManagerController {
@PostMapping("/upgrade")
@ResponseBody
@ApiOperation("更新处置能力节点")
public ProtocolRespDTO<BaseListResp<DeviceInfoRsp>> upgradeDisposeDevice(
public ProtocolRespDTO<CommDeviceListRsp> upgradeDisposeDevice(
@Validated(ValidGroups.UpgradeDeviceValid.class)
@RequestBody ProtocolReqDTO<AddDeviceReq> mr) {
@ -223,7 +223,7 @@ public class DisposeDeviceManagerController {
// 更新设备信息
List<MulReturnType<ErrorCode, DisposeDevice>> ret = disposeDeviceManagerService.upgradeDisposeDevice(devs);
BaseListResp<DeviceInfoRsp> rspInfo = new BaseListResp<>();
CommDeviceListRsp rspInfo = new CommDeviceListRsp();
rspInfo.setItems(new ArrayList<>());
ret.forEach(v -> {
@ -232,7 +232,7 @@ public class DisposeDeviceManagerController {
disposeDeviceManagerService.getAllDisposeDevice().parallelStream()
.filter(k -> k.getId().equals(dev.getId()))
.findAny().ifPresent(device -> rsp.setDevStatus(device.getStatus()));
.findAny().ifPresent(device -> rsp.setDevStatus(device.getStatus().getValue()));
rsp.setId(String.valueOf(dev.getId()));
rsp.setStatus(v.getFirstParam().getCode());

View File

@ -7,7 +7,6 @@ import com.dispose.common.DisposeConfigValue;
import com.dispose.common.ErrorCode;
import com.dispose.common.Helper;
import com.dispose.common.NetflowDirection;
import com.dispose.pojo.dto.protocol.base.BaseListResp;
import com.dispose.pojo.dto.protocol.base.BaseRespStatus;
import com.dispose.pojo.dto.protocol.base.IdArraysReq;
import com.dispose.pojo.dto.protocol.base.ProtocolReqDTO;
@ -19,6 +18,7 @@ import com.dispose.pojo.dto.protocol.task.GetTaskRsp;
import com.dispose.pojo.dto.protocol.task.TaskStartMulRsp;
import com.dispose.pojo.dto.protocol.task.TaskStartReq;
import com.dispose.pojo.dto.protocol.task.TaskStartRsp;
import com.dispose.pojo.dto.protocol.task.TaskStopItem;
import com.dispose.pojo.dto.protocol.task.TaskStopRsp;
import com.dispose.pojo.entity.DeviceTask;
import com.dispose.pojo.entity.DisposeTask;
@ -210,11 +210,11 @@ public class DisposeTaskController {
@PostMapping("/stop")
@ResponseBody
@ApiOperation("停止处置任务")
public ProtocolRespDTO<?> stopTask(@Validated(ValidGroups.TaskStopReqValid.class)
public ProtocolRespDTO<TaskStopRsp> stopTask(@Validated(ValidGroups.TaskStopReqValid.class)
@RequestBody ProtocolReqDTO<IdArraysReq> mr) {
// 记录多个任务停止信息
BaseListResp<TaskStopRsp> rspList = new BaseListResp<>();
TaskStopRsp rspList = new TaskStopRsp();
rspList.setItems(new ArrayList<>());
@ -223,7 +223,7 @@ public class DisposeTaskController {
// 停止处置任务
MulReturnType<ErrorCode, DisposeTask> ret = disposeTaskService.stopTask(Long.parseLong(tId));
TaskStopRsp rspInfo = TaskStopRsp.builder().build();
TaskStopItem rspInfo = TaskStopItem.builder().build();
// 停止成功
if (ret.getFirstParam() == ErrorCode.ERR_OK) {

View File

@ -1,5 +1,6 @@
package com.dispose.pojo.dto.protocol.base;
package com.dispose.pojo.dto.protocol.device.manager;
import com.dispose.pojo.dto.protocol.base.BaseRespStatus;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import lombok.AllArgsConstructor;
@ -11,9 +12,8 @@ import lombok.NoArgsConstructor;
import java.util.List;
/**
* The type Base list resp.
* The type Del device rsp.
*
* @param <T> the type parameter
* @author <huangxin@cmhi.chinamoblie.com>
*/
@EqualsAndHashCode(callSuper = true)
@ -23,9 +23,9 @@ import java.util.List;
@AllArgsConstructor
@JsonPropertyOrder({"items", "status", "message"})
@JsonInclude(JsonInclude.Include.NON_NULL)
public class BaseListResp<T> extends BaseRespStatus {
public class CommDeviceListRsp extends BaseRespStatus {
/**
* The Items.
*/
private List<T> items;
private List<DeviceInfoRsp> items;
}

View File

@ -1,6 +1,5 @@
package com.dispose.pojo.dto.protocol.device.manager;
import com.dispose.common.ObjectStatus;
import com.dispose.pojo.dto.protocol.base.BaseIdResp;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
@ -26,5 +25,5 @@ public class DeviceInfoRsp extends BaseIdResp {
/**
* The Dev status.
*/
private ObjectStatus devStatus;
private Integer devStatus;
}

View File

@ -0,0 +1,42 @@
package com.dispose.pojo.dto.protocol.task;
import com.dispose.pojo.dto.protocol.base.BaseIdResp;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
/**
* The type Task stop item.
*
* @author <huangxin@cmhi.chinamoblie.com>
*/
@EqualsAndHashCode(callSuper = true)
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@JsonPropertyOrder({"taskId", "disposeDevice", "type", "disposeIp", "leftTime", "status", "message"})
@JsonInclude(JsonInclude.Include.NON_NULL)
public class TaskStopItem extends BaseIdResp {
/**
* The Dispose device.
*/
private String[] disposeDevice;
/**
* The Type.
*/
private Integer type;
/**
* The Dispose ip.
*/
private String disposeIp;
/**
* The Left time.
*/
private String leftTime;
}

View File

@ -1,7 +1,6 @@
package com.dispose.pojo.dto.protocol.task;
import com.dispose.pojo.dto.protocol.base.BaseIdResp;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.dispose.pojo.dto.protocol.base.BaseRespStatus;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import lombok.AllArgsConstructor;
import lombok.Builder;
@ -9,8 +8,10 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import java.util.List;
/**
* The type Task stop resp.
* The type Task stop rsp.
*
* @author <huangxin@cmhi.chinamoblie.com>
*/
@ -19,24 +20,10 @@ import lombok.NoArgsConstructor;
@Builder
@NoArgsConstructor
@AllArgsConstructor
@JsonPropertyOrder({"taskId", "disposeDevice", "type", "disposeIp", "leftTime", "status", "message"})
@JsonInclude(JsonInclude.Include.NON_NULL)
public class TaskStopRsp extends BaseIdResp {
@JsonPropertyOrder({"items", "status", "message"})
public class TaskStopRsp extends BaseRespStatus {
/**
* The Dispose device.
* The Items.
*/
private String[] disposeDevice;
/**
* The Type.
*/
private Integer type;
/**
* The Dispose ip.
*/
private String disposeIp;
/**
* The Left time.
*/
private String leftTime;
private List<TaskStopItem> items;
}