OCT
REM: 1. 增加分页数据大小控制配置项 2. 增加获取设备节点信息接口 3. 更新设备能力数据库,支持保存设备清洗储备能力 4. 更新设备管理接口,支持设备清理能力字段 5. 增加设备节点管理服务 6. 增加分页参数校验器 7. 更新启动多IP清洗任务返回值,避免使用匿名JSON字段 8. 处置设备管理增加获取所有可用设备功能 9. 修正ERR_UNTRUSTTOKEN重复的错误码 10. 更新部分校验器返回错误消息格式
This commit is contained in:
parent
1404e286f1
commit
d899cb5da3
|
@ -5,6 +5,8 @@ dispose.split_char=,
|
|||
dispose.request-timeout-second=5
|
||||
dispose.used-privacy-protect=true
|
||||
dispose.call-error-retry-times=3
|
||||
dispose.max-split-page-size=100
|
||||
dispose.min-split-page-size=10
|
||||
|
||||
# 迪普设备配置
|
||||
# 发送超时时间(s)
|
||||
|
|
|
@ -25,12 +25,25 @@ public class DisposeConfigValue {
|
|||
/**
|
||||
* The constant CALL_ERROR_RETRY_TIMES.
|
||||
*/
|
||||
public static volatile int CALL_ERROR_RETRY_TIMES=5;
|
||||
public static volatile int CALL_ERROR_RETRY_TIMES = 5;
|
||||
|
||||
/**
|
||||
* The constant DEFAULT_DISPOSE_BANDWIDTH.
|
||||
*/
|
||||
public static volatile int DEFAULT_DISPOSE_BANDWIDTH=1024;
|
||||
public static volatile int DEFAULT_DISPOSE_BANDWIDTH = 1024;
|
||||
|
||||
public static volatile String SPLIT_CHAR=",";
|
||||
/**
|
||||
* The constant SPLIT_CHAR.
|
||||
*/
|
||||
public static volatile String SPLIT_CHAR = ",";
|
||||
|
||||
/**
|
||||
* The constant MAX_SPLIT_PAGE_SIZE.
|
||||
*/
|
||||
public static volatile int MAX_SPLIT_PAGE_SIZE = 100;
|
||||
|
||||
/**
|
||||
* The constant MIN_SPLIT_PAGE_SIZE.
|
||||
*/
|
||||
public static volatile int MIN_SPLIT_PAGE_SIZE = 10;
|
||||
}
|
||||
|
|
|
@ -7,214 +7,200 @@ package com.dispose.common;
|
|||
*/
|
||||
public enum ErrorCode {
|
||||
/**
|
||||
* The Err ok.
|
||||
* Err ok error code.
|
||||
*/
|
||||
ERR_OK(0, "成功"),
|
||||
/**
|
||||
* The Err password.
|
||||
* Err password error code.
|
||||
*/
|
||||
ERR_PASSWORD(1, "密码错误"),
|
||||
/**
|
||||
* The Err usernotfound.
|
||||
* Err usernotfound error code.
|
||||
*/
|
||||
ERR_USERNOTFOUND(2, "用户不存在"),
|
||||
/**
|
||||
* The Err passwordmore.
|
||||
* Err passwordmore error code.
|
||||
*/
|
||||
ERR_PASSWORDMORE(3, "连续密码错误达上限,再次输入错误将锁定用户"),
|
||||
/**
|
||||
* The Err userlock.
|
||||
* Err userlock error code.
|
||||
*/
|
||||
ERR_USERLOCK(4, "密码错误达上限,用户被锁定"),
|
||||
/**
|
||||
* The Err account.
|
||||
* Err account error code.
|
||||
*/
|
||||
ERR_ACCOUNT(5, "用户账户异常"),
|
||||
/**
|
||||
* The Err userexist.
|
||||
* Err userexist error code.
|
||||
*/
|
||||
ERR_USEREXIST(6, "该用户已经存在"),
|
||||
/**
|
||||
* The Err passwordsimple.
|
||||
* Err passwordsimple error code.
|
||||
*/
|
||||
ERR_PASSWORDSIMPLE(7, "用户密码强度不符合要求"),
|
||||
/**
|
||||
* The Err inputformat.
|
||||
* Err inputformat error code.
|
||||
*/
|
||||
ERR_INPUTFORMAT(8, "输入信息格式有误"),
|
||||
/**
|
||||
* The Err inputmiss.
|
||||
* Err inputmiss error code.
|
||||
*/
|
||||
ERR_INPUTMISS(9, "缺少必要输入信息"),
|
||||
/**
|
||||
* The Err permission.
|
||||
* Err permission error code.
|
||||
*/
|
||||
ERR_PERMISSION(10, "操作员权限不足"),
|
||||
/**
|
||||
* The Err reqtimeout.
|
||||
* Err reqtimeout error code.
|
||||
*/
|
||||
ERR_REQTIMEOUT(11, "请求超时"),
|
||||
/**
|
||||
* The Err params.
|
||||
* Err params error code.
|
||||
*/
|
||||
ERR_PARAMS(12, "参数错误"),
|
||||
/**
|
||||
* The Err systemexception.
|
||||
* Err systemexception error code.
|
||||
*/
|
||||
ERR_SYSTEMEXCEPTION(13, "系统异常"),
|
||||
/**
|
||||
* The Err unknowncmd.
|
||||
* Err unknowncmd error code.
|
||||
*/
|
||||
ERR_UNKNOWNCMD(14, "未知命令"),
|
||||
/**
|
||||
* The Err logout.
|
||||
* Err logout error code.
|
||||
*/
|
||||
ERR_LOGOUT(15, "用户未登录"),
|
||||
/**
|
||||
* The Err tokentimeout.
|
||||
* Err tokentimeout error code.
|
||||
*/
|
||||
ERR_TOKENTIMEOUT(16, "Token超时"),
|
||||
/**
|
||||
* The Err tokennotfound.
|
||||
* Err tokennotfound error code.
|
||||
*/
|
||||
ERR_TOKENNOTFOUND(17, "非法Token"),
|
||||
/**
|
||||
* The Err missauthhead.
|
||||
* Err missauthhead error code.
|
||||
*/
|
||||
ERR_MISSAUTHHEAD(18, "Http 请求缺少认证头部"),
|
||||
/**
|
||||
* The Err nosuchdevice.
|
||||
* Err nosuchdevice error code.
|
||||
*/
|
||||
ERR_NOSUCHDEVICE(19, "没有这个设备"),
|
||||
/**
|
||||
* The Err deviceexists.
|
||||
* Err deviceexists error code.
|
||||
*/
|
||||
ERR_DEVICEEXISTS(20, "设备已经存在"),
|
||||
/**
|
||||
* The Err paramexception.
|
||||
* Err paramexception error code.
|
||||
*/
|
||||
ERR_PARAMEXCEPTION(21, "参数异常"),
|
||||
/**
|
||||
* The Err devicelocked.
|
||||
* Err devicelocked error code.
|
||||
*/
|
||||
ERR_DEVICELOCKED(22, "设备已锁定"),
|
||||
/**
|
||||
* The Err version.
|
||||
* Err version error code.
|
||||
*/
|
||||
ERR_VERSION(23, "协议版本不兼容,请升级系统"),
|
||||
/**
|
||||
* The Err nosuchtype.
|
||||
* Err nosuchtype error code.
|
||||
*/
|
||||
ERR_NOSUCHTYPE(24, "没有这个类型的处置设备"),
|
||||
/**
|
||||
* The Err removemore.
|
||||
* Err removemore error code.
|
||||
*/
|
||||
ERR_REMOVEMORE(25, "禁止同时删除多个设备"),
|
||||
|
||||
/**
|
||||
* The Err taskrunning.
|
||||
* Err taskrunning error code.
|
||||
*/
|
||||
ERR_TASKRUNNING(26, "同类任务正在运行"),
|
||||
|
||||
/**
|
||||
* The Err unsupport.
|
||||
* Err unsupport error code.
|
||||
*/
|
||||
ERR_UNSUPPORT(27, "不支持的操作"),
|
||||
|
||||
/**
|
||||
* The Err interrupt.
|
||||
* Err interrupt error code.
|
||||
*/
|
||||
ERR_INTERRUPT(28, "操作中断"),
|
||||
|
||||
/**
|
||||
* The Err calldevice.
|
||||
* Err calldevice error code.
|
||||
*/
|
||||
ERR_CALLDEVICE(29, "调用设备失败"),
|
||||
|
||||
/**
|
||||
* The Err nosuchtask.
|
||||
* Err nosuchtask error code.
|
||||
*/
|
||||
ERR_NOSUCHTASK(30, "没有该任务"),
|
||||
|
||||
/**
|
||||
* The Err tasknotrunning.
|
||||
* Err tasknotrunning error code.
|
||||
*/
|
||||
ERR_TASKNOTRUNNING(31, "该任务没有运行"),
|
||||
|
||||
/**
|
||||
* The Err requesttimeout.
|
||||
* Err requesttimeout error code.
|
||||
*/
|
||||
ERR_REQUESTTIMEOUT(32, "请求超时"),
|
||||
|
||||
/**
|
||||
* The Err unabledisposeip.
|
||||
* Err unabledisposeip error code.
|
||||
*/
|
||||
ERR_UNABLEDISPOSEIP(33, "无法处置该IP"),
|
||||
|
||||
/**
|
||||
* The Err haohan error.
|
||||
* Err haohan error error code.
|
||||
*/
|
||||
ERR_HAOHAN_ERROR(34, "浩瀚设备返回错误"),
|
||||
|
||||
/**
|
||||
* The Err database.
|
||||
* Err database error code.
|
||||
*/
|
||||
ERR_DATABASE(35, "操作数据库失败"),
|
||||
|
||||
/**
|
||||
* The Err ipnodevice.
|
||||
* Err ipnodevice error code.
|
||||
*/
|
||||
ERR_IPNODEVICE(36, "找不到处置该IP的设备"),
|
||||
|
||||
/**
|
||||
* Err untrusthost error code.
|
||||
*/
|
||||
ERR_UNTRUSTHOST(37, "未经授权的客户端"),
|
||||
|
||||
/**
|
||||
* Err untrusttoken error code.
|
||||
*/
|
||||
ERR_UNTRUSTTOKEN(37, "未经授权的Token"),
|
||||
ERR_UNTRUSTTOKEN(38, "未经授权的Token"),
|
||||
|
||||
/**
|
||||
* The Err decrypt base 64.
|
||||
* Err decrypt base 64 error code.
|
||||
*/
|
||||
ERR_DECRYPT_BASE64(100, "BASE64解密失败"),
|
||||
/**
|
||||
* The Err encrypt base 64.
|
||||
* Err encrypt base 64 error code.
|
||||
*/
|
||||
ERR_ENCRYPT_BASE64(101, "BASE64加密失败"),
|
||||
/**
|
||||
* The Err decrypt aes 256.
|
||||
* Err decrypt aes 256 error code.
|
||||
*/
|
||||
ERR_DECRYPT_AES256(102, "AES256解密失败"),
|
||||
/**
|
||||
* The Err encrypt aes 256.
|
||||
* Err encrypt aes 256 error code.
|
||||
*/
|
||||
ERR_ENCRYPT_AES256(103, "AES256加密失败"),
|
||||
/**
|
||||
* The Err decrypt 3 des.
|
||||
* Err decrypt 3 des error code.
|
||||
*/
|
||||
ERR_DECRYPT_3DES(104, "3DES解密失败"),
|
||||
/**
|
||||
* The Err encrypt 3 des.
|
||||
* Err encrypt 3 des error code.
|
||||
*/
|
||||
ERR_ENCRYPT_3DES(105, "3DES加密失败"),
|
||||
/**
|
||||
* The Err decrypt unknown.
|
||||
* Err decrypt unknown error code.
|
||||
*/
|
||||
ERR_DECRYPT_UNKNOWN(106, "不支持的解密算法"),
|
||||
/**
|
||||
* The Err encrypt unknown.
|
||||
* Err encrypt unknown error code.
|
||||
*/
|
||||
ERR_ENCRYPT_UNKNOWN(107, "不支持的加密算法"),
|
||||
|
||||
/**
|
||||
* The Err json encode.
|
||||
* Err json encode error code.
|
||||
*/
|
||||
ERR_JSON_ENCODE(108, "Json 序列号错误"),
|
||||
/**
|
||||
* The Err json decode.
|
||||
* Err json decode error code.
|
||||
*/
|
||||
ERR_JSON_DECODE(109, "Json 反序列化错误"),
|
||||
;
|
||||
|
|
|
@ -13,15 +13,15 @@ public enum ObjectStatus implements BaseEnum {
|
|||
/**
|
||||
* The Locked.
|
||||
*/
|
||||
LOCKED(1, "锁定"),
|
||||
LOCKED(1, "已锁定"),
|
||||
/**
|
||||
* The Disabled.
|
||||
*/
|
||||
DISABLED(2, "禁用"),
|
||||
DISABLED(2, "已禁用"),
|
||||
/**
|
||||
* The Deleted.
|
||||
*/
|
||||
DELETED(3, "删除");
|
||||
DELETED(3, "已删除");
|
||||
|
||||
/**
|
||||
* The Code.
|
||||
|
|
|
@ -40,7 +40,8 @@ public class AuthConfigure implements WebMvcConfigurer {
|
|||
*/
|
||||
@PostConstruct
|
||||
private void initGlobalValue() {
|
||||
AuthConfigValue.TOKEN_EXPIRED_TIME_MS = Optional.ofNullable(tokenTimeoutMinute).orElse((long) 30 * 60 * 1000);
|
||||
AuthConfigValue.TOKEN_EXPIRED_TIME_MS =
|
||||
Optional.of(tokenTimeoutMinute * 60 * 1000).orElse((long) 30 * 60 * 1000);
|
||||
AuthConfigValue.VERIFY_REQUEST_TOKEN = Optional.ofNullable(verifyRequestToken).orElse(true);
|
||||
}
|
||||
|
||||
|
|
|
@ -41,12 +41,21 @@ public class DisposeConfigure {
|
|||
* The Used privacy protect.
|
||||
*/
|
||||
private Boolean usedPrivacyProtect;
|
||||
|
||||
/**
|
||||
* The Default dispose band width.
|
||||
*/
|
||||
private Integer defaultDisposeBandWidth;
|
||||
|
||||
/**
|
||||
* The Max split page size.
|
||||
*/
|
||||
private Integer maxSplitPageSize;
|
||||
|
||||
/**
|
||||
* The Min split page size.
|
||||
*/
|
||||
private Integer minSplitPageSize;
|
||||
|
||||
/**
|
||||
* Init global value.
|
||||
*/
|
||||
|
@ -58,5 +67,7 @@ public class DisposeConfigure {
|
|||
DisposeConfigValue.CALL_ERROR_RETRY_TIMES = Optional.ofNullable(callErrorRetryTimes).orElse(5);
|
||||
DisposeConfigValue.DEFAULT_DISPOSE_BANDWIDTH = Optional.ofNullable(defaultDisposeBandWidth).orElse(1024);
|
||||
DisposeConfigValue.SPLIT_CHAR = Optional.ofNullable(splitChar).orElse(",");
|
||||
DisposeConfigValue.MAX_SPLIT_PAGE_SIZE = Optional.ofNullable(maxSplitPageSize).orElse(100);
|
||||
DisposeConfigValue.MIN_SPLIT_PAGE_SIZE = Optional.ofNullable(minSplitPageSize).orElse(10);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -81,7 +81,8 @@ public class DisposeDeviceManagerController {
|
|||
DisposeDevice dev = DisposeDevice.builder()
|
||||
.ipAddr(v.getIpAddr())
|
||||
.ipPort(v.getIpPort())
|
||||
.deviceType(CommonEnumHandler.codeOf(DisposeDeviceType.class, v.getDeviceType()))
|
||||
.deviceType(CommonEnumHandler.codeOf(DisposeDeviceType.class,
|
||||
v.getDeviceType()))
|
||||
.areaCode(v.getAreaCode())
|
||||
.deviceName(v.getDeviceName())
|
||||
.manufacturer(v.getManufacturer())
|
||||
|
@ -100,9 +101,11 @@ public class DisposeDeviceManagerController {
|
|||
v.getCapacity().forEach(k -> {
|
||||
// 添加设备能力
|
||||
DisposeCapacity cap = DisposeCapacity.builder()
|
||||
.capacityType(CommonEnumHandler.codeOf(DisposeCapacityType.class, k.getCapacityType()))
|
||||
.capacityType(CommonEnumHandler.codeOf(DisposeCapacityType.class, k
|
||||
.getCapacityType()))
|
||||
.ipType(CommonEnumHandler.codeOf(IpAddrType.class, k.getIpType()))
|
||||
.objectType(CommonEnumHandler.codeOf(DisposeObjectType.class, k.getObjectType()))
|
||||
.objectType(CommonEnumHandler.codeOf(DisposeObjectType.class,
|
||||
k.getObjectType()))
|
||||
.protectIp(k.getProtectIp())
|
||||
.build();
|
||||
dev.getDevCapacity().add(cap);
|
||||
|
@ -140,14 +143,16 @@ public class DisposeDeviceManagerController {
|
|||
DisposeDevice dev = v.getSecondParam();
|
||||
AddDeviceRet rsp = AddDeviceRet.builder()
|
||||
.ipAddr(dev.getIpAddr())
|
||||
.ipPort(dev.getIpPort())
|
||||
.ipPort(dev.getIpPort().length() == 0 ?
|
||||
(dev.getUrlType() == HttpType.HTTP ?
|
||||
"80" : "443") : dev.getIpPort())
|
||||
.build();
|
||||
|
||||
rsp.setStatus(v.getFirstParam().getCode());
|
||||
rsp.setMessage(new String[] {v.getFirstParam().getMsg()});
|
||||
rsp.setMessage(new String[]{v.getFirstParam().getMsg()});
|
||||
|
||||
// 添加设备成功,记录新增设备ID
|
||||
if(rsp.getStatus() == ErrorCode.ERR_OK.getCode()) {
|
||||
if (rsp.getStatus() == ErrorCode.ERR_OK.getCode()) {
|
||||
rsp.setDevId(String.valueOf(dev.getId()));
|
||||
}
|
||||
|
||||
|
@ -189,7 +194,7 @@ public class DisposeDeviceManagerController {
|
|||
rsp.setId(String.valueOf(dev.getId()));
|
||||
rsp.setDevStatus(dev.getStatus());
|
||||
rsp.setStatus(v.getFirstParam().getCode());
|
||||
rsp.setMessage(new String[] {v.getFirstParam().getMsg()});
|
||||
rsp.setMessage(new String[]{v.getFirstParam().getMsg()});
|
||||
|
||||
rspInfo.add(rsp);
|
||||
});
|
||||
|
@ -224,7 +229,7 @@ public class DisposeDeviceManagerController {
|
|||
|
||||
rsp.setId(String.valueOf(dev.getId()));
|
||||
rsp.setStatus(v.getFirstParam().getCode());
|
||||
rsp.setMessage(new String[] {v.getFirstParam().getMsg()});
|
||||
rsp.setMessage(new String[]{v.getFirstParam().getMsg()});
|
||||
|
||||
rspInfo.add(rsp);
|
||||
});
|
||||
|
@ -246,8 +251,8 @@ public class DisposeDeviceManagerController {
|
|||
@RequestBody ProtocolReqDTO<GetDeviceReq> mr) {
|
||||
|
||||
MulReturnType<PageInfo<DisposeDevice>, List<DisposeDevice>> ret =
|
||||
disposeDeviceManagerService.getAllDisposeDevice(mr.getMsgContent().getStartPage(),
|
||||
Integer.parseInt(mr.getMsgContent().getPageSize()));
|
||||
disposeDeviceManagerService.getPageDisposeDevice(mr.getMsgContent().getStartPage(),
|
||||
mr.getMsgContent().getPageSize());
|
||||
|
||||
GetDeviceRsp rspInfo = new GetDeviceRsp();
|
||||
|
||||
|
@ -258,7 +263,7 @@ public class DisposeDeviceManagerController {
|
|||
// 分页信息
|
||||
rspInfo.setCurPageNumber(ret.getFirstParam().getPageNum());
|
||||
rspInfo.setPageSize(ret.getFirstParam().getPageSize());
|
||||
rspInfo.setTotalItems((int)ret.getFirstParam().getTotal());
|
||||
rspInfo.setTotalItems((int) ret.getFirstParam().getTotal());
|
||||
rspInfo.setTotalPages(ret.getFirstParam().getPages());
|
||||
|
||||
// 设备信息
|
||||
|
@ -267,7 +272,8 @@ public class DisposeDeviceManagerController {
|
|||
devInfo.setId(v.getId().toString());
|
||||
devInfo.setIpAddr(DisposeConfigValue.USED_PRIVACY_PROTECT ?
|
||||
PrivacyHelper.ipAddressPrivacy(v.getIpAddr()) : v.getIpAddr());
|
||||
devInfo.setIpPort(v.getIpPort());
|
||||
devInfo.setIpPort(v.getIpPort().length() == 0 ?
|
||||
(v.getUrlType() == HttpType.HTTP ? "80" : "443") : v.getIpPort());
|
||||
devInfo.setDeviceType(v.getDeviceType().getValue());
|
||||
devInfo.setAreaCode(v.getAreaCode());
|
||||
devInfo.setDeviceName(v.getDeviceName());
|
||||
|
@ -288,6 +294,7 @@ public class DisposeDeviceManagerController {
|
|||
.objectType(k.getObjectType().getValue())
|
||||
.ipType(k.getIpType().getValue())
|
||||
.protectIp(k.getProtectIp())
|
||||
.reserveNetflow(k.getReserveNetflow())
|
||||
.build();
|
||||
|
||||
capList.add(capInfo);
|
||||
|
|
|
@ -0,0 +1,90 @@
|
|||
package com.dispose.controller;
|
||||
|
||||
import com.dispose.common.DisposeCapacityType;
|
||||
import com.dispose.common.ErrorCode;
|
||||
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.GetAreaInfoRsp;
|
||||
import com.dispose.pojo.entity.DisposeDevice;
|
||||
import com.dispose.service.AreaCodeManagerService;
|
||||
import com.dispose.service.DisposeAbilityRouterService;
|
||||
import com.dispose.service.DisposeDeviceManagerService;
|
||||
import com.security.annotation.Decryption;
|
||||
import com.security.annotation.Encryption;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* The type Dispose info controller.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping(value = "/info")
|
||||
@Slf4j
|
||||
@Api(value = "处置平台认证接口", tags = "前端接口接口")
|
||||
@Component
|
||||
@Validated
|
||||
@Encryption
|
||||
@Decryption
|
||||
public class DisposeInfoController {
|
||||
|
||||
/**
|
||||
* The Dispose device manager service.
|
||||
*/
|
||||
@Resource
|
||||
private DisposeDeviceManagerService disposeDeviceManagerService;
|
||||
|
||||
/**
|
||||
* The Dispose ability router service.
|
||||
*/
|
||||
@Resource
|
||||
private DisposeAbilityRouterService disposeAbilityRouterService;
|
||||
|
||||
@Resource
|
||||
private AreaCodeManagerService areaCodeManagerService;
|
||||
|
||||
/**
|
||||
* Gets all dispose device.
|
||||
*
|
||||
* @return the all dispose device
|
||||
*/
|
||||
@GetMapping("areaInfo")
|
||||
@ResponseBody
|
||||
@ApiOperation("获取处置能力节点")
|
||||
public ProtocolRespDTO<?> getAllDisposeDevice() {
|
||||
|
||||
GetAreaInfoRsp rspInfo = GetAreaInfoRsp.builder()
|
||||
.items(new ArrayList<>())
|
||||
.build();
|
||||
|
||||
Map<Integer, List<DisposeDevice>> groupDev = areaCodeManagerService.getAreaCodeGroup();
|
||||
|
||||
for (Integer areaCode : groupDev.keySet()) {
|
||||
AreaInfoDetail info = AreaInfoDetail.builder()
|
||||
.nodeId(areaCode.toString())
|
||||
.totalNetflow(areaCodeManagerService.getAreaCodeGroupReserveNetflow(areaCode))
|
||||
.onlineDevices(areaCodeManagerService.getAreaCodeOnlineDeviceNum(areaCode))
|
||||
.capacityType(Arrays.stream(areaCodeManagerService.getAreaCodeSupportCapacity(areaCode))
|
||||
.map(DisposeCapacityType::getValue)
|
||||
.toArray(Integer[]::new))
|
||||
.build();
|
||||
rspInfo.getItems().add(info);
|
||||
}
|
||||
|
||||
return ProtocolRespDTO.result(ErrorCode.ERR_OK, rspInfo);
|
||||
}
|
||||
}
|
|
@ -11,6 +11,7 @@ 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.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.TaskStopRsp;
|
||||
|
@ -128,7 +129,7 @@ public class DisposeTaskController {
|
|||
@PostMapping("/startMulIp")
|
||||
@ResponseBody
|
||||
@ApiOperation("启动处置任务")
|
||||
public ProtocolRespDTO<List<TaskStartRsp>> startTaskMulIp(@Validated(ValidGroups.TaskStartMulReqValid.class)
|
||||
public ProtocolRespDTO<TaskStartMulRsp> startTaskMulIp(@Validated(ValidGroups.TaskStartMulReqValid.class)
|
||||
@RequestBody ProtocolReqDTO<TaskStartReq> mr,
|
||||
@NotNull @RequestHeader HttpHeaders headers) {
|
||||
TaskStartReq req = mr.getMsgContent();
|
||||
|
@ -143,7 +144,9 @@ public class DisposeTaskController {
|
|||
Integer flowBand = Optional.ofNullable(req.getFlowBandwidth())
|
||||
.orElse(DisposeConfigValue.DEFAULT_DISPOSE_BANDWIDTH);
|
||||
|
||||
List<TaskStartRsp> rspList = new ArrayList<>();
|
||||
TaskStartMulRsp mulRsp = TaskStartMulRsp.builder()
|
||||
.items(new ArrayList<>())
|
||||
.build();
|
||||
|
||||
for (String ip : req.getMulDisposeIp()) {
|
||||
// 构造处置任务参数
|
||||
|
@ -176,10 +179,10 @@ public class DisposeTaskController {
|
|||
rspInfo.setStatus(ret.getFirstParam().getCode());
|
||||
rspInfo.setMessage(new String[]{ret.getFirstParam().getMsg()});
|
||||
|
||||
rspList.add(rspInfo);
|
||||
mulRsp.getItems().add(rspInfo);
|
||||
}
|
||||
|
||||
return ProtocolRespDTO.result(ErrorCode.ERR_OK, rspList);
|
||||
return ProtocolRespDTO.result(ErrorCode.ERR_OK, mulRsp);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
package com.dispose.pojo.dto.protocol.device.info;
|
||||
|
||||
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 Area info detail.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@JsonPropertyOrder({"nodeId", "totalNetflow", "capacityType", "onlineDevices"})
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class AreaInfoDetail {
|
||||
/**
|
||||
* The Node id.
|
||||
*/
|
||||
private String nodeId;
|
||||
/**
|
||||
* The Total netflow.
|
||||
*/
|
||||
private Integer totalNetflow;
|
||||
/**
|
||||
* The Capacity type.
|
||||
*/
|
||||
private Integer[] capacityType;
|
||||
/**
|
||||
* The Online devices.
|
||||
*/
|
||||
private Integer onlineDevices;
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package com.dispose.pojo.dto.protocol.device.info;
|
||||
|
||||
|
||||
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.List;
|
||||
|
||||
/**
|
||||
* The type Get area info rsp.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@JsonPropertyOrder({"taskId", "disposeIp", "expireTime", "status", "message"})
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class GetAreaInfoRsp extends BaseRespStatus {
|
||||
/**
|
||||
* The Items.
|
||||
*/
|
||||
private List<AreaInfoDetail> items;
|
||||
}
|
|
@ -24,7 +24,7 @@ import javax.validation.constraints.NotNull;
|
|||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@JsonPropertyOrder({"capacityType", "objectType", "ipType", "protectIp"})
|
||||
@JsonPropertyOrder({"capacityType", "objectType", "ipType", "protectIp", "reserveNetflow"})
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class AddCapacityInfo {
|
||||
/**
|
||||
|
@ -52,4 +52,9 @@ public class AddCapacityInfo {
|
|||
*/
|
||||
@ValidIpSegment(message = "protectIp Ip地址格式错误", groups = ValidGroups.AddDeviceValid.class)
|
||||
private String protectIp;
|
||||
|
||||
/**
|
||||
* The Reserve netflow.
|
||||
*/
|
||||
private Integer reserveNetflow;
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ import lombok.NoArgsConstructor;
|
|||
@Data
|
||||
@NoArgsConstructor
|
||||
@JsonPropertyOrder({"id", "ipAddr", "ipPort", "deviceType", "areaCode", "deviceName", "manufacturer",
|
||||
"model", "version", "userName", "password", "urlPath", "urlType", "readme", "capacity", "status"})
|
||||
"model", "version", "userName", "password", "urlPath", "urlType", "readme", "devStatus", "capacity"})
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class GetDeviceDetail extends AddDeviceInfo {
|
||||
/**
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.dispose.pojo.dto.protocol.device.manager;
|
||||
|
||||
import com.dispose.validation.group.ValidGroups;
|
||||
import com.dispose.validation.valids.ValidSplitPageSize;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
|
@ -8,7 +9,6 @@ import lombok.Data;
|
|||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Pattern;
|
||||
import javax.validation.constraints.Positive;
|
||||
|
||||
/**
|
||||
|
@ -32,9 +32,7 @@ public class GetDeviceReq {
|
|||
/**
|
||||
* The Page size.
|
||||
*/
|
||||
@Pattern(regexp = "^([1-5]0)$",
|
||||
message = "pageSize 字段取值为 {10, 20, 30, 40, 50}",
|
||||
groups = ValidGroups.ProtocolCommonValid.class)
|
||||
@ValidSplitPageSize(groups = ValidGroups.ProtocolCommonValid.class)
|
||||
@NotNull(message = "pageSize 字段不能为空", groups = ValidGroups.ProtocolCommonValid.class)
|
||||
private String pageSize;
|
||||
private Integer pageSize;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
package com.dispose.pojo.dto.protocol.task;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* The type Task start mul rsp.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class TaskStartMulRsp {
|
||||
/**
|
||||
* The Items.
|
||||
*/
|
||||
List<TaskStartRsp> items;
|
||||
}
|
|
@ -8,6 +8,7 @@ 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;
|
||||
|
@ -57,6 +58,7 @@ public class TaskStartReq {
|
|||
* The Dispose time.
|
||||
*/
|
||||
@NotNull(message = "disposeTime 处置时间不能为空", groups = ValidGroups.TaskStartReqCommonValid.class)
|
||||
@ValidSplitPageSize(groups = ValidGroups.TaskStartReqCommonValid.class)
|
||||
private Integer disposeTime;
|
||||
/**
|
||||
* The Flow direction.
|
||||
|
|
|
@ -66,4 +66,9 @@ public class DisposeCapacity implements Serializable {
|
|||
* The Protect ip.
|
||||
*/
|
||||
private String protectIp;
|
||||
|
||||
/**
|
||||
* The Reserve netflow.
|
||||
*/
|
||||
private Integer reserveNetflow;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
package com.dispose.service;
|
||||
|
||||
import com.dispose.common.DisposeCapacityType;
|
||||
import com.dispose.pojo.entity.DisposeDevice;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* The interface Area code manager service.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
public interface AreaCodeManagerService {
|
||||
/**
|
||||
* Gets area code group.
|
||||
*
|
||||
* @return the area code group
|
||||
*/
|
||||
Map<Integer, List<DisposeDevice>> getAreaCodeGroup();
|
||||
|
||||
/**
|
||||
* Gets area code group reserve netflow.
|
||||
*
|
||||
* @param areaCode the area code
|
||||
* @return the area code group reserve netflow
|
||||
*/
|
||||
int getAreaCodeGroupReserveNetflow(Integer areaCode);
|
||||
|
||||
/**
|
||||
* Gets area code online device num.
|
||||
*
|
||||
* @param areaCode the area code
|
||||
* @return the area code online device num
|
||||
*/
|
||||
int getAreaCodeOnlineDeviceNum(Integer areaCode);
|
||||
|
||||
/**
|
||||
* Gets area code support capacity.
|
||||
*
|
||||
* @param areaCode the area code
|
||||
* @return the area code support capacity
|
||||
*/
|
||||
DisposeCapacityType[] getAreaCodeSupportCapacity(Integer areaCode);
|
||||
}
|
|
@ -40,12 +40,19 @@ public interface DisposeDeviceManagerService {
|
|||
|
||||
|
||||
/**
|
||||
* Gets all dispose device.
|
||||
* Gets page dispose device.
|
||||
*
|
||||
* @param startPage the start page
|
||||
* @param pageSize the page size
|
||||
* @return the page dispose device
|
||||
*/
|
||||
MulReturnType<PageInfo<DisposeDevice>, List<DisposeDevice>> getPageDisposeDevice(Integer startPage,
|
||||
Integer pageSize);
|
||||
|
||||
/**
|
||||
* Gets all dispose device.
|
||||
*
|
||||
* @return the all dispose device
|
||||
*/
|
||||
MulReturnType<PageInfo<DisposeDevice>, List<DisposeDevice>> getAllDisposeDevice(Integer startPage,
|
||||
Integer pageSize);
|
||||
List<DisposeDevice> getAllDisposeDevice();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,119 @@
|
|||
package com.dispose.service.impl;
|
||||
|
||||
import com.dispose.common.DisposeCapacityType;
|
||||
import com.dispose.pojo.entity.DisposeCapacity;
|
||||
import com.dispose.pojo.entity.DisposeDevice;
|
||||
import com.dispose.service.AreaCodeManagerService;
|
||||
import com.dispose.service.DisposeAbilityRouterService;
|
||||
import com.dispose.service.DisposeDeviceManagerService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* The type Area code manager service.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class AreaCodeManagerServiceImpl implements AreaCodeManagerService {
|
||||
|
||||
/**
|
||||
* The Dispose device manager service.
|
||||
*/
|
||||
@Resource
|
||||
private DisposeDeviceManagerService disposeDeviceManagerService;
|
||||
|
||||
/**
|
||||
* The Dispose ability router service.
|
||||
*/
|
||||
@Resource
|
||||
private DisposeAbilityRouterService disposeAbilityRouterService;
|
||||
|
||||
/**
|
||||
* Gets area code group.
|
||||
*
|
||||
* @return the area code group
|
||||
*/
|
||||
@Override
|
||||
public Map<Integer, List<DisposeDevice>> getAreaCodeGroup() {
|
||||
List<DisposeDevice> disposeDevices = disposeDeviceManagerService.getAllDisposeDevice();
|
||||
|
||||
if (disposeDevices == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return disposeDevices.stream().collect(Collectors.groupingBy(DisposeDevice::getAreaCode));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets area code group reserve netflow.
|
||||
*
|
||||
* @param areaCode the area code
|
||||
* @return the area code group reserve netflow
|
||||
*/
|
||||
@Override
|
||||
public int getAreaCodeGroupReserveNetflow(Integer areaCode) {
|
||||
List<DisposeDevice> disposeDevices = disposeDeviceManagerService.getAllDisposeDevice();
|
||||
|
||||
if (disposeDevices == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return disposeDevices.stream()
|
||||
.filter(v -> v.getAreaCode().equals(areaCode))
|
||||
.mapToInt(v -> v.getDevCapacity().stream()
|
||||
.filter(k -> k.getCapacityType() == DisposeCapacityType.CLEANUP)
|
||||
.mapToInt(DisposeCapacity::getReserveNetflow).sum())
|
||||
.sum();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets area code online device num.
|
||||
*
|
||||
* @param areaCode the area code
|
||||
* @return the area code online device num
|
||||
*/
|
||||
@Override
|
||||
public int getAreaCodeOnlineDeviceNum(Integer areaCode) {
|
||||
List<DisposeDevice> disposeDevices = disposeDeviceManagerService.getAllDisposeDevice();
|
||||
|
||||
if (disposeDevices == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return (int) disposeDevices.stream()
|
||||
.filter(v -> v.getAreaCode().equals(areaCode))
|
||||
.filter(k -> disposeAbilityRouterService.getAbilityDevice(k.getId())
|
||||
.getDb()
|
||||
.getDeviceLinkStatus())
|
||||
.count();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get area code support capacity dispose capacity type [ ].
|
||||
*
|
||||
* @param areaCode the area code
|
||||
* @return the dispose capacity type [ ]
|
||||
*/
|
||||
@Override
|
||||
public DisposeCapacityType[] getAreaCodeSupportCapacity(Integer areaCode) {
|
||||
List<DisposeDevice> disposeDevices = disposeDeviceManagerService.getAllDisposeDevice();
|
||||
|
||||
if (disposeDevices == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return disposeDevices.stream()
|
||||
.filter(v -> v.getAreaCode().equals(areaCode))
|
||||
.flatMap(k -> k.getDevCapacity().stream()
|
||||
.map(DisposeCapacity::getCapacityType))
|
||||
.distinct()
|
||||
.toArray(DisposeCapacityType[]::new);
|
||||
}
|
||||
}
|
|
@ -101,15 +101,25 @@ public class DisposeDeviceManagerServiceImpl implements DisposeDeviceManagerServ
|
|||
}
|
||||
|
||||
/**
|
||||
* Gets all dispose device.
|
||||
* Gets page dispose device.
|
||||
*
|
||||
* @param startPage the start page
|
||||
* @param pageSize the page size
|
||||
* @return the all dispose device
|
||||
* @return the page dispose device
|
||||
*/
|
||||
@Override
|
||||
public MulReturnType<PageInfo<DisposeDevice>, List<DisposeDevice>> getAllDisposeDevice(Integer startPage,
|
||||
public MulReturnType<PageInfo<DisposeDevice>, List<DisposeDevice>> getPageDisposeDevice(Integer startPage,
|
||||
Integer pageSize) {
|
||||
return disposeDeviceManager.getPagesOfDevices(startPage, pageSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all dispose device.
|
||||
*
|
||||
* @return the all dispose device
|
||||
*/
|
||||
@Override
|
||||
public List<DisposeDevice> getAllDisposeDevice() {
|
||||
return disposeDeviceManager.getAllNormalDisposeDevices();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
package com.dispose.validation.valids;
|
||||
|
||||
import com.dispose.validation.valids.impl.ValidSplitPageSizeImpl;
|
||||
|
||||
import javax.validation.Constraint;
|
||||
import javax.validation.Payload;
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Target({ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
@Constraint(validatedBy = {ValidSplitPageSizeImpl.class})
|
||||
public @interface ValidSplitPageSize {
|
||||
String message() default "";
|
||||
|
||||
/**
|
||||
* Groups class [ ].
|
||||
*
|
||||
* @return the class [ ]
|
||||
*/
|
||||
Class<?>[] groups() default {};
|
||||
|
||||
/**
|
||||
* Payload class [ ].
|
||||
*
|
||||
* @return the class [ ]
|
||||
*/
|
||||
Class<? extends Payload>[] payload() default {};
|
||||
}
|
|
@ -55,10 +55,10 @@ public class ValidBaseEnumArrayImpl implements ConstraintValidator<ValidBaseEnum
|
|||
List<Integer> enumValues = Arrays.stream(enumClass.getEnumConstants())
|
||||
.map(BaseEnum::getValue).collect(Collectors.toList());
|
||||
|
||||
String errMsg = this.message +
|
||||
String errMsg = this.message + " 字段 " +
|
||||
((ConstraintValidatorContextImpl) ctx).getConstraintViolationCreationContexts()
|
||||
.get(0).getPath().getLeafNode().getName()
|
||||
+ " 字段取值范围:" + enumValues.toString();
|
||||
+ " 值 {" + Arrays.toString(integers) + "} 错误, 字段取值范围:" + enumValues.toString();
|
||||
|
||||
// 重新设置消息
|
||||
ctx.disableDefaultConstraintViolation();
|
||||
|
|
|
@ -58,10 +58,10 @@ public class ValidBaseEnumImpl implements ConstraintValidator<ValidBaseEnum, Int
|
|||
List<Integer> enumValues = Arrays.stream(enumClass.getEnumConstants())
|
||||
.map(BaseEnum::getValue).collect(Collectors.toList());
|
||||
|
||||
String errMsg = this.message +
|
||||
String errMsg = this.message + " 字段 " +
|
||||
((ConstraintValidatorContextImpl) ctx).getConstraintViolationCreationContexts()
|
||||
.get(0).getPath().getLeafNode().getName()
|
||||
+ " 字段取值范围:" + enumValues.toString();
|
||||
+ " 值 {" + integer + "} 错误, 字段取值范围:" + enumValues.toString();
|
||||
|
||||
// 重新设置消息
|
||||
ctx.disableDefaultConstraintViolation();
|
||||
|
|
|
@ -0,0 +1,68 @@
|
|||
package com.dispose.validation.valids.impl;
|
||||
|
||||
import com.dispose.common.DisposeConfigValue;
|
||||
import com.dispose.validation.valids.ValidSplitPageSize;
|
||||
import org.hibernate.validator.internal.engine.constraintvalidation.ConstraintValidatorContextImpl;
|
||||
|
||||
import javax.validation.ConstraintValidator;
|
||||
import javax.validation.ConstraintValidatorContext;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* The type Valid split page size.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
public class ValidSplitPageSizeImpl implements ConstraintValidator<ValidSplitPageSize, Integer> {
|
||||
private String message;
|
||||
|
||||
/**
|
||||
* Initialize.
|
||||
*
|
||||
* @param constraintAnnotation the constraint annotation
|
||||
*/
|
||||
@Override
|
||||
public void initialize(ValidSplitPageSize constraintAnnotation) {
|
||||
this.message = constraintAnnotation.message();
|
||||
}
|
||||
|
||||
/**
|
||||
* Is valid boolean.
|
||||
*
|
||||
* @param integer the integer
|
||||
* @param ctx the constraint validator context
|
||||
* @return the boolean
|
||||
*/
|
||||
@Override
|
||||
public boolean isValid(Integer integer, ConstraintValidatorContext ctx) {
|
||||
|
||||
if (integer == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (integer == 0 ||
|
||||
integer % DisposeConfigValue.MIN_SPLIT_PAGE_SIZE != 0 ||
|
||||
integer > DisposeConfigValue.MAX_SPLIT_PAGE_SIZE) {
|
||||
|
||||
List<Integer> rang = new ArrayList<>();
|
||||
|
||||
for (int i = DisposeConfigValue.MIN_SPLIT_PAGE_SIZE; i <= DisposeConfigValue.MAX_SPLIT_PAGE_SIZE;
|
||||
i += DisposeConfigValue.MIN_SPLIT_PAGE_SIZE) {
|
||||
rang.add(i);
|
||||
}
|
||||
|
||||
String errMsg = this.message + " 字段 " +
|
||||
((ConstraintValidatorContextImpl) ctx).getConstraintViolationCreationContexts()
|
||||
.get(0).getPath().getLeafNode().getName() +
|
||||
" 值 {" + integer + "} 错误, 字段取值范围:" + rang.toString();
|
||||
|
||||
// 重新设置消息
|
||||
ctx.disableDefaultConstraintViolation();
|
||||
ctx.buildConstraintViolationWithTemplate(errMsg).addConstraintViolation();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -8,6 +8,7 @@
|
|||
<result column="objectType" property="objectType" javaType="com.dispose.common.DisposeObjectType"/>
|
||||
<result column="ipType" property="ipType" javaType="com.dispose.common.IpAddrType"/>
|
||||
<result column="protectIp" property="protectIp"/>
|
||||
<result column="reserveNetflow" property="reserveNetflow"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="selectAll" resultMap="dispose_capacity">
|
||||
|
@ -17,10 +18,11 @@
|
|||
|
||||
<insert id="addNewDisposeCapacity" useGeneratedKeys="true" keyProperty="id"
|
||||
parameterType="com.dispose.pojo.entity.DisposeCapacity">
|
||||
INSERT IGNORE INTO dispose_capacity(deviceId, capacityType, objectType, ipType, protectIp)
|
||||
INSERT IGNORE INTO dispose_capacity(deviceId, capacityType, objectType, ipType, protectIp, reserveNetflow)
|
||||
VALUES
|
||||
<foreach collection="devCaps" item="cap" separator=",">
|
||||
(#{cap.deviceId}, #{cap.capacityType}, #{cap.objectType}, #{cap.ipType}, #{cap.protectIp})
|
||||
(#{cap.deviceId}, #{cap.capacityType}, #{cap.objectType}, #{cap.ipType},
|
||||
#{cap.protectIp}, #{cap.reserveNetflow})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
<result column="objectType" property="objectType" javaType="com.dispose.common.DisposeObjectType"/>
|
||||
<result column="ipType" property="ipType" javaType="com.dispose.common.IpAddrType"/>
|
||||
<result column="protectIp" property="protectIp"/>
|
||||
<result column="reserveNetflow" property="reserveNetflow"/>
|
||||
</collection>
|
||||
</resultMap>
|
||||
|
||||
|
@ -34,7 +35,8 @@
|
|||
c.capacityType capacityType,
|
||||
c.objectType objectType,
|
||||
c.ipType ipType,
|
||||
c.protectIp protectIp
|
||||
c.protectIp protectIp,
|
||||
c.reserveNetflow reserveNetflow
|
||||
FROM dispose_device d
|
||||
LEFT JOIN dispose_capacity c ON d.id = c.deviceId
|
||||
</select>
|
||||
|
|
|
@ -377,7 +377,7 @@ public class DisposeDeviceManagerControllerTest extends InitTestEnvironment {
|
|||
|
||||
for (int i = 1; i < 5; i++) {
|
||||
getReq.setStartPage(i);
|
||||
getReq.setPageSize(String.valueOf(i * 10));
|
||||
getReq.setPageSize(i * 10);
|
||||
|
||||
ProtocolReqDTO<GetDeviceReq> reqInfo = new ProtocolReqDTO<>();
|
||||
|
||||
|
@ -387,7 +387,7 @@ public class DisposeDeviceManagerControllerTest extends InitTestEnvironment {
|
|||
reqInfo.setMsgContent(getReq);
|
||||
|
||||
String ret = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/manager/device_list")
|
||||
.post("/manager/deviceList")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", ConstValue.STRING_HTTP_AUTH_HEAD + getLoginToken())
|
||||
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||
|
@ -405,7 +405,7 @@ public class DisposeDeviceManagerControllerTest extends InitTestEnvironment {
|
|||
|
||||
log.debug(objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(rspInfo));
|
||||
|
||||
double totalPages = Math.ceil(deviceList.size() / Double.parseDouble(getReq.getPageSize()));
|
||||
double totalPages = Math.ceil(deviceList.size() / getReq.getPageSize().doubleValue());
|
||||
|
||||
Assert.assertEquals(rspInfo.getMsgContent().getCurPageNumber(), getReq.getStartPage());
|
||||
Assert.assertEquals(String.valueOf(rspInfo.getMsgContent().getPageSize()), String.valueOf(getReq.getPageSize()));
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
package com.dispose.test.service;
|
||||
|
||||
import com.dispose.service.AreaCodeManagerService;
|
||||
import com.dispose.test.Global.InitTestEnvironment;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.junit.Assert;
|
||||
import org.junit.FixMethodOrder;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.MethodSorters;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.annotation.Rollback;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Arrays;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
@Slf4j
|
||||
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
||||
@Transactional
|
||||
@Rollback
|
||||
public class AreaCodeManagerServiceTest extends InitTestEnvironment {
|
||||
|
||||
@Resource
|
||||
private AreaCodeManagerService areaCodeManagerService;
|
||||
|
||||
@Test
|
||||
public void a2_getAreaCodeGroupReserveNetflow() {
|
||||
long tolNetflow = areaCodeManagerService.getAreaCodeGroupReserveNetflow(0);
|
||||
|
||||
log.info("AreaCode {} netflow total: {}", 0, tolNetflow);
|
||||
|
||||
Assert.assertNotEquals(tolNetflow, 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void a3_getAreaCodeSupportCapacity() {
|
||||
log.info("AreaCode {} capacity: {}", 0,
|
||||
Arrays.toString(areaCodeManagerService.getAreaCodeSupportCapacity(2)));
|
||||
}
|
||||
}
|
|
@ -239,7 +239,7 @@ public class DisposeDeviceManagerServiceTest extends InitTestEnvironment {
|
|||
Integer startPage = i;
|
||||
Integer pageSize = i * 2;
|
||||
|
||||
MulReturnType<PageInfo<DisposeDevice>, List<DisposeDevice>> ret = disposeDeviceManagerService.getAllDisposeDevice(startPage, pageSize);
|
||||
MulReturnType<PageInfo<DisposeDevice>, List<DisposeDevice>> ret = disposeDeviceManagerService.getPageDisposeDevice(startPage, pageSize);
|
||||
|
||||
PageInfo<DisposeDevice> pageInfo = ret.getFirstParam();
|
||||
List<DisposeDevice> deviceList = ret.getSecondParam();
|
||||
|
|
Loading…
Reference in New Issue