wang.ramboll.extend.request.limit.autoconfigure.RequestLimitProperties Maven / Gradle / Ivy
The newest version!
package wang.ramboll.extend.request.limit.autoconfigure;
import org.apache.commons.lang3.StringUtils;
import org.springframework.boot.context.properties.ConfigurationProperties;
/**
* 请求防刷/限量拦截 自动装载配置
* @author WangRuibo
*/
@ConfigurationProperties(prefix = RequestLimitProperties.WANG_RAMBOLL_PREFIX)
public class RequestLimitProperties {
public static final String WANG_RAMBOLL_PREFIX = "wang.ramboll.request.limit";
/**
* Controller所在包
*/
private String controllerPackages = "";
/**
* 默认拦截返回类型
*/
private Class defaultLimitReturnClass = null;
/**
* 是否使用默认返回对象Bean
*/
private boolean useFailReturnBean = false;
/**
* 默认拦截返回code
*/
private int defaultLimitReturnCode = -1 ;
/**
* 默认拦截返回message
*/
private String defaultLimitReturnMessage = "Request frequency limited.";
private String[] controllerPackageArray = {};
/**
* 是否开启自动装配
* @return
*/
public boolean isEnable() {
return StringUtils.isNotBlank(controllerPackages);
}
public String getControllerPackages() {
return controllerPackages;
}
public void setControllerPackages(String controllerPackages) {
this.controllerPackages = controllerPackages;
this.controllerPackageArray = controllerPackages.split(",");
}
public Class getDefaultLimitReturnClass() {
return defaultLimitReturnClass;
}
public void setDefaultLimitReturnClass(Class defaultLimitReturnClass) {
this.defaultLimitReturnClass = defaultLimitReturnClass;
}
public int getDefaultLimitReturnCode() {
return defaultLimitReturnCode;
}
public void setDefaultLimitReturnCode(int defaultLimitReturnCode) {
this.defaultLimitReturnCode = defaultLimitReturnCode;
}
public String getDefaultLimitReturnMessage() {
return defaultLimitReturnMessage;
}
public void setDefaultLimitReturnMessage(String defaultLimitReturnMessage) {
this.defaultLimitReturnMessage = defaultLimitReturnMessage;
}
public String[] getControllerPackageArray() {
return controllerPackageArray;
}
public boolean isUseFailReturnBean() {
return useFailReturnBean;
}
public void setUseFailReturnBean(boolean useFailReturnBean) {
this.useFailReturnBean = useFailReturnBean;
}
}