com.dahuatech.icc.brm.model.v202010.card.BrmCardBatchAddRequest Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of java-sdk-brm Show documentation
Show all versions of java-sdk-brm Show documentation
Dahua ICC Open API SDK for Java
The newest version!
package com.dahuatech.icc.brm.model.v202010.card;
import com.dahuatech.hutool.http.Method;
import com.dahuatech.icc.brm.constant.BrmConstant;
import com.dahuatech.icc.oauth.exception.BusinessException;
import com.dahuatech.icc.brm.model.v202010.FieldExt;
import com.dahuatech.icc.common.ParamValidEnum;
import com.dahuatech.icc.exception.ClientException;
import com.dahuatech.icc.oauth.http.AbstractIccRequest;
import com.dahuatech.icc.util.CollectionUtil;
import com.dahuatech.icc.util.StringUtils;
import java.util.Collections;
import java.util.List;
/**
* 批量新增卡片
*
* @author 232676
* @since 1.0.0 2020/11/11 12:19
*/
public class BrmCardBatchAddRequest extends AbstractIccRequest {
private List cardList;
private List fieldExt;
private BrmCardBatchAddRequest(Builder builder) {
super(BrmConstant.url(BrmConstant.BRM_URL_CARD_BATCH_ADD_POST), Method.POST);
this.cardList = builder.cardList;
putBodyParameter("cardList", cardList);
}
public BrmCardBatchAddRequest(){
super(BrmConstant.url(BrmConstant.BRM_URL_CARD_BATCH_ADD_POST), Method.POST);
}
public static Builder builder() {
return new Builder();
}
public List getCardList() {
return cardList;
}
public void setCardList(List cardList) {
this.cardList = cardList;
putBodyParameter("cardList", cardList);
}
public List getFieldExt() {
return fieldExt;
}
public void setFieldExt(List fieldExt) {
this.fieldExt = fieldExt;
putBodyParameter("fieldExt", fieldExt);
}
@Override
public Class getResponseClass() {
return BrmCardBatchAddResponse.class;
}
public static class Builder {
private List cardList;
public Builder cardList(List cardList) {
this.cardList = cardList;
return this;
}
public BrmCardBatchAddRequest build() throws ClientException {
return new BrmCardBatchAddRequest(this);
}
}
public void businessValid() {
if(CollectionUtil.isEmpty(cardList)){
throw new BusinessException(ParamValidEnum.PARAM_NOT_EMPTY_ERROR.getCode(),ParamValidEnum.PARAM_NOT_EMPTY_ERROR.getErrMsg(), "cardList");
}
for(BrmCard brmCard : cardList){
if(StringUtils.isEmpty(brmCard.getCardNumber())){
throw new BusinessException(ParamValidEnum.PARAM_NOT_EMPTY_ERROR.getCode(),ParamValidEnum.PARAM_NOT_EMPTY_ERROR.getErrMsg(), "cardNumber");
}
if(StringUtils.isEmpty(brmCard.getCategory())){
throw new BusinessException(ParamValidEnum.PARAM_NOT_EMPTY_ERROR.getCode(),ParamValidEnum.PARAM_NOT_EMPTY_ERROR.getErrMsg(), "category");
}
if(StringUtils.isEmpty(brmCard.getCardType())){
throw new BusinessException(ParamValidEnum.PARAM_NOT_EMPTY_ERROR.getCode(),ParamValidEnum.PARAM_NOT_EMPTY_ERROR.getErrMsg(), "cardType");
}
if(StringUtils.isEmpty(brmCard.getStartDate())){
throw new BusinessException(ParamValidEnum.PARAM_NOT_EMPTY_ERROR.getCode(),ParamValidEnum.PARAM_NOT_EMPTY_ERROR.getErrMsg(), "startDate");
}
if(StringUtils.isEmpty(brmCard.getEndDate())){
throw new BusinessException(ParamValidEnum.PARAM_NOT_EMPTY_ERROR.getCode(),ParamValidEnum.PARAM_NOT_EMPTY_ERROR.getErrMsg(), "endDate");
}
if(brmCard.getDepartmentId() == null){
throw new BusinessException(ParamValidEnum.PARAM_NOT_EMPTY_ERROR.getCode(),ParamValidEnum.PARAM_NOT_EMPTY_ERROR.getErrMsg(), "departmentId");
}
}
}
}