REM:
1. 修正某些协议直接返回匿名的JSON数组
This commit is contained in:
HuangXin 2020-09-10 20:01:46 +08:00
parent 3a915103d1
commit e65f0e6ca4
5 changed files with 54 additions and 10 deletions

View File

@ -10,6 +10,7 @@ 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;
@ -171,7 +172,7 @@ public class DisposeDeviceManagerController {
@DeleteMapping("/device")
@ResponseBody
@ApiOperation("删除处置能力节点")
public ProtocolRespDTO<List<DeviceInfoRsp>> removeDisposeDevice(
public ProtocolRespDTO<BaseListResp<DeviceInfoRsp>> removeDisposeDevice(
@Validated(ValidGroups.ExplicitIdArrayValid.class)
@RequestBody ProtocolReqDTO<IdArraysReq> mr) {
@ -185,7 +186,8 @@ public class DisposeDeviceManagerController {
List<MulReturnType<ErrorCode, DisposeDevice>> ret =
disposeDeviceManagerService.removeDisposeDevice(idList);
List<DeviceInfoRsp> rspInfo = new ArrayList<>();
BaseListResp<DeviceInfoRsp> rspInfo = new BaseListResp<>();
rspInfo.setItems(new ArrayList<>());
ret.forEach(v -> {
DeviceInfoRsp rsp = new DeviceInfoRsp();
@ -196,7 +198,7 @@ public class DisposeDeviceManagerController {
rsp.setStatus(v.getFirstParam().getCode());
rsp.setMessage(new String[]{v.getFirstParam().getMsg()});
rspInfo.add(rsp);
rspInfo.getItems().add(rsp);
});
return ProtocolRespDTO.result(ErrorCode.ERR_OK, rspInfo);
@ -211,7 +213,7 @@ public class DisposeDeviceManagerController {
@PostMapping("/upgrade")
@ResponseBody
@ApiOperation("更新处置能力节点")
public ProtocolRespDTO<List<DeviceInfoRsp>> upgradeDisposeDevice(
public ProtocolRespDTO<BaseListResp<DeviceInfoRsp>> upgradeDisposeDevice(
@Validated(ValidGroups.UpgradeDeviceValid.class)
@RequestBody ProtocolReqDTO<AddDeviceReq> mr) {
@ -221,7 +223,8 @@ public class DisposeDeviceManagerController {
// 更新设备信息
List<MulReturnType<ErrorCode, DisposeDevice>> ret = disposeDeviceManagerService.upgradeDisposeDevice(devs);
List<DeviceInfoRsp> rspInfo = new ArrayList<>();
BaseListResp<DeviceInfoRsp> rspInfo = new BaseListResp<>();
rspInfo.setItems(new ArrayList<>());
ret.forEach(v -> {
DeviceInfoRsp rsp = new DeviceInfoRsp();
@ -235,7 +238,7 @@ public class DisposeDeviceManagerController {
rsp.setStatus(v.getFirstParam().getCode());
rsp.setMessage(new String[]{v.getFirstParam().getMsg()});
rspInfo.add(rsp);
rspInfo.getItems().add(rsp);
});
return ProtocolRespDTO.result(ErrorCode.ERR_OK, rspInfo);

View File

@ -7,6 +7,7 @@ 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;
@ -213,9 +214,12 @@ public class DisposeTaskController {
@RequestBody ProtocolReqDTO<IdArraysReq> mr) {
// 记录多个任务停止信息
List<TaskStopRsp> rspList = new ArrayList<>();
BaseListResp<TaskStopRsp> rspList = new BaseListResp<>();
rspList.setItems(new ArrayList<>());
for (String tId : mr.getMsgContent().getTaskId()) {
// 停止处置任务
MulReturnType<ErrorCode, DisposeTask> ret = disposeTaskService.stopTask(Long.parseLong(tId));
@ -237,7 +241,7 @@ public class DisposeTaskController {
rspInfo.setStatus(ret.getFirstParam().getCode());
rspInfo.setMessage(new String[]{ret.getFirstParam().getMsg()});
rspList.add(rspInfo);
rspList.getItems().add(rspInfo);
}
return ProtocolRespDTO.result(ErrorCode.ERR_OK, rspList);

View File

@ -0,0 +1,31 @@
package com.dispose.pojo.dto.protocol.base;
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;
import java.util.List;
/**
* The type Base list resp.
*
* @param <T> the type parameter
* @author <huangxin@cmhi.chinamoblie.com>
*/
@EqualsAndHashCode(callSuper = true)
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@JsonPropertyOrder({"items", "status", "message"})
@JsonInclude(JsonInclude.Include.NON_NULL)
public class BaseListResp<T> extends BaseRespStatus {
/**
* The Items.
*/
private List<T> items;
}

View File

@ -1,9 +1,11 @@
package com.dispose.pojo.dto.protocol.device.info;
import com.dispose.pojo.dto.protocol.base.BaseRespStatus;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import java.util.List;
@ -13,12 +15,13 @@ import java.util.List;
*
* @author <huangxin@cmhi.chinamoblie.com>
*/
@EqualsAndHashCode(callSuper = true)
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@JsonPropertyOrder({"items", "status", "message"})
public class GetDeviceInfoRsp {
public class GetDeviceInfoRsp extends BaseRespStatus {
/**
* The Items.
*/

View File

@ -1,9 +1,11 @@
package com.dispose.pojo.dto.protocol.task;
import com.dispose.pojo.dto.protocol.base.BaseRespStatus;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import java.util.List;
@ -13,12 +15,13 @@ import java.util.List;
*
* @author <huangxin@cmhi.chinamoblie.com>
*/
@EqualsAndHashCode(callSuper = true)
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@JsonInclude(JsonInclude.Include.NON_NULL)
public class TaskStartMulRsp {
public class TaskStartMulRsp extends BaseRespStatus {
/**
* The Items.
*/