OCT
REM: 1. 增加获取设备链接状态接口 2. 优化获取设备版本信息接口实现 3. 增加分页获取处置任务接口 4. 合并部分接口请求DTO定义 5. 优化代码风格
This commit is contained in:
parent
204de601db
commit
518b048fe6
|
@ -37,7 +37,7 @@ public class AuthConfigValue {
|
|||
/**
|
||||
* The constant TRUST_INFO_CACHE.
|
||||
*/
|
||||
public static volatile HashMap<String, Long> TRUST_INFO_CACHE = new HashMap<>();
|
||||
public static final HashMap<String, Long> TRUST_INFO_CACHE = new HashMap<>();
|
||||
|
||||
/**
|
||||
* The constant AUTH_CHECK.
|
||||
|
|
|
@ -12,7 +12,7 @@ public enum DisposeCapacityType implements BaseEnum {
|
|||
*/
|
||||
CLEANUP(0, "清洗能力"),
|
||||
/**
|
||||
* Blackhool dispose capacity type.
|
||||
* The Blackhool.
|
||||
*/
|
||||
BLACKHOOL(1, "压制能力"),
|
||||
/**
|
||||
|
@ -20,7 +20,7 @@ public enum DisposeCapacityType implements BaseEnum {
|
|||
*/
|
||||
HIDEPEND(2, "高防能力"),
|
||||
/**
|
||||
* The Detecive.
|
||||
* The Detective.
|
||||
*/
|
||||
DETECTIVE(3, "检测能力"),
|
||||
;
|
||||
|
|
|
@ -17,7 +17,7 @@ public enum DisposeTaskStatus implements BaseEnum {
|
|||
/**
|
||||
* The Task started.
|
||||
*/
|
||||
TASK_STARTED(2, "启动完成"),
|
||||
TASK_STARTED(2, "处置中"),
|
||||
/**
|
||||
* The Task finished.
|
||||
*/
|
||||
|
|
|
@ -81,6 +81,7 @@ public class Helper {
|
|||
public static String ipAddressNormalize(String ipAddr) {
|
||||
IPAddressString addrString = new IPAddressString(ipAddr);
|
||||
IPAddress addr = addrString.getAddress();
|
||||
final String cidrSplit = "/";
|
||||
|
||||
if (addr.isIPv6()) {
|
||||
return addr.toFullString().toUpperCase();
|
||||
|
@ -89,11 +90,11 @@ public class Helper {
|
|||
String ip;
|
||||
String mask = "";
|
||||
|
||||
if (!ipAddr.contains("/")) {
|
||||
if (!ipAddr.contains(cidrSplit)) {
|
||||
ip = ipAddr;
|
||||
} else {
|
||||
ip = ipAddr.substring(0, ipAddr.indexOf("/"));
|
||||
mask = ipAddr.substring(ipAddr.indexOf("/"));
|
||||
ip = ipAddr.substring(0, ipAddr.indexOf(cidrSplit));
|
||||
mask = ipAddr.substring(ipAddr.indexOf(cidrSplit));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -45,6 +45,11 @@ public class AuthConfigure implements WebMvcConfigurer {
|
|||
AuthConfigValue.VERIFY_REQUEST_TOKEN = Optional.ofNullable(verifyRequestToken).orElse(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Init auth interceptor token interceptor.
|
||||
*
|
||||
* @return the token interceptor
|
||||
*/
|
||||
@Bean
|
||||
public TokenInterceptor initAuthInterceptor(){
|
||||
return new TokenInterceptor();
|
||||
|
@ -60,5 +65,6 @@ public class AuthConfigure implements WebMvcConfigurer {
|
|||
// 注册需要检查token的控制器接口
|
||||
registry.addInterceptor(initAuthInterceptor()).addPathPatterns("/information/**");
|
||||
registry.addInterceptor(initAuthInterceptor()).addPathPatterns("/task/**");
|
||||
registry.addInterceptor(initAuthInterceptor()).addPathPatterns("/info/**");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,9 +18,9 @@ import com.dispose.pojo.dto.protocol.device.manager.AddCapacityInfo;
|
|||
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.DeviceInfoRsp;
|
||||
import com.dispose.pojo.dto.protocol.device.manager.GetDeviceDetail;
|
||||
import com.dispose.pojo.dto.protocol.device.manager.GetDeviceReq;
|
||||
import com.dispose.pojo.dto.protocol.device.manager.GetDeviceRsp;
|
||||
import com.dispose.pojo.entity.DisposeCapacity;
|
||||
import com.dispose.pojo.entity.DisposeDevice;
|
||||
|
@ -247,7 +247,7 @@ public class DisposeDeviceManagerController {
|
|||
@ApiOperation("获取处置能力节点")
|
||||
public ProtocolRespDTO<? extends BaseRespStatus> getAllDisposeDevice(
|
||||
@Validated(ValidGroups.ProtocolCommonValid.class)
|
||||
@RequestBody ProtocolReqDTO<GetDeviceReq> mr) {
|
||||
@RequestBody ProtocolReqDTO<BasePagesGetReq> mr) {
|
||||
|
||||
MulReturnType<PageInfo<DisposeDevice>, List<DisposeDevice>> ret =
|
||||
disposeDeviceManagerService.getPageDisposeDevice(mr.getMsgContent().getStartPage(),
|
||||
|
|
|
@ -8,9 +8,9 @@ import com.dispose.pojo.dto.protocol.base.IdArraysReq;
|
|||
import com.dispose.pojo.dto.protocol.base.ProtocolReqDTO;
|
||||
import com.dispose.pojo.dto.protocol.base.ProtocolRespDTO;
|
||||
import com.dispose.pojo.dto.protocol.device.info.AreaInfoDetail;
|
||||
import com.dispose.pojo.dto.protocol.device.info.DeviceVersionDetail;
|
||||
import com.dispose.pojo.dto.protocol.device.info.DeviceDetail;
|
||||
import com.dispose.pojo.dto.protocol.device.info.GetAreaInfoRsp;
|
||||
import com.dispose.pojo.dto.protocol.device.info.GetDeviceVerInfoRsp;
|
||||
import com.dispose.pojo.dto.protocol.device.info.GetDeviceInfoRsp;
|
||||
import com.dispose.pojo.dto.protocol.device.info.GetPlatformVerInfoRsp;
|
||||
import com.dispose.pojo.entity.DisposeDevice;
|
||||
import com.dispose.service.AreaCodeManagerService;
|
||||
|
@ -34,9 +34,9 @@ import org.springframework.web.bind.annotation.ResponseBody;
|
|||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
|
@ -113,9 +113,9 @@ public class DisposeInfoController {
|
|||
}
|
||||
|
||||
/**
|
||||
* Gets version info.
|
||||
* Gets platform version info.
|
||||
*
|
||||
* @return the version info
|
||||
* @return the platform version info
|
||||
*/
|
||||
@GetMapping("platformVersion")
|
||||
@ResponseBody
|
||||
|
@ -129,38 +129,34 @@ public class DisposeInfoController {
|
|||
return ProtocolRespDTO.result(ErrorCode.ERR_OK, rspInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets device version info.
|
||||
*
|
||||
* @param mr the mr
|
||||
* @return the device version info
|
||||
*/
|
||||
@PostMapping("deviceVersion")
|
||||
@ResponseBody
|
||||
@ApiOperation("获取设备版本信息")
|
||||
public ProtocolRespDTO<GetDeviceVerInfoRsp> getDeviceVersionInfo(
|
||||
public ProtocolRespDTO<GetDeviceInfoRsp> getDeviceVersionInfo(
|
||||
@Validated(ValidGroups.GetDevVerReqValid.class)
|
||||
@RequestBody ProtocolReqDTO<IdArraysReq> mr
|
||||
) {
|
||||
GetDeviceVerInfoRsp rspInfo = GetDeviceVerInfoRsp.builder()
|
||||
.items(new ArrayList<>())
|
||||
.build();
|
||||
List<Long> reqIds = Arrays.stream(mr.getMsgContent().getId()).map(Long::parseLong).collect(Collectors.toList());
|
||||
GetDeviceInfoRsp rspInfo = GetDeviceInfoRsp.builder().build();
|
||||
List<DeviceDetail> rspList = new ArrayList<>();
|
||||
|
||||
Map<Long, DisposeDevice> devMap = disposeDeviceManagerService.getAllDisposeDevice()
|
||||
.stream()
|
||||
.collect(Collectors.toMap(DisposeDevice::getId,
|
||||
Function.identity()));
|
||||
// 获取请求id列表
|
||||
List<Long> reqIds = Arrays.stream(mr.getMsgContent().getId()).map(Long::parseLong)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 获取所有可用设备
|
||||
List<DisposeDevice> disposeDevice = disposeDeviceManagerService.getAllDisposeDevice();
|
||||
|
||||
List<Long> allDevId = new ArrayList<>(devMap.keySet());
|
||||
|
||||
if (reqIds.size() == 0) {
|
||||
reqIds = allDevId;
|
||||
}
|
||||
|
||||
reqIds.stream().collect(Collectors.groupingBy(allDevId::contains))
|
||||
.forEach((k, v) -> v.forEach(m -> {
|
||||
DeviceVersionDetail dv = DeviceVersionDetail.builder().build();
|
||||
dv.setId(String.valueOf(m));
|
||||
|
||||
if (k) {
|
||||
DisposeDevice d = devMap.get(m);
|
||||
|
||||
// 获取设备版本信息
|
||||
disposeDevice.stream().filter(v -> reqIds.size() == 0 || reqIds.contains(v.getId()))
|
||||
.forEach(d -> {
|
||||
DeviceDetail dv = DeviceDetail.builder().build();
|
||||
dv.setId(String.valueOf(d.getId()));
|
||||
dv.setIpAddr(d.getIpAddr());
|
||||
dv.setIpPort(Helper.ipPortNormalize(d.getIpPort(), d.getUrlType()));
|
||||
dv.setVersion(disposeAbilityRouterService.getAbilityDevice(d.getId())
|
||||
|
@ -169,15 +165,82 @@ public class DisposeInfoController {
|
|||
|
||||
dv.setStatus(ErrorCode.ERR_OK.getCode());
|
||||
dv.setMessage(new String[]{ErrorCode.ERR_OK.getMsg()});
|
||||
} else {
|
||||
rspList.add(dv);
|
||||
});
|
||||
|
||||
// 设置不存在id的错误码
|
||||
reqIds.stream()
|
||||
.filter(v -> disposeDevice.stream().noneMatch(k -> k.getId().equals(v)))
|
||||
.forEach(v -> {
|
||||
DeviceDetail dv = DeviceDetail.builder().build();
|
||||
dv.setId(String.valueOf(v));
|
||||
dv.setStatus(ErrorCode.ERR_NOSUCHDEVICE.getCode());
|
||||
dv.setMessage(new String[]{ErrorCode.ERR_NOSUCHDEVICE.getMsg()});
|
||||
}
|
||||
rspList.add(dv);
|
||||
});
|
||||
|
||||
rspInfo.getItems().add(dv);
|
||||
}));
|
||||
// 对返回的信息按照设备ID排序
|
||||
rspInfo.setItems(rspList.stream()
|
||||
.sorted(Comparator.comparing(DeviceDetail::getId))
|
||||
.collect(Collectors.toList()));
|
||||
|
||||
return ProtocolRespDTO.result(ErrorCode.ERR_OK, rspInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets device link status info.
|
||||
*
|
||||
* @param mr the mr
|
||||
* @return the device link status info
|
||||
*/
|
||||
@PostMapping("deviceLinkStatus")
|
||||
@ResponseBody
|
||||
@ApiOperation("获取设备在线状态")
|
||||
public ProtocolRespDTO<GetDeviceInfoRsp> getDeviceLinkStatusInfo(
|
||||
@Validated(ValidGroups.GetDevVerReqValid.class)
|
||||
@RequestBody ProtocolReqDTO<IdArraysReq> mr
|
||||
) {
|
||||
GetDeviceInfoRsp rspInfo = GetDeviceInfoRsp.builder().build();
|
||||
List<DeviceDetail> rspList = new ArrayList<>();
|
||||
|
||||
// 获取请求id列表
|
||||
List<Long> reqIds = Arrays.stream(mr.getMsgContent().getId()).map(Long::parseLong)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 获取所有可用设备
|
||||
List<DisposeDevice> disposeDevice = disposeDeviceManagerService.getAllDisposeDevice();
|
||||
|
||||
// 获取设备版本信息
|
||||
disposeDevice.stream().filter(v -> reqIds.size() == 0 || reqIds.contains(v.getId()))
|
||||
.forEach(d -> {
|
||||
DeviceDetail dv = DeviceDetail.builder().build();
|
||||
dv.setId(String.valueOf(d.getId()));
|
||||
dv.setIpAddr(d.getIpAddr());
|
||||
dv.setIpPort(Helper.ipPortNormalize(d.getIpPort(), d.getUrlType()));
|
||||
dv.setOnline(disposeAbilityRouterService.getAbilityDevice(d.getId())
|
||||
.getDb()
|
||||
.getDeviceLinkStatus() ? 1 : 0);
|
||||
dv.setStatus(ErrorCode.ERR_OK.getCode());
|
||||
dv.setMessage(new String[]{ErrorCode.ERR_OK.getMsg()});
|
||||
rspList.add(dv);
|
||||
});
|
||||
|
||||
// 设置不存在id的错误码
|
||||
reqIds.stream()
|
||||
.filter(v -> disposeDevice.stream().noneMatch(k -> k.getId().equals(v)))
|
||||
.forEach(v -> {
|
||||
DeviceDetail dv = DeviceDetail.builder().build();
|
||||
dv.setId(String.valueOf(v));
|
||||
dv.setStatus(ErrorCode.ERR_NOSUCHDEVICE.getCode());
|
||||
dv.setMessage(new String[]{ErrorCode.ERR_NOSUCHDEVICE.getMsg()});
|
||||
rspList.add(dv);
|
||||
});
|
||||
|
||||
// 对返回的信息按照设备ID排序
|
||||
rspInfo.setItems(rspList.stream()
|
||||
.sorted(Comparator.comparing(DeviceDetail::getId))
|
||||
.collect(Collectors.toList()));
|
||||
|
||||
return ProtocolRespDTO.result(ErrorCode.ERR_OK, rspInfo);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,10 @@ import com.dispose.pojo.dto.protocol.base.BaseRespStatus;
|
|||
import com.dispose.pojo.dto.protocol.base.IdArraysReq;
|
||||
import com.dispose.pojo.dto.protocol.base.ProtocolReqDTO;
|
||||
import com.dispose.pojo.dto.protocol.base.ProtocolRespDTO;
|
||||
import com.dispose.pojo.dto.protocol.device.manager.BasePagesGetReq;
|
||||
import com.dispose.pojo.dto.protocol.task.GetDeviceTaskDetail;
|
||||
import com.dispose.pojo.dto.protocol.task.GetTaskDetail;
|
||||
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;
|
||||
|
@ -21,6 +25,7 @@ import com.dispose.pojo.po.MulReturnType;
|
|||
import com.dispose.service.DisposeTaskService;
|
||||
import com.dispose.service.UserAccountService;
|
||||
import com.dispose.validation.group.ValidGroups;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.security.annotation.Decryption;
|
||||
import com.security.annotation.Encryption;
|
||||
import io.swagger.annotations.Api;
|
||||
|
@ -88,12 +93,15 @@ public class DisposeTaskController {
|
|||
// 构造处置任务参数
|
||||
DisposeTask task = DisposeTask.builder()
|
||||
.deviceId(Long.parseLong(Optional.ofNullable(req.getId()).orElse("-1")))
|
||||
.accountId(userAccountService.getUserIdByAuthHead(Objects.requireNonNull(headers.get("Authorization")).get(0)))
|
||||
.disposeCapacity(CommonEnumHandler.codeOf(DisposeCapacityType.class, req.getType()))
|
||||
.accountId(userAccountService.getUserIdByAuthHead(Objects.requireNonNull(headers.get("Authorization"))
|
||||
.get(0)))
|
||||
.disposeCapacity(CommonEnumHandler.codeOf(DisposeCapacityType.class,
|
||||
req.getType()))
|
||||
.disposeIp(Helper.ipAddressNormalize(req.getDisposeIp()))
|
||||
.planEndTime(String.valueOf(req.getDisposeTime()))
|
||||
.flowDirection(CommonEnumHandler.codeOf(NetflowDirection.class,
|
||||
Optional.ofNullable(req.getFlowDirection()).orElse(2)))
|
||||
Optional.ofNullable(req.getFlowDirection())
|
||||
.orElse(2)))
|
||||
.attackType(DDoSAttackType.getTypeMaskFromAttackType(
|
||||
Optional.ofNullable(req.getAttackType())
|
||||
.orElse(new Integer[]{DDoSAttackType.ALL_ATTACKS.getValue()})))
|
||||
|
@ -126,6 +134,13 @@ public class DisposeTaskController {
|
|||
return ProtocolRespDTO.result(ret.getFirstParam(), rspInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* Start task mul ip protocol resp dto.
|
||||
*
|
||||
* @param mr the mr
|
||||
* @param headers the headers
|
||||
* @return the protocol resp dto
|
||||
*/
|
||||
@PostMapping("/startMulIp")
|
||||
@ResponseBody
|
||||
@ApiOperation("启动处置任务")
|
||||
|
@ -227,4 +242,65 @@ public class DisposeTaskController {
|
|||
|
||||
return ProtocolRespDTO.result(ErrorCode.ERR_OK, rspList);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all dispose task.
|
||||
*
|
||||
* @param mr the mr
|
||||
* @return the all dispose task
|
||||
*/
|
||||
@PostMapping("/taskList")
|
||||
@ResponseBody
|
||||
@ApiOperation("获取处置任务")
|
||||
public ProtocolRespDTO<? extends BaseRespStatus> getAllDisposeTask(
|
||||
@Validated(ValidGroups.ProtocolCommonValid.class)
|
||||
@RequestBody ProtocolReqDTO<BasePagesGetReq> mr
|
||||
) {
|
||||
GetTaskRsp rspInfo = new GetTaskRsp();
|
||||
|
||||
MulReturnType<PageInfo<DisposeTask>, List<DisposeTask>> ret =
|
||||
disposeTaskService.getPageDisposeTask(mr.getMsgContent().getStartPage(),
|
||||
mr.getMsgContent().getPageSize());
|
||||
|
||||
// 拼装返回数据
|
||||
rspInfo.setStatus(ErrorCode.ERR_OK.getCode());
|
||||
rspInfo.setMessage(new String[]{ErrorCode.ERR_OK.getMsg()});
|
||||
|
||||
// 分页信息
|
||||
rspInfo.setCurPageNumber(ret.getFirstParam().getPageNum());
|
||||
rspInfo.setPageSize(ret.getFirstParam().getPageSize());
|
||||
rspInfo.setTotalItems((int) ret.getFirstParam().getTotal());
|
||||
rspInfo.setTotalPages(ret.getFirstParam().getPages());
|
||||
|
||||
ret.getSecondParam().forEach(v -> {
|
||||
GetTaskDetail taskDetail = GetTaskDetail.builder()
|
||||
.taskId(String.valueOf(v.getId()))
|
||||
.accountId(String.valueOf(v.getAccountId()))
|
||||
.disposeCapacity(v.getDisposeCapacity().getValue())
|
||||
.disposeIp(v.getDisposeIp())
|
||||
.createTime(v.getCreateTime())
|
||||
.planEndTime(v.getPlanEndTime())
|
||||
.endTime(v.getEndTime())
|
||||
.flowDirection(v.getFlowDirection().getValue())
|
||||
.attackType(v.getAttackType().toString())
|
||||
.flowBandWidth(v.getFlowBandWidth())
|
||||
.currentStatus(v.getCurrentStatus().getValue())
|
||||
.deviceTask(new ArrayList<>())
|
||||
.build();
|
||||
v.getDeviceTask().forEach(k -> {
|
||||
GetDeviceTaskDetail deviceTaskDetail = GetDeviceTaskDetail.builder()
|
||||
.devTaskId(String.valueOf(k.getId()))
|
||||
.devId(String.valueOf(k.getDeviceId()))
|
||||
.externId(String.valueOf(k.getExternId()))
|
||||
.status(k.getStatus())
|
||||
.build();
|
||||
|
||||
taskDetail.getDeviceTask().add(deviceTaskDetail);
|
||||
});
|
||||
|
||||
rspInfo.getItems().add(taskDetail);
|
||||
});
|
||||
|
||||
return ProtocolRespDTO.result(ErrorCode.ERR_OK, rspInfo);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,8 @@ import com.dispose.common.DisposeCapacityType;
|
|||
import com.dispose.common.DisposeTaskStatus;
|
||||
import com.dispose.common.ErrorCode;
|
||||
import com.dispose.pojo.entity.DisposeTask;
|
||||
import com.dispose.pojo.po.MulReturnType;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -62,4 +64,13 @@ public interface DisposeTaskManager {
|
|||
*/
|
||||
DisposeTask getDisposeTaskById(Long taskId);
|
||||
|
||||
/**
|
||||
* Gets pages of task.
|
||||
*
|
||||
* @param startPage the start page
|
||||
* @param pageSize the page size
|
||||
* @return the pages of task
|
||||
*/
|
||||
MulReturnType<PageInfo<DisposeTask>, List<DisposeTask>> getPagesOfTask(Integer startPage,
|
||||
Integer pageSize);
|
||||
}
|
||||
|
|
|
@ -7,10 +7,14 @@ import com.dispose.manager.DisposeTaskManager;
|
|||
import com.dispose.mapper.DeviceTaskMapper;
|
||||
import com.dispose.mapper.DisposeTaskMapper;
|
||||
import com.dispose.pojo.entity.DisposeTask;
|
||||
import com.dispose.pojo.po.MulReturnType;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -103,4 +107,28 @@ public class DisposeTaskManagerImpl implements DisposeTaskManager {
|
|||
public DisposeTask getDisposeTaskById(Long taskId) {
|
||||
return disposeTaskMapper.getDisposeTaskById(taskId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets pages of task.
|
||||
*
|
||||
* @param startPage the start page
|
||||
* @param pageSize the page size
|
||||
* @return the pages of task
|
||||
*/
|
||||
@Override
|
||||
public MulReturnType<PageInfo<DisposeTask>, List<DisposeTask>> getPagesOfTask(Integer startPage,
|
||||
Integer pageSize) {
|
||||
// 设置分页信息
|
||||
PageHelper.startPage(startPage, pageSize);
|
||||
|
||||
List<DisposeTask> taskList = disposeTaskMapper.selectAll();
|
||||
|
||||
if(taskList == null) {
|
||||
taskList = new ArrayList<>();
|
||||
}
|
||||
|
||||
PageInfo<DisposeTask> pageInfo = new PageInfo<>(taskList);
|
||||
|
||||
return new MulReturnType<>(pageInfo, taskList);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ import lombok.EqualsAndHashCode;
|
|||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* The type Device version detail.
|
||||
* The type Device detail.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
|
@ -19,9 +19,9 @@ import lombok.NoArgsConstructor;
|
|||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@JsonPropertyOrder({"id", "ipAddr", "ipPort", "version", "status", "message"})
|
||||
@JsonPropertyOrder({"id", "ipAddr", "ipPort", "version", "online" ,"status", "message"})
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class DeviceVersionDetail extends BaseIdResp {
|
||||
public class DeviceDetail extends BaseIdResp {
|
||||
/**
|
||||
* The Ip addr.
|
||||
*/
|
||||
|
@ -34,4 +34,8 @@ public class DeviceVersionDetail extends BaseIdResp {
|
|||
* The Version.
|
||||
*/
|
||||
private String version;
|
||||
/**
|
||||
* The Online.
|
||||
*/
|
||||
private Integer online;
|
||||
}
|
|
@ -1,4 +0,0 @@
|
|||
package com.dispose.pojo.dto.protocol.device.info;
|
||||
|
||||
public class GetDevVerReq {
|
||||
}
|
|
@ -8,7 +8,7 @@ import lombok.Data;
|
|||
import java.util.List;
|
||||
|
||||
/**
|
||||
* The type Get device ver info rsp.
|
||||
* The type Get device info rsp.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
|
@ -16,9 +16,9 @@ import java.util.List;
|
|||
@Builder
|
||||
@AllArgsConstructor
|
||||
@JsonPropertyOrder({"items", "status", "message"})
|
||||
public class GetDeviceVerInfoRsp {
|
||||
public class GetDeviceInfoRsp {
|
||||
/**
|
||||
* The Device version.
|
||||
* The Items.
|
||||
*/
|
||||
private List<DeviceVersionDetail> items;
|
||||
private List<DeviceDetail> items;
|
||||
}
|
|
@ -21,7 +21,7 @@ import javax.validation.constraints.Positive;
|
|||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class GetDeviceReq {
|
||||
public class BasePagesGetReq {
|
||||
/**
|
||||
* The Start page.
|
||||
*/
|
|
@ -0,0 +1,38 @@
|
|||
package com.dispose.pojo.dto.protocol.task;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* The type Get device task detail.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@JsonPropertyOrder({"devTaskId", "devId", "externId", "status"})
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class GetDeviceTaskDetail {
|
||||
/**
|
||||
* The Dev task id.
|
||||
*/
|
||||
private String devTaskId;
|
||||
/**
|
||||
* The Dev id.
|
||||
*/
|
||||
private String devId;
|
||||
/**
|
||||
* The Extern id.
|
||||
*/
|
||||
private String externId;
|
||||
/**
|
||||
* The Status.
|
||||
*/
|
||||
private Long status;
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
package com.dispose.pojo.dto.protocol.task;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* The type Get task detail.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@JsonPropertyOrder({"taskId", "accountId", "disposeCapacity", "disposeIp", "createTime", "planEndTime", "endTime",
|
||||
"flowDirection", "attackType", "flowBandWidth", "currentStatus", "deviceTask"})
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class GetTaskDetail {
|
||||
|
||||
/**
|
||||
* The Task id.
|
||||
*/
|
||||
private String taskId;
|
||||
/**
|
||||
* The Account id.
|
||||
*/
|
||||
private String accountId;
|
||||
/**
|
||||
* The Dispose capacity.
|
||||
*/
|
||||
private Integer disposeCapacity;
|
||||
/**
|
||||
* The Dispose ip.
|
||||
*/
|
||||
private String disposeIp;
|
||||
/**
|
||||
* The Create time.
|
||||
*/
|
||||
private String createTime;
|
||||
/**
|
||||
* The Plan end time.
|
||||
*/
|
||||
private String planEndTime;
|
||||
/**
|
||||
* The End time.
|
||||
*/
|
||||
private String endTime;
|
||||
/**
|
||||
* The Flow direction.
|
||||
*/
|
||||
private Integer flowDirection;
|
||||
/**
|
||||
* The Attack type.
|
||||
*/
|
||||
private String attackType;
|
||||
/**
|
||||
* The Flow band width.
|
||||
*/
|
||||
private Integer flowBandWidth;
|
||||
/**
|
||||
* The Current status.
|
||||
*/
|
||||
private Integer currentStatus;
|
||||
/**
|
||||
* The Device task.
|
||||
*/
|
||||
private List<GetDeviceTaskDetail> deviceTask;
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
package com.dispose.pojo.dto.protocol.task;
|
||||
|
||||
import com.dispose.pojo.dto.protocol.base.BaseRespStatus;
|
||||
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 java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* The type Get task rsp.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@JsonPropertyOrder({"curPageNumber", "pageSize", "totalItems", "totalPages", "status", "message", "items"})
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class GetTaskRsp extends BaseRespStatus {
|
||||
|
||||
/**
|
||||
* The Cur page number.
|
||||
*/
|
||||
private Integer curPageNumber;
|
||||
/**
|
||||
* The Page size.
|
||||
*/
|
||||
private Integer pageSize;
|
||||
/**
|
||||
* The Total items.
|
||||
*/
|
||||
private Integer totalItems;
|
||||
/**
|
||||
* The Total pages.
|
||||
*/
|
||||
private Integer totalPages;
|
||||
|
||||
/**
|
||||
* The Items.
|
||||
*/
|
||||
private List<GetTaskDetail> items;
|
||||
|
||||
/**
|
||||
* Instantiates a new Get task rsp.
|
||||
*/
|
||||
public GetTaskRsp() {
|
||||
this.items = new ArrayList<>();
|
||||
}
|
||||
}
|
|
@ -8,7 +8,6 @@ import com.dispose.validation.valids.ValidArrayIpAddr;
|
|||
import com.dispose.validation.valids.ValidBaseEnum;
|
||||
import com.dispose.validation.valids.ValidBaseEnumArray;
|
||||
import com.dispose.validation.valids.ValidIpAddr;
|
||||
import com.dispose.validation.valids.ValidSplitPageSize;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
|
|
|
@ -43,7 +43,6 @@ public class DisposeTask implements Serializable {
|
|||
@Id
|
||||
@KeySql(useGeneratedKeys = true)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* The Device id.
|
||||
*/
|
||||
|
|
|
@ -3,6 +3,9 @@ package com.dispose.service;
|
|||
import com.dispose.common.ErrorCode;
|
||||
import com.dispose.pojo.entity.DisposeTask;
|
||||
import com.dispose.pojo.po.MulReturnType;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* The interface Dispose task service.
|
||||
|
@ -35,4 +38,13 @@ public interface DisposeTaskService {
|
|||
*/
|
||||
DisposeTask getDisposeTask(Long taskId);
|
||||
|
||||
/**
|
||||
* Gets page dispose task.
|
||||
*
|
||||
* @param startPage the start page
|
||||
* @param pageSize the page size
|
||||
* @return the page dispose task
|
||||
*/
|
||||
MulReturnType<PageInfo<DisposeTask>, List<DisposeTask>> getPageDisposeTask(Integer startPage,
|
||||
Integer pageSize);
|
||||
}
|
||||
|
|
|
@ -7,9 +7,11 @@ import com.dispose.pojo.entity.DisposeTask;
|
|||
import com.dispose.pojo.po.MulReturnType;
|
||||
import com.dispose.service.DisposeAbilityRouterService;
|
||||
import com.dispose.service.DisposeTaskService;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* The type Dispose task service.
|
||||
|
@ -24,6 +26,9 @@ public class DisposeTaskServiceImpl implements DisposeTaskService {
|
|||
@Resource
|
||||
DisposeTaskManager disposeTaskManager;
|
||||
|
||||
/**
|
||||
* The Dispose ability router service.
|
||||
*/
|
||||
@Resource
|
||||
DisposeAbilityRouterService disposeAbilityRouterService;
|
||||
|
||||
|
@ -90,4 +95,16 @@ public class DisposeTaskServiceImpl implements DisposeTaskService {
|
|||
return disposeTaskManager.getDisposeTaskById(taskId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets page dispose task.
|
||||
*
|
||||
* @param startPage the start page
|
||||
* @param pageSize the page size
|
||||
* @return the page dispose task
|
||||
*/
|
||||
@Override
|
||||
public MulReturnType<PageInfo<DisposeTask>, List<DisposeTask>> getPageDisposeTask(Integer startPage,
|
||||
Integer pageSize) {
|
||||
return disposeTaskManager.getPagesOfTask(startPage, pageSize);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,11 +10,21 @@ import java.lang.annotation.Retention;
|
|||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* The interface Valid ip port.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@Target({ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
@Constraint(validatedBy = {ValidIpPortImpl.class})
|
||||
public @interface ValidIpPort {
|
||||
/**
|
||||
* Message string.
|
||||
*
|
||||
* @return the string
|
||||
*/
|
||||
String message();
|
||||
|
||||
/**
|
||||
|
|
|
@ -10,11 +10,21 @@ import java.lang.annotation.Retention;
|
|||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* The interface Valid split page size.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@Target({ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
@Constraint(validatedBy = {ValidSplitPageSizeImpl.class})
|
||||
public @interface ValidSplitPageSize {
|
||||
/**
|
||||
* Message string.
|
||||
*
|
||||
* @return the string
|
||||
*/
|
||||
String message() default "";
|
||||
|
||||
/**
|
||||
|
|
|
@ -18,8 +18,8 @@ import com.dispose.pojo.dto.protocol.device.manager.AddDeviceInfo;
|
|||
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.DeviceInfoRsp;
|
||||
import com.dispose.pojo.dto.protocol.device.manager.GetDeviceReq;
|
||||
import com.dispose.pojo.dto.protocol.device.manager.GetDeviceRsp;
|
||||
import com.dispose.pojo.entity.DisposeDevice;
|
||||
import com.dispose.pojo.po.MulReturnType;
|
||||
|
@ -373,13 +373,13 @@ public class DisposeDeviceManagerControllerTest extends InitTestEnvironment {
|
|||
public void d1_getAllDisposeDevice() throws Exception {
|
||||
List<DisposeDevice> deviceList = disposeDeviceMapper.selectAll();
|
||||
|
||||
GetDeviceReq getReq = new GetDeviceReq();
|
||||
BasePagesGetReq getReq = new BasePagesGetReq();
|
||||
|
||||
for (int i = 1; i < 5; i++) {
|
||||
getReq.setStartPage(i);
|
||||
getReq.setPageSize(i * 10);
|
||||
|
||||
ProtocolReqDTO<GetDeviceReq> reqInfo = new ProtocolReqDTO<>();
|
||||
ProtocolReqDTO<BasePagesGetReq> reqInfo = new ProtocolReqDTO<>();
|
||||
|
||||
reqInfo.setVer(ConstValue.Protocol.VERSION);
|
||||
reqInfo.setCryptoType(ProtoCryptoType.CRYPTO_NONE.getCode());
|
||||
|
|
Loading…
Reference in New Issue