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

com.dahuatech.icc.multiinone.vo.BaseRequest Maven / Gradle / Ivy

There is a newer version: 1.0.13.7
Show newest version
package com.dahuatech.icc.multiinone.vo;

import com.dahuatech.icc.common.ParamValidEnum;
import com.dahuatech.icc.multiinone.domain.BaseBean;
import com.dahuatech.icc.multiinone.exception.BusinessException;
import com.dahuatech.icc.oauth.model.v202010.OauthConfigBaseInfo;
import com.dahuatech.icc.oauth.model.v202010.OauthConfigUserPwdInfo;
import com.dahuatech.icc.oauth.profile.GrantType;
import com.dahuatech.icc.util.StringUtils;

public abstract class BaseRequest extends BaseBean{

    protected OauthConfigBaseInfo oauthConfigBaseInfo;

    public OauthConfigBaseInfo getOauthConfigBaseInfo() {
        return oauthConfigBaseInfo;
    }

    public void setOauthConfigBaseInfo(OauthConfigBaseInfo oauthConfigBaseInfo) {
        this.oauthConfigBaseInfo = oauthConfigBaseInfo;
    }

    public void valid(){
        /**
         * 鉴权参数校验
         */
        baseCheck();
        /**
         * 业务参数校验
         */
        businessValid();
    }

    public void baseCheck(){
        if(this == null){
            throw new com.dahuatech.icc.oauth.exception.BusinessException(ParamValidEnum.OAUTH_PARAM_NOT_EMPTY_ERROR.getCode(),"请求对象为空", "GroupInfoAddRequest");
        }
        if(oauthConfigBaseInfo == null){
            throw new com.dahuatech.icc.oauth.exception.BusinessException(ParamValidEnum.OAUTH_PARAM_NOT_EMPTY_ERROR.getCode(), "鉴权信息为空", "oauthConfigBaseInfo");
        }
        if(oauthConfigBaseInfo.getGrantType() == null){
            throw new com.dahuatech.icc.oauth.exception.BusinessException(ParamValidEnum.OAUTH_PARAM_NOT_EMPTY_ERROR.getCode(), "鉴权类型为空", "grantType");
        }
        if(com.dahuatech.icc.util.StringUtils.isEmpty(oauthConfigBaseInfo.getClientId())){
            throw new com.dahuatech.icc.oauth.exception.BusinessException(ParamValidEnum.OAUTH_PARAM_NOT_EMPTY_ERROR.getCode(), "申请访问id凭证为空", "clientId");
        }
        if(com.dahuatech.icc.util.StringUtils.isEmpty(oauthConfigBaseInfo.getClientSecret())){
            throw new com.dahuatech.icc.oauth.exception.BusinessException(ParamValidEnum.OAUTH_PARAM_NOT_EMPTY_ERROR.getCode(), "申请访问秘钥为空", "clientSecret");
        }
        if(oauthConfigBaseInfo.getHttpConfigInfo() == null){
            throw new com.dahuatech.icc.oauth.exception.BusinessException(ParamValidEnum.OAUTH_PARAM_NOT_EMPTY_ERROR.getCode(), "平台信息为空", "httpConfigInfo");
        }
        if(com.dahuatech.icc.util.StringUtils.isEmpty(oauthConfigBaseInfo.getHttpConfigInfo().getHost())){
            throw new com.dahuatech.icc.oauth.exception.BusinessException(ParamValidEnum.OAUTH_PARAM_NOT_EMPTY_ERROR.getCode(), "平台信息|host为空", "host");
        }
        if(oauthConfigBaseInfo.getGrantType() == GrantType.password){//客户端
            OauthConfigUserPwdInfo oauthConfigUserPwdInfo = (OauthConfigUserPwdInfo)oauthConfigBaseInfo;
            if(com.dahuatech.icc.util.StringUtils.isEmpty(oauthConfigUserPwdInfo.getPassword())){
                throw new com.dahuatech.icc.oauth.exception.BusinessException(ParamValidEnum.OAUTH_PARAM_NOT_EMPTY_ERROR.getCode(), "平台信息|密码为空", "password");
            }
            if(com.dahuatech.icc.util.StringUtils.isEmpty(oauthConfigUserPwdInfo.getUsername())){
                throw new com.dahuatech.icc.oauth.exception.BusinessException(ParamValidEnum.OAUTH_PARAM_NOT_EMPTY_ERROR.getCode(), "平台信息|用户名为空", "username");
            }
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy