All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.dahuatech.icc.cirs.model.v202209.material.MaterialPartRequest Maven / Gradle / Ivy

There is a newer version: 1.0.13.7
Show newest version
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 13:41
 * @Description: 素材分片上传
 */
public class MaterialPartRequest extends AbstractIccRequest {
    private String name;
    private Integer dirType;
    private String dirCode;
    private String taskId;
    private Integer chunkTotal;
    private Integer chunk;
    private File file;
    private Long size;

    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 String getTaskId() {
        return taskId;
    }

    public void setTaskId(String taskId) {
        this.taskId = taskId;
    }

    public Integer getChunkTotal() {
        return chunkTotal;
    }

    public void setChunkTotal(Integer chunkTotal) {
        this.chunkTotal = chunkTotal;
    }

    public Integer getChunk() {
        return chunk;
    }

    public void setChunk(Integer chunk) {
        this.chunk = chunk;
    }

    public File getFile() {
        return file;
    }

    public void setFile(File file) {
        this.file = file;
    }

    public Long getSize() {
        return size;
    }

    public void setSize(Long size) {
        this.size = size;
    }

    public MaterialPartRequest(String name, Integer dirType, String dirCode, String taskId, Integer chunkTotal,
                               Integer chunk, File file, Long size) throws ClientException {
        super(CirsConstant.url(CirsConstant.MATERIAL_PART), Method.POST);
        form("name",name);
        form("dirType",dirType);
        form("dirCode",dirCode);
        form("taskId",taskId);
        form("chunkTotal",chunkTotal);
        form("chunk",chunk);
        form("file",file);
        form("size",size);
        this.name=name;
        this.dirType=dirType;
        this.dirCode=dirCode;
        this.taskId=taskId;
        this.chunkTotal=chunkTotal;
        this.chunk=chunk;
        this.file=file;
        this.size=size;
    }

    public MaterialPartRequest(HttpConfigInfo httpConfigInfo, String url, Method method) throws ClientException {
        super(httpConfigInfo.getPrefixUrl() + url, method, Boolean.TRUE);
    }

    @Override
    public Class getResponseClass() {
        return MaterialPartResponse.class;
    }

    public void businessValid() throws BusinessException {
        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(StringUtils.isEmpty(taskId)){
            throw new BusinessException(ParamValidEnum.PARAM_NOT_EMPTY_ERROR.getCode(), ParamValidEnum.PARAM_NOT_EMPTY_ERROR.getErrMsg(), "taskId");
        }
        if(chunkTotal==null){
            throw new BusinessException(ParamValidEnum.PARAM_NOT_EMPTY_ERROR.getCode(), ParamValidEnum.PARAM_NOT_EMPTY_ERROR.getErrMsg(), "chunkTotal");
        }
        if(chunk==null){
            throw new BusinessException(ParamValidEnum.PARAM_NOT_EMPTY_ERROR.getCode(), ParamValidEnum.PARAM_NOT_EMPTY_ERROR.getErrMsg(), "chunk");
        }
        if(file==null){
            throw new BusinessException(ParamValidEnum.PARAM_NOT_EMPTY_ERROR.getCode(), ParamValidEnum.PARAM_NOT_EMPTY_ERROR.getErrMsg(), "file");
        }
        if(size==null){
            throw new BusinessException(ParamValidEnum.PARAM_NOT_EMPTY_ERROR.getCode(), ParamValidEnum.PARAM_NOT_EMPTY_ERROR.getErrMsg(), "size");
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy