com.dahuatech.icc.multiinone.admin.vo.OperateDirectRequest Maven / Gradle / Ivy
package com.dahuatech.icc.multiinone.admin.vo;
import com.dahuatech.icc.common.ParamValidEnum;
import com.dahuatech.icc.multiinone.utils.StringUtils;
import com.dahuatech.icc.multiinone.vo.BaseRequest;
import com.dahuatech.icc.oauth.exception.BusinessException;
/**
* program:java-sdk
*
* Author: 312013
* Date:2022-08-11 09:43
* Description: 云台控制,封装开启与停止操作
*/
public class OperateDirectRequest extends BaseRequest {
//数据对象
private OperateDirectData data;
public OperateDirectData getData() {
return data;
}
public void setData(OperateDirectData data) {
this.data = data;
}
public class OperateDirectData{
//水平方向步长
private String stepX;
//垂直方向步长
private String stepY;
//方向:1=上,2=下,3=左,4=右,5=左上,6=左下,7=右上,8=右下
private String direct;
//通道编码
private String channelId;
//命令:0=停止, 1=开启
private String command;
//扩展数据
private String extend;
public String getStepX() {
return stepX;
}
public void setStepX(String stepX) {
this.stepX = stepX;
}
public String getStepY() {
return stepY;
}
public void setStepY(String stepY) {
this.stepY = stepY;
}
public String getDirect() {
return direct;
}
public void setDirect(String direct) {
this.direct = direct;
}
public String getChannelId() {
return channelId;
}
public void setChannelId(String channelId) {
this.channelId = channelId;
}
public String getCommand() {
return command;
}
public void setCommand(String command) {
this.command = command;
}
public String getExtend() {
return extend;
}
public void setExtend(String extend) {
this.extend = extend;
}
}
public void businessValid() {
if(data == null){
throw new BusinessException(ParamValidEnum.PARAM_NOT_EMPTY_ERROR.getCode(), ParamValidEnum.PARAM_NOT_EMPTY_ERROR.getErrMsg(), "data");
}
if(StringUtils.isEmpty(data.stepX) &&StringUtils.isEmpty(data.stepY) &&StringUtils.isEmpty(data.direct)&&StringUtils.isEmpty(data.channelId)&&StringUtils.isEmpty(data.command)&&StringUtils.isEmpty(data.extend)){
throw new BusinessException(ParamValidEnum.PARAM_NOT_EMPTY_ERROR.getCode(), ParamValidEnum.PARAM_NOT_EMPTY_ERROR.getErrMsg(), "data");
}
if(StringUtils.isEmpty(data.stepX)){
throw new BusinessException(ParamValidEnum.PARAM_NOT_EMPTY_ERROR.getCode(), ParamValidEnum.PARAM_NOT_EMPTY_ERROR.getErrMsg(), "data.stepX");
}
if(Long.parseLong(data.stepX) < 1 || Long.parseLong(data.stepX) > 8){
throw new BusinessException(ParamValidEnum.PARAM_SCOP_ERROR.getCode(), ParamValidEnum.PARAM_SCOP_ERROR.getErrMsg(), "data.stepX");
}
if(StringUtils.isEmpty(data.stepY)){
throw new BusinessException(ParamValidEnum.PARAM_NOT_EMPTY_ERROR.getCode(), ParamValidEnum.PARAM_NOT_EMPTY_ERROR.getErrMsg(), "data.stepY");
}
if(Long.parseLong(data.stepY) < 1 || Long.parseLong(data.stepY) > 8){
throw new BusinessException(ParamValidEnum.PARAM_SCOP_ERROR.getCode(), ParamValidEnum.PARAM_SCOP_ERROR.getErrMsg(), "data.stepY");
}
if(StringUtils.isEmpty(data.direct)){
throw new BusinessException(ParamValidEnum.PARAM_NOT_EMPTY_ERROR.getCode(), ParamValidEnum.PARAM_NOT_EMPTY_ERROR.getErrMsg(), "data.direct");
}
if(Long.parseLong(data.direct) < 1 || Long.parseLong(data.direct) > 8){
throw new BusinessException(ParamValidEnum.PARAM_SCOP_ERROR.getCode(), ParamValidEnum.PARAM_SCOP_ERROR.getErrMsg(), "data.direct");
}
if(StringUtils.isEmpty(data.channelId)){
throw new BusinessException(ParamValidEnum.PARAM_NOT_EMPTY_ERROR.getCode(), ParamValidEnum.PARAM_NOT_EMPTY_ERROR.getErrMsg(), "data.channelId");
}
if(StringUtils.isEmpty(data.command)){
throw new BusinessException(ParamValidEnum.PARAM_NOT_EMPTY_ERROR.getCode(), ParamValidEnum.PARAM_NOT_EMPTY_ERROR.getErrMsg(), "data.command");
}
if(Long.parseLong(data.command) != 1 && Long.parseLong(data.command) != 0){
throw new BusinessException(ParamValidEnum.PARAM_SCOP_ERROR.getCode(), ParamValidEnum.PARAM_SCOP_ERROR.getErrMsg(), "data.command");
}
if(StringUtils.isEmpty(data.extend)){
throw new BusinessException(ParamValidEnum.PARAM_NOT_EMPTY_ERROR.getCode(), ParamValidEnum.PARAM_NOT_EMPTY_ERROR.getErrMsg(), "data.extend");
}
}
}