com.dahuatech.icc.cirs.model.v202209.material.MaterialUploadRequest Maven / Gradle / Ivy
package com.dahuatech.icc.cirs.model.v202209.material;
import com.dahuatech.hutool.http.Method;
import com.dahuatech.icc.cirs.constant.CirsConstant;
import com.dahuatech.icc.cirs.enums.DirTypeEnums;
import com.dahuatech.icc.common.ParamValidEnum;
import com.dahuatech.icc.exception.ClientException;
import com.dahuatech.icc.oauth.exception.BusinessException;
import com.dahuatech.icc.oauth.http.AbstractIccRequest;
import com.dahuatech.icc.oauth.model.v202010.HttpConfigInfo;
import com.dahuatech.icc.util.StringUtils;
import java.io.File;
/**
* program:java-sdk
*
* @Author: 355079
* @Date:2022-09-06 09:47
* @Description: 素材上传
*/
public class MaterialUploadRequest extends AbstractIccRequest {
private File file;
private String name;
private Integer dirType;
private String dirCode;
private Integer duration;
public File getFile() {
return file;
}
public void setFile(File file) {
this.file = file;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Integer getDirType() {
return dirType;
}
public void setDirType(Integer dirType) {
this.dirType = dirType;
}
public String getDirCode() {
return dirCode;
}
public void setDirCode(String dirCode) {
this.dirCode = dirCode;
}
public Integer getDuration() {
return duration;
}
public void setDuration(Integer duration) {
this.duration = duration;
}
public MaterialUploadRequest(File file,String name,Integer dirType, String dirCode, Integer duration) throws ClientException {
super(CirsConstant.url(CirsConstant.MATERIAL_UPLOAD), Method.POST);
form("file",file);
form("name",name);
form("dirType",dirType);
form("dirCode",dirCode);
form("duration",duration);
this.file=file;
this.name=name;
this.dirType=dirType;
this.dirCode=dirCode;
this.duration=duration;
}
public MaterialUploadRequest(HttpConfigInfo httpConfigInfo, String url, Method method) throws ClientException {
super(httpConfigInfo.getPrefixUrl() + url, method, Boolean.TRUE);
}
@Override
public Class getResponseClass() {
return MaterialUploadResponse.class;
}
public void businessValid() throws BusinessException{
if(file==null){
throw new BusinessException(ParamValidEnum.PARAM_NOT_EMPTY_ERROR.getCode(), ParamValidEnum.PARAM_NOT_EMPTY_ERROR.getErrMsg(), "file");
}
if(StringUtils.isEmpty(name)){
throw new BusinessException(ParamValidEnum.PARAM_NOT_EMPTY_ERROR.getCode(), ParamValidEnum.PARAM_NOT_EMPTY_ERROR.getErrMsg(), "name");
}
if(!DirTypeEnums.isRight(dirType)){
throw new BusinessException(ParamValidEnum.PARAM_NOT_EMPTY_ERROR.getCode(), ParamValidEnum.PARAM_NOT_EMPTY_ERROR.getErrMsg(), "dirType");
}
if(StringUtils.isEmpty(dirCode)){
throw new BusinessException(ParamValidEnum.PARAM_NOT_EMPTY_ERROR.getCode(), ParamValidEnum.PARAM_NOT_EMPTY_ERROR.getErrMsg(), "dirCode");
}
if(duration==null){
throw new BusinessException(ParamValidEnum.PARAM_NOT_EMPTY_ERROR.getCode(), ParamValidEnum.PARAM_NOT_EMPTY_ERROR.getErrMsg(), "duration");
}
}
}