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.
|
* 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.
|
* The constant AUTH_CHECK.
|
||||||
|
|
|
@ -12,7 +12,7 @@ public enum DisposeCapacityType implements BaseEnum {
|
||||||
*/
|
*/
|
||||||
CLEANUP(0, "清洗能力"),
|
CLEANUP(0, "清洗能力"),
|
||||||
/**
|
/**
|
||||||
* Blackhool dispose capacity type.
|
* The Blackhool.
|
||||||
*/
|
*/
|
||||||
BLACKHOOL(1, "压制能力"),
|
BLACKHOOL(1, "压制能力"),
|
||||||
/**
|
/**
|
||||||
|
@ -20,7 +20,7 @@ public enum DisposeCapacityType implements BaseEnum {
|
||||||
*/
|
*/
|
||||||
HIDEPEND(2, "高防能力"),
|
HIDEPEND(2, "高防能力"),
|
||||||
/**
|
/**
|
||||||
* The Detecive.
|
* The Detective.
|
||||||
*/
|
*/
|
||||||
DETECTIVE(3, "检测能力"),
|
DETECTIVE(3, "检测能力"),
|
||||||
;
|
;
|
||||||
|
|
|
@ -17,7 +17,7 @@ public enum DisposeTaskStatus implements BaseEnum {
|
||||||
/**
|
/**
|
||||||
* The Task started.
|
* The Task started.
|
||||||
*/
|
*/
|
||||||
TASK_STARTED(2, "启动完成"),
|
TASK_STARTED(2, "处置中"),
|
||||||
/**
|
/**
|
||||||
* The Task finished.
|
* The Task finished.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -81,6 +81,7 @@ public class Helper {
|
||||||
public static String ipAddressNormalize(String ipAddr) {
|
public static String ipAddressNormalize(String ipAddr) {
|
||||||
IPAddressString addrString = new IPAddressString(ipAddr);
|
IPAddressString addrString = new IPAddressString(ipAddr);
|
||||||
IPAddress addr = addrString.getAddress();
|
IPAddress addr = addrString.getAddress();
|
||||||
|
final String cidrSplit = "/";
|
||||||
|
|
||||||
if (addr.isIPv6()) {
|
if (addr.isIPv6()) {
|
||||||
return addr.toFullString().toUpperCase();
|
return addr.toFullString().toUpperCase();
|
||||||
|
@ -89,11 +90,11 @@ public class Helper {
|
||||||
String ip;
|
String ip;
|
||||||
String mask = "";
|
String mask = "";
|
||||||
|
|
||||||
if (!ipAddr.contains("/")) {
|
if (!ipAddr.contains(cidrSplit)) {
|
||||||
ip = ipAddr;
|
ip = ipAddr;
|
||||||
} else {
|
} else {
|
||||||
ip = ipAddr.substring(0, ipAddr.indexOf("/"));
|
ip = ipAddr.substring(0, ipAddr.indexOf(cidrSplit));
|
||||||
mask = ipAddr.substring(ipAddr.indexOf("/"));
|
mask = ipAddr.substring(ipAddr.indexOf(cidrSplit));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,11 @@ public class AuthConfigure implements WebMvcConfigurer {
|
||||||
AuthConfigValue.VERIFY_REQUEST_TOKEN = Optional.ofNullable(verifyRequestToken).orElse(true);
|
AuthConfigValue.VERIFY_REQUEST_TOKEN = Optional.ofNullable(verifyRequestToken).orElse(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Init auth interceptor token interceptor.
|
||||||
|
*
|
||||||
|
* @return the token interceptor
|
||||||
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
public TokenInterceptor initAuthInterceptor(){
|
public TokenInterceptor initAuthInterceptor(){
|
||||||
return new TokenInterceptor();
|
return new TokenInterceptor();
|
||||||
|
@ -60,5 +65,6 @@ public class AuthConfigure implements WebMvcConfigurer {
|
||||||
// 注册需要检查token的控制器接口
|
// 注册需要检查token的控制器接口
|
||||||
registry.addInterceptor(initAuthInterceptor()).addPathPatterns("/information/**");
|
registry.addInterceptor(initAuthInterceptor()).addPathPatterns("/information/**");
|
||||||
registry.addInterceptor(initAuthInterceptor()).addPathPatterns("/task/**");
|
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.AddDeviceReq;
|
||||||
import com.dispose.pojo.dto.protocol.device.manager.AddDeviceRet;
|
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.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.DeviceInfoRsp;
|
||||||
import com.dispose.pojo.dto.protocol.device.manager.GetDeviceDetail;
|
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.dto.protocol.device.manager.GetDeviceRsp;
|
||||||
import com.dispose.pojo.entity.DisposeCapacity;
|
import com.dispose.pojo.entity.DisposeCapacity;
|
||||||
import com.dispose.pojo.entity.DisposeDevice;
|
import com.dispose.pojo.entity.DisposeDevice;
|
||||||
|
@ -247,7 +247,7 @@ public class DisposeDeviceManagerController {
|
||||||
@ApiOperation("获取处置能力节点")
|
@ApiOperation("获取处置能力节点")
|
||||||
public ProtocolRespDTO<? extends BaseRespStatus> getAllDisposeDevice(
|
public ProtocolRespDTO<? extends BaseRespStatus> getAllDisposeDevice(
|
||||||
@Validated(ValidGroups.ProtocolCommonValid.class)
|
@Validated(ValidGroups.ProtocolCommonValid.class)
|
||||||
@RequestBody ProtocolReqDTO<GetDeviceReq> mr) {
|
@RequestBody ProtocolReqDTO<BasePagesGetReq> mr) {
|
||||||
|
|
||||||
MulReturnType<PageInfo<DisposeDevice>, List<DisposeDevice>> ret =
|
MulReturnType<PageInfo<DisposeDevice>, List<DisposeDevice>> ret =
|
||||||
disposeDeviceManagerService.getPageDisposeDevice(mr.getMsgContent().getStartPage(),
|
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.ProtocolReqDTO;
|
||||||
import com.dispose.pojo.dto.protocol.base.ProtocolRespDTO;
|
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.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.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.dto.protocol.device.info.GetPlatformVerInfoRsp;
|
||||||
import com.dispose.pojo.entity.DisposeDevice;
|
import com.dispose.pojo.entity.DisposeDevice;
|
||||||
import com.dispose.service.AreaCodeManagerService;
|
import com.dispose.service.AreaCodeManagerService;
|
||||||
|
@ -34,9 +34,9 @@ import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.function.Function;
|
|
||||||
import java.util.stream.Collectors;
|
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")
|
@GetMapping("platformVersion")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
|
@ -129,55 +129,118 @@ public class DisposeInfoController {
|
||||||
return ProtocolRespDTO.result(ErrorCode.ERR_OK, rspInfo);
|
return ProtocolRespDTO.result(ErrorCode.ERR_OK, rspInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets device version info.
|
||||||
|
*
|
||||||
|
* @param mr the mr
|
||||||
|
* @return the device version info
|
||||||
|
*/
|
||||||
@PostMapping("deviceVersion")
|
@PostMapping("deviceVersion")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@ApiOperation("获取设备版本信息")
|
@ApiOperation("获取设备版本信息")
|
||||||
public ProtocolRespDTO<GetDeviceVerInfoRsp> getDeviceVersionInfo(
|
public ProtocolRespDTO<GetDeviceInfoRsp> getDeviceVersionInfo(
|
||||||
@Validated(ValidGroups.GetDevVerReqValid.class)
|
@Validated(ValidGroups.GetDevVerReqValid.class)
|
||||||
@RequestBody ProtocolReqDTO<IdArraysReq> mr
|
@RequestBody ProtocolReqDTO<IdArraysReq> mr
|
||||||
) {
|
) {
|
||||||
GetDeviceVerInfoRsp rspInfo = GetDeviceVerInfoRsp.builder()
|
GetDeviceInfoRsp rspInfo = GetDeviceInfoRsp.builder().build();
|
||||||
.items(new ArrayList<>())
|
List<DeviceDetail> rspList = new ArrayList<>();
|
||||||
.build();
|
|
||||||
List<Long> reqIds = Arrays.stream(mr.getMsgContent().getId()).map(Long::parseLong).collect(Collectors.toList());
|
|
||||||
|
|
||||||
Map<Long, DisposeDevice> devMap = disposeDeviceManagerService.getAllDisposeDevice()
|
// 获取请求id列表
|
||||||
.stream()
|
List<Long> reqIds = Arrays.stream(mr.getMsgContent().getId()).map(Long::parseLong)
|
||||||
.collect(Collectors.toMap(DisposeDevice::getId,
|
.collect(Collectors.toList());
|
||||||
Function.identity()));
|
|
||||||
|
|
||||||
|
// 获取所有可用设备
|
||||||
|
List<DisposeDevice> disposeDevice = disposeDeviceManagerService.getAllDisposeDevice();
|
||||||
|
|
||||||
List<Long> allDevId = new ArrayList<>(devMap.keySet());
|
// 获取设备版本信息
|
||||||
|
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())
|
||||||
|
.getFirewareInfo()
|
||||||
|
.getVersion());
|
||||||
|
|
||||||
if (reqIds.size() == 0) {
|
dv.setStatus(ErrorCode.ERR_OK.getCode());
|
||||||
reqIds = allDevId;
|
dv.setMessage(new String[]{ErrorCode.ERR_OK.getMsg()});
|
||||||
}
|
rspList.add(dv);
|
||||||
|
});
|
||||||
|
|
||||||
reqIds.stream().collect(Collectors.groupingBy(allDevId::contains))
|
// 设置不存在id的错误码
|
||||||
.forEach((k, v) -> v.forEach(m -> {
|
reqIds.stream()
|
||||||
DeviceVersionDetail dv = DeviceVersionDetail.builder().build();
|
.filter(v -> disposeDevice.stream().noneMatch(k -> k.getId().equals(v)))
|
||||||
dv.setId(String.valueOf(m));
|
.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);
|
||||||
|
});
|
||||||
|
|
||||||
if (k) {
|
// 对返回的信息按照设备ID排序
|
||||||
DisposeDevice d = devMap.get(m);
|
rspInfo.setItems(rspList.stream()
|
||||||
|
.sorted(Comparator.comparing(DeviceDetail::getId))
|
||||||
dv.setIpAddr(d.getIpAddr());
|
.collect(Collectors.toList()));
|
||||||
dv.setIpPort(Helper.ipPortNormalize(d.getIpPort(), d.getUrlType()));
|
|
||||||
dv.setVersion(disposeAbilityRouterService.getAbilityDevice(d.getId())
|
|
||||||
.getFirewareInfo()
|
|
||||||
.getVersion());
|
|
||||||
|
|
||||||
dv.setStatus(ErrorCode.ERR_OK.getCode());
|
|
||||||
dv.setMessage(new String[]{ErrorCode.ERR_OK.getMsg()});
|
|
||||||
} else {
|
|
||||||
dv.setStatus(ErrorCode.ERR_NOSUCHDEVICE.getCode());
|
|
||||||
dv.setMessage(new String[]{ErrorCode.ERR_NOSUCHDEVICE.getMsg()});
|
|
||||||
}
|
|
||||||
|
|
||||||
rspInfo.getItems().add(dv);
|
|
||||||
}));
|
|
||||||
|
|
||||||
return ProtocolRespDTO.result(ErrorCode.ERR_OK, rspInfo);
|
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.IdArraysReq;
|
||||||
import com.dispose.pojo.dto.protocol.base.ProtocolReqDTO;
|
import com.dispose.pojo.dto.protocol.base.ProtocolReqDTO;
|
||||||
import com.dispose.pojo.dto.protocol.base.ProtocolRespDTO;
|
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.TaskStartMulRsp;
|
||||||
import com.dispose.pojo.dto.protocol.task.TaskStartReq;
|
import com.dispose.pojo.dto.protocol.task.TaskStartReq;
|
||||||
import com.dispose.pojo.dto.protocol.task.TaskStartRsp;
|
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.DisposeTaskService;
|
||||||
import com.dispose.service.UserAccountService;
|
import com.dispose.service.UserAccountService;
|
||||||
import com.dispose.validation.group.ValidGroups;
|
import com.dispose.validation.group.ValidGroups;
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
import com.security.annotation.Decryption;
|
import com.security.annotation.Decryption;
|
||||||
import com.security.annotation.Encryption;
|
import com.security.annotation.Encryption;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
|
@ -87,27 +92,30 @@ public class DisposeTaskController {
|
||||||
|
|
||||||
// 构造处置任务参数
|
// 构造处置任务参数
|
||||||
DisposeTask task = DisposeTask.builder()
|
DisposeTask task = DisposeTask.builder()
|
||||||
.deviceId(Long.parseLong(Optional.ofNullable(req.getId()).orElse("-1")))
|
.deviceId(Long.parseLong(Optional.ofNullable(req.getId()).orElse("-1")))
|
||||||
.accountId(userAccountService.getUserIdByAuthHead(Objects.requireNonNull(headers.get("Authorization")).get(0)))
|
.accountId(userAccountService.getUserIdByAuthHead(Objects.requireNonNull(headers.get("Authorization"))
|
||||||
.disposeCapacity(CommonEnumHandler.codeOf(DisposeCapacityType.class, req.getType()))
|
.get(0)))
|
||||||
.disposeIp(Helper.ipAddressNormalize(req.getDisposeIp()))
|
.disposeCapacity(CommonEnumHandler.codeOf(DisposeCapacityType.class,
|
||||||
.planEndTime(String.valueOf(req.getDisposeTime()))
|
req.getType()))
|
||||||
.flowDirection(CommonEnumHandler.codeOf(NetflowDirection.class,
|
.disposeIp(Helper.ipAddressNormalize(req.getDisposeIp()))
|
||||||
Optional.ofNullable(req.getFlowDirection()).orElse(2)))
|
.planEndTime(String.valueOf(req.getDisposeTime()))
|
||||||
.attackType(DDoSAttackType.getTypeMaskFromAttackType(
|
.flowDirection(CommonEnumHandler.codeOf(NetflowDirection.class,
|
||||||
Optional.ofNullable(req.getAttackType())
|
Optional.ofNullable(req.getFlowDirection())
|
||||||
.orElse(new Integer[]{DDoSAttackType.ALL_ATTACKS.getValue()})))
|
.orElse(2)))
|
||||||
.flowBandWidth(Optional.ofNullable(req.getFlowBandwidth())
|
.attackType(DDoSAttackType.getTypeMaskFromAttackType(
|
||||||
.orElse(DisposeConfigValue.DEFAULT_DISPOSE_BANDWIDTH))
|
Optional.ofNullable(req.getAttackType())
|
||||||
.build();
|
.orElse(new Integer[]{DDoSAttackType.ALL_ATTACKS.getValue()})))
|
||||||
|
.flowBandWidth(Optional.ofNullable(req.getFlowBandwidth())
|
||||||
|
.orElse(DisposeConfigValue.DEFAULT_DISPOSE_BANDWIDTH))
|
||||||
|
.build();
|
||||||
|
|
||||||
// 创建处置任务
|
// 创建处置任务
|
||||||
MulReturnType<ErrorCode, DisposeTask> ret = disposeTaskService.createTask(task);
|
MulReturnType<ErrorCode, DisposeTask> ret = disposeTaskService.createTask(task);
|
||||||
|
|
||||||
// 设置返回消息
|
// 设置返回消息
|
||||||
TaskStartRsp rspInfo = TaskStartRsp.builder()
|
TaskStartRsp rspInfo = TaskStartRsp.builder()
|
||||||
.disposeIp(task.getDisposeIp())
|
.disposeIp(task.getDisposeIp())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
rspInfo.setStatus(ret.getFirstParam().getCode());
|
rspInfo.setStatus(ret.getFirstParam().getCode());
|
||||||
rspInfo.setMessage(new String[]{ret.getFirstParam().getMsg()});
|
rspInfo.setMessage(new String[]{ret.getFirstParam().getMsg()});
|
||||||
|
@ -126,23 +134,30 @@ public class DisposeTaskController {
|
||||||
return ProtocolRespDTO.result(ret.getFirstParam(), rspInfo);
|
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")
|
@PostMapping("/startMulIp")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@ApiOperation("启动处置任务")
|
@ApiOperation("启动处置任务")
|
||||||
public ProtocolRespDTO<TaskStartMulRsp> startTaskMulIp(@Validated(ValidGroups.TaskStartMulReqValid.class)
|
public ProtocolRespDTO<TaskStartMulRsp> startTaskMulIp(@Validated(ValidGroups.TaskStartMulReqValid.class)
|
||||||
@RequestBody ProtocolReqDTO<TaskStartReq> mr,
|
@RequestBody ProtocolReqDTO<TaskStartReq> mr,
|
||||||
@NotNull @RequestHeader HttpHeaders headers) {
|
@NotNull @RequestHeader HttpHeaders headers) {
|
||||||
TaskStartReq req = mr.getMsgContent();
|
TaskStartReq req = mr.getMsgContent();
|
||||||
Long devId = Long.parseLong(Optional.ofNullable(req.getId()).orElse("-1"));
|
Long devId = Long.parseLong(Optional.ofNullable(req.getId()).orElse("-1"));
|
||||||
Long aId = userAccountService.getUserIdByAuthHead(Objects.requireNonNull(headers.get("Authorization")).get(0));
|
Long aId = userAccountService.getUserIdByAuthHead(Objects.requireNonNull(headers.get("Authorization")).get(0));
|
||||||
DisposeCapacityType capType = CommonEnumHandler.codeOf(DisposeCapacityType.class, req.getType());
|
DisposeCapacityType capType = CommonEnumHandler.codeOf(DisposeCapacityType.class, req.getType());
|
||||||
String endTime = String.valueOf(req.getDisposeTime());
|
String endTime = String.valueOf(req.getDisposeTime());
|
||||||
NetflowDirection netDir = CommonEnumHandler.codeOf(NetflowDirection.class,
|
NetflowDirection netDir = CommonEnumHandler.codeOf(NetflowDirection.class,
|
||||||
Optional.ofNullable(req.getFlowDirection()).orElse(2));
|
Optional.ofNullable(req.getFlowDirection()).orElse(2));
|
||||||
Long attackType = DDoSAttackType.getTypeMaskFromAttackType(Optional.ofNullable(req.getAttackType())
|
Long attackType = DDoSAttackType.getTypeMaskFromAttackType(Optional.ofNullable(req.getAttackType())
|
||||||
.orElse(new Integer[]{DDoSAttackType.ALL_ATTACKS.getValue()}));
|
.orElse(new Integer[]{DDoSAttackType.ALL_ATTACKS.getValue()}));
|
||||||
Integer flowBand = Optional.ofNullable(req.getFlowBandwidth())
|
Integer flowBand = Optional.ofNullable(req.getFlowBandwidth())
|
||||||
.orElse(DisposeConfigValue.DEFAULT_DISPOSE_BANDWIDTH);
|
.orElse(DisposeConfigValue.DEFAULT_DISPOSE_BANDWIDTH);
|
||||||
|
|
||||||
TaskStartMulRsp mulRsp = TaskStartMulRsp.builder()
|
TaskStartMulRsp mulRsp = TaskStartMulRsp.builder()
|
||||||
.items(new ArrayList<>())
|
.items(new ArrayList<>())
|
||||||
|
@ -151,23 +166,23 @@ public class DisposeTaskController {
|
||||||
for (String ip : req.getMulDisposeIp()) {
|
for (String ip : req.getMulDisposeIp()) {
|
||||||
// 构造处置任务参数
|
// 构造处置任务参数
|
||||||
DisposeTask task = DisposeTask.builder()
|
DisposeTask task = DisposeTask.builder()
|
||||||
.deviceId(devId)
|
.deviceId(devId)
|
||||||
.accountId(aId)
|
.accountId(aId)
|
||||||
.disposeCapacity(capType)
|
.disposeCapacity(capType)
|
||||||
.disposeIp(Helper.ipAddressNormalize(ip))
|
.disposeIp(Helper.ipAddressNormalize(ip))
|
||||||
.planEndTime(endTime)
|
.planEndTime(endTime)
|
||||||
.flowDirection(netDir)
|
.flowDirection(netDir)
|
||||||
.attackType(attackType)
|
.attackType(attackType)
|
||||||
.flowBandWidth(flowBand)
|
.flowBandWidth(flowBand)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
// 创建处置任务
|
// 创建处置任务
|
||||||
MulReturnType<ErrorCode, DisposeTask> ret = disposeTaskService.createTask(task);
|
MulReturnType<ErrorCode, DisposeTask> ret = disposeTaskService.createTask(task);
|
||||||
|
|
||||||
// 设置返回消息
|
// 设置返回消息
|
||||||
TaskStartRsp rspInfo = TaskStartRsp.builder()
|
TaskStartRsp rspInfo = TaskStartRsp.builder()
|
||||||
.disposeIp(ip)
|
.disposeIp(ip)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
// 启动任务成功
|
// 启动任务成功
|
||||||
if (ret.getFirstParam() == ErrorCode.ERR_OK ||
|
if (ret.getFirstParam() == ErrorCode.ERR_OK ||
|
||||||
|
@ -209,9 +224,9 @@ public class DisposeTaskController {
|
||||||
// 停止成功
|
// 停止成功
|
||||||
if (ret.getFirstParam() == ErrorCode.ERR_OK) {
|
if (ret.getFirstParam() == ErrorCode.ERR_OK) {
|
||||||
rspInfo.setDisposeDevice(ret.getSecondParam().getDeviceTask().stream()
|
rspInfo.setDisposeDevice(ret.getSecondParam().getDeviceTask().stream()
|
||||||
.map(DeviceTask::getDeviceId)
|
.map(DeviceTask::getDeviceId)
|
||||||
.map(String::valueOf)
|
.map(String::valueOf)
|
||||||
.toArray(String[]::new));
|
.toArray(String[]::new));
|
||||||
rspInfo.setType(ret.getSecondParam().getDisposeCapacity().getValue());
|
rspInfo.setType(ret.getSecondParam().getDisposeCapacity().getValue());
|
||||||
rspInfo.setDisposeIp(ret.getSecondParam().getDisposeIp());
|
rspInfo.setDisposeIp(ret.getSecondParam().getDisposeIp());
|
||||||
rspInfo.setLeftTime(String.valueOf(Math.abs(
|
rspInfo.setLeftTime(String.valueOf(Math.abs(
|
||||||
|
@ -227,4 +242,65 @@ public class DisposeTaskController {
|
||||||
|
|
||||||
return ProtocolRespDTO.result(ErrorCode.ERR_OK, rspList);
|
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.DisposeTaskStatus;
|
||||||
import com.dispose.common.ErrorCode;
|
import com.dispose.common.ErrorCode;
|
||||||
import com.dispose.pojo.entity.DisposeTask;
|
import com.dispose.pojo.entity.DisposeTask;
|
||||||
|
import com.dispose.pojo.po.MulReturnType;
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -62,4 +64,13 @@ public interface DisposeTaskManager {
|
||||||
*/
|
*/
|
||||||
DisposeTask getDisposeTaskById(Long taskId);
|
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.DeviceTaskMapper;
|
||||||
import com.dispose.mapper.DisposeTaskMapper;
|
import com.dispose.mapper.DisposeTaskMapper;
|
||||||
import com.dispose.pojo.entity.DisposeTask;
|
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 lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -103,4 +107,28 @@ public class DisposeTaskManagerImpl implements DisposeTaskManager {
|
||||||
public DisposeTask getDisposeTaskById(Long taskId) {
|
public DisposeTask getDisposeTaskById(Long taskId) {
|
||||||
return disposeTaskMapper.getDisposeTaskById(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;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The type Device version detail.
|
* The type Device detail.
|
||||||
*
|
*
|
||||||
* @author <huangxin@cmhi.chinamoblie.com>
|
* @author <huangxin@cmhi.chinamoblie.com>
|
||||||
*/
|
*/
|
||||||
|
@ -19,9 +19,9 @@ import lombok.NoArgsConstructor;
|
||||||
@Builder
|
@Builder
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@JsonPropertyOrder({"id", "ipAddr", "ipPort", "version", "status", "message"})
|
@JsonPropertyOrder({"id", "ipAddr", "ipPort", "version", "online" ,"status", "message"})
|
||||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
public class DeviceVersionDetail extends BaseIdResp {
|
public class DeviceDetail extends BaseIdResp {
|
||||||
/**
|
/**
|
||||||
* The Ip addr.
|
* The Ip addr.
|
||||||
*/
|
*/
|
||||||
|
@ -34,4 +34,8 @@ public class DeviceVersionDetail extends BaseIdResp {
|
||||||
* The Version.
|
* The Version.
|
||||||
*/
|
*/
|
||||||
private String 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;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The type Get device ver info rsp.
|
* The type Get device info rsp.
|
||||||
*
|
*
|
||||||
* @author <huangxin@cmhi.chinamoblie.com>
|
* @author <huangxin@cmhi.chinamoblie.com>
|
||||||
*/
|
*/
|
||||||
|
@ -16,9 +16,9 @@ import java.util.List;
|
||||||
@Builder
|
@Builder
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@JsonPropertyOrder({"items", "status", "message"})
|
@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
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
public class GetDeviceReq {
|
public class BasePagesGetReq {
|
||||||
/**
|
/**
|
||||||
* The Start page.
|
* 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.ValidBaseEnum;
|
||||||
import com.dispose.validation.valids.ValidBaseEnumArray;
|
import com.dispose.validation.valids.ValidBaseEnumArray;
|
||||||
import com.dispose.validation.valids.ValidIpAddr;
|
import com.dispose.validation.valids.ValidIpAddr;
|
||||||
import com.dispose.validation.valids.ValidSplitPageSize;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
|
|
|
@ -43,7 +43,6 @@ public class DisposeTask implements Serializable {
|
||||||
@Id
|
@Id
|
||||||
@KeySql(useGeneratedKeys = true)
|
@KeySql(useGeneratedKeys = true)
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Device id.
|
* The Device id.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -3,6 +3,9 @@ package com.dispose.service;
|
||||||
import com.dispose.common.ErrorCode;
|
import com.dispose.common.ErrorCode;
|
||||||
import com.dispose.pojo.entity.DisposeTask;
|
import com.dispose.pojo.entity.DisposeTask;
|
||||||
import com.dispose.pojo.po.MulReturnType;
|
import com.dispose.pojo.po.MulReturnType;
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The interface Dispose task service.
|
* The interface Dispose task service.
|
||||||
|
@ -35,4 +38,13 @@ public interface DisposeTaskService {
|
||||||
*/
|
*/
|
||||||
DisposeTask getDisposeTask(Long taskId);
|
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.pojo.po.MulReturnType;
|
||||||
import com.dispose.service.DisposeAbilityRouterService;
|
import com.dispose.service.DisposeAbilityRouterService;
|
||||||
import com.dispose.service.DisposeTaskService;
|
import com.dispose.service.DisposeTaskService;
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The type Dispose task service.
|
* The type Dispose task service.
|
||||||
|
@ -24,6 +26,9 @@ public class DisposeTaskServiceImpl implements DisposeTaskService {
|
||||||
@Resource
|
@Resource
|
||||||
DisposeTaskManager disposeTaskManager;
|
DisposeTaskManager disposeTaskManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Dispose ability router service.
|
||||||
|
*/
|
||||||
@Resource
|
@Resource
|
||||||
DisposeAbilityRouterService disposeAbilityRouterService;
|
DisposeAbilityRouterService disposeAbilityRouterService;
|
||||||
|
|
||||||
|
@ -90,4 +95,16 @@ public class DisposeTaskServiceImpl implements DisposeTaskService {
|
||||||
return disposeTaskManager.getDisposeTaskById(taskId);
|
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.RetentionPolicy;
|
||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The interface Valid ip port.
|
||||||
|
*
|
||||||
|
* @author <huangxin@cmhi.chinamoblie.com>
|
||||||
|
*/
|
||||||
@Target({ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER})
|
@Target({ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER})
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Documented
|
@Documented
|
||||||
@Constraint(validatedBy = {ValidIpPortImpl.class})
|
@Constraint(validatedBy = {ValidIpPortImpl.class})
|
||||||
public @interface ValidIpPort {
|
public @interface ValidIpPort {
|
||||||
|
/**
|
||||||
|
* Message string.
|
||||||
|
*
|
||||||
|
* @return the string
|
||||||
|
*/
|
||||||
String message();
|
String message();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -10,11 +10,21 @@ import java.lang.annotation.Retention;
|
||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The interface Valid split page size.
|
||||||
|
*
|
||||||
|
* @author <huangxin@cmhi.chinamoblie.com>
|
||||||
|
*/
|
||||||
@Target({ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER})
|
@Target({ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER})
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Documented
|
@Documented
|
||||||
@Constraint(validatedBy = {ValidSplitPageSizeImpl.class})
|
@Constraint(validatedBy = {ValidSplitPageSizeImpl.class})
|
||||||
public @interface ValidSplitPageSize {
|
public @interface ValidSplitPageSize {
|
||||||
|
/**
|
||||||
|
* Message string.
|
||||||
|
*
|
||||||
|
* @return the string
|
||||||
|
*/
|
||||||
String message() default "";
|
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.AddDeviceReq;
|
||||||
import com.dispose.pojo.dto.protocol.device.manager.AddDeviceRet;
|
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.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.DeviceInfoRsp;
|
||||||
import com.dispose.pojo.dto.protocol.device.manager.GetDeviceReq;
|
|
||||||
import com.dispose.pojo.dto.protocol.device.manager.GetDeviceRsp;
|
import com.dispose.pojo.dto.protocol.device.manager.GetDeviceRsp;
|
||||||
import com.dispose.pojo.entity.DisposeDevice;
|
import com.dispose.pojo.entity.DisposeDevice;
|
||||||
import com.dispose.pojo.po.MulReturnType;
|
import com.dispose.pojo.po.MulReturnType;
|
||||||
|
@ -373,13 +373,13 @@ public class DisposeDeviceManagerControllerTest extends InitTestEnvironment {
|
||||||
public void d1_getAllDisposeDevice() throws Exception {
|
public void d1_getAllDisposeDevice() throws Exception {
|
||||||
List<DisposeDevice> deviceList = disposeDeviceMapper.selectAll();
|
List<DisposeDevice> deviceList = disposeDeviceMapper.selectAll();
|
||||||
|
|
||||||
GetDeviceReq getReq = new GetDeviceReq();
|
BasePagesGetReq getReq = new BasePagesGetReq();
|
||||||
|
|
||||||
for (int i = 1; i < 5; i++) {
|
for (int i = 1; i < 5; i++) {
|
||||||
getReq.setStartPage(i);
|
getReq.setStartPage(i);
|
||||||
getReq.setPageSize(i * 10);
|
getReq.setPageSize(i * 10);
|
||||||
|
|
||||||
ProtocolReqDTO<GetDeviceReq> reqInfo = new ProtocolReqDTO<>();
|
ProtocolReqDTO<BasePagesGetReq> reqInfo = new ProtocolReqDTO<>();
|
||||||
|
|
||||||
reqInfo.setVer(ConstValue.Protocol.VERSION);
|
reqInfo.setVer(ConstValue.Protocol.VERSION);
|
||||||
reqInfo.setCryptoType(ProtoCryptoType.CRYPTO_NONE.getCode());
|
reqInfo.setCryptoType(ProtoCryptoType.CRYPTO_NONE.getCode());
|
||||||
|
|
Loading…
Reference in New Issue