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

com.dahuatech.icc.brm.model.v202010.user.BrmUserBatchAddRequest Maven / Gradle / Ivy

There is a newer version: 1.0.13.7
Show newest version
package com.dahuatech.icc.brm.model.v202010.user;

import com.dahuatech.hutool.http.Method;
import com.dahuatech.icc.brm.constant.BrmConstant;
import com.dahuatech.icc.brm.constant.ParamConstant;
import com.dahuatech.icc.brm.exception.BusinessException;
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.List;

public class BrmUserBatchAddRequest
        extends AbstractIccRequest {

    private List userAddList;

    public BrmUserBatchAddRequest(Builder builder) {
        super(BrmConstant.url(BrmConstant.BRM_URL_USER_BATCH_ADD_POST), Method.POST);
        this.userAddList = builder.userAddList;
        putBodyParameter("userAddList", userAddList);
    }

    public BrmUserBatchAddRequest(){
        super(BrmConstant.url(BrmConstant.BRM_URL_USER_BATCH_ADD_POST), Method.POST);
    }

    public static Builder builder() {
        return new Builder();
    }

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

    public List getUserAddList() {
        return userAddList;
    }

    public void setUserAddList(List userAddList) {
        this.userAddList = userAddList;
        putBodyParameter("userAddList", userAddList);
    }

    @Override
    public String toString() {
        return "BrmUserBatchAddRequest{" +
                "userAddList=" + userAddList +
                '}';
    }

    public static class UserBatch {

        /** 登录用户名 */
        private String loginName;
        /** 所属组织编码 */
        private String ownerCode;
        /** 是否复用 */
        private Integer isReuse;
        /** 关联人员ID */
        private Long personId;
        /** 用户关联角色 */
        private List roleIdList;
        /*--------以上必填-----*/

        public String getLoginName() {
            return loginName;
        }

        public void setLoginName(String loginName) {
            this.loginName = loginName;
        }

        public String getOwnerCode() {
            return ownerCode;
        }

        public void setOwnerCode(String ownerCode) {
            this.ownerCode = ownerCode;
        }

        public Integer getIsReuse() {
            return isReuse;
        }

        public void setIsReuse(Integer isReuse) {
            this.isReuse = isReuse;
        }

        public Long getPersonId() {
            return personId;
        }

        public void setPersonId(Long personId) {
            this.personId = personId;
        }

        public List getRoleIdList() {
            return roleIdList;
        }

        public void setRoleIdList(List roleIdList) {
            this.roleIdList = roleIdList;
        }
    }

    public static class Builder {
        private List userAddList;

        public Builder userAddList(List userAddList) {
            this.userAddList = userAddList;
            return this;
        }

        public BrmUserBatchAddRequest build() throws ClientException {
            return new BrmUserBatchAddRequest(this);
        }
    }
    public void businessValid() {
        if(CollectionUtil.isEmpty(userAddList)){
            throw new BusinessException(ParamValidEnum.PARAM_NOT_EMPTY_ERROR.getCode(),ParamValidEnum.PARAM_NOT_EMPTY_ERROR.getErrMsg(), "userAddList");
        }
        for(UserBatch userBatch : userAddList){
            if(StringUtils.isEmpty(userBatch.getLoginName())){
                throw new BusinessException(ParamValidEnum.PARAM_NOT_EMPTY_ERROR.getCode(),ParamValidEnum.PARAM_NOT_EMPTY_ERROR.getErrMsg(), "loginName");
            }
            if(StringUtils.isEmpty(userBatch.getOwnerCode())){
                throw new BusinessException(ParamValidEnum.PARAM_NOT_EMPTY_ERROR.getCode(),ParamValidEnum.PARAM_NOT_EMPTY_ERROR.getErrMsg(), "ownerCode");
            }
            if(userBatch.getIsReuse() == null){
                throw new BusinessException(ParamValidEnum.PARAM_NOT_EMPTY_ERROR.getCode(),ParamValidEnum.PARAM_NOT_EMPTY_ERROR.getErrMsg(), "isReuse");
            }
            if(userBatch.getPersonId() == null){
                throw new BusinessException(ParamValidEnum.PARAM_NOT_EMPTY_ERROR.getCode(),ParamValidEnum.PARAM_NOT_EMPTY_ERROR.getErrMsg(), "personId");
            }
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy