配置文件优化

v1.4.1
Parker 4 years ago
parent 10b91dc156
commit 78b76a50ae

@ -16,7 +16,6 @@
package org.opsli.common.constants;
import org.opsli.common.utils.Props;
/**
* @BelongsProject: opsli-boot
@ -25,40 +24,31 @@ import org.opsli.common.utils.Props;
* @CreateTime: 2020-09-18 18:46
* @Description: MyBatis
*/
public final class MyBatisConstants {
public interface MyBatisConstants {
/** 逻辑删除值 */
public static final String LOGIC_DELETE_VALUE;
String LOGIC_DELETE_VALUE = "1";
/** 逻辑不删除值 */
public static final String LOGIC_NOT_DELETE_VALUE;
String LOGIC_NOT_DELETE_VALUE = "0";
/** ID */
public static final String FIELD_ID = "id";
String FIELD_ID = "id";
/** PID */
public static final String FIELD_PARENT_ID = "parentId";
String FIELD_PARENT_ID = "parentId";
/** 创建人 */
public static final String FIELD_CREATE_BY = "createBy";
String FIELD_CREATE_BY = "createBy";
/** 更新时间 */
public static final String FIELD_CREATE_TIME = "createTime";
String FIELD_CREATE_TIME = "createTime";
/** 更新人 */
public static final String FIELD_UPDATE_BY = "updateBy";
String FIELD_UPDATE_BY = "updateBy";
/** 更新时间 */
public static final String FIELD_UPDATE_TIME = "updateTime";
String FIELD_UPDATE_TIME = "updateTime";
/** 逻辑删除 */
public static final String FIELD_DELETE_LOGIC = "deleted";
String FIELD_DELETE_LOGIC = "deleted";
/** 乐观锁 */
public static final String FIELD_OPTIMISTIC_LOCK = "version";
String FIELD_OPTIMISTIC_LOCK = "version";
/** 多租户字段 */
public static final String FIELD_TENANT = "tenantId";
static {
Props props = new Props("application.yaml");
LOGIC_DELETE_VALUE = props.getStr("mybatis-plus.global-config.db-config.logic-delete-value","1");
LOGIC_NOT_DELETE_VALUE = props.getStr("mybatis-plus.global-config.db-config.logic-not-delete-value","0");
}
private MyBatisConstants(){}
String FIELD_TENANT = "tenantId";
}

@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
package org.opsli.core.conf;
package org.opsli.core.autoconfigure.conf;
import com.google.code.kaptcha.impl.DefaultKaptcha;
import com.google.code.kaptcha.util.Config;

@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
package org.opsli.core.conf;
package org.opsli.core.autoconfigure.conf;
import com.baomidou.mybatisplus.extension.plugins.OptimisticLockerInterceptor;
import lombok.extern.slf4j.Slf4j;
@ -31,7 +31,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
*
*/
@Slf4j
@EnableTransactionManagement //开启事务
@EnableTransactionManagement
@Configuration
public class MyBatisPlusConfig {

@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
package org.opsli.core.conf;
package org.opsli.core.autoconfigure.conf;
import lombok.extern.slf4j.Slf4j;
import org.opsli.core.cache.pushsub.receiver.RedisPushSubReceiver;

@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
package org.opsli.core.conf;
package org.opsli.core.autoconfigure.conf;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ClassUtil;
@ -29,15 +29,12 @@ import org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSource
import org.apache.shiro.spring.web.ShiroFilterFactoryBean;
import org.apache.shiro.web.mgt.DefaultWebSecurityManager;
import org.apache.shiro.web.session.mgt.DefaultWebSessionManager;
import org.opsli.common.utils.Props;
import org.opsli.core.autoconfigure.GlobalProperties;
import org.opsli.core.autoconfigure.properties.ApiPathProperties;
import org.opsli.core.autoconfigure.properties.GlobalProperties;
import org.opsli.core.security.shiro.authenticator.CustomModularRealmAuthenticator;
import org.opsli.core.security.shiro.filter.CustomShiroFilter;
import org.opsli.core.security.shiro.realm.FlagRealm;
import org.opsli.plugins.redis.conf.RedisPluginConfig;
import org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.DependsOn;
@ -57,30 +54,17 @@ import java.util.Set;
* @date 2017-04-20 18:33
*/
@Configuration
@AutoConfigureAfter(RedisPluginConfig.class)
public class ShiroConfig {
/** 获得排除URL */
private static final List<String> URL_EXCLUSION;
/** API前缀 */
private static final String API_URL_PREFIX;
static{
Props props = new Props("application.yaml");
URL_EXCLUSION = props.getList("opsli.token-auth.url-exclusion");
API_URL_PREFIX = props.getStr("server.servlet.api.path.global-prefix","");
}
@Autowired
GlobalProperties globalProperties;
/**
* filer
* @param securityManager
* @return
* @return ShiroFilterFactoryBean
*/
@Bean("shiroFilter")
public ShiroFilterFactoryBean shirFilter(SecurityManager securityManager) {
public ShiroFilterFactoryBean shirFilter(SecurityManager securityManager,
GlobalProperties globalProperties, ApiPathProperties apiPathProperties) {
ShiroFilterFactoryBean shiroFilter = new ShiroFilterFactoryBean();
shiroFilter.setSecurityManager(securityManager);
@ -92,9 +76,14 @@ public class ShiroConfig {
Map<String, String> filterMap = Maps.newLinkedHashMap();
// 加载排除URL
if(CollUtil.isNotEmpty(URL_EXCLUSION)){
for (String excUrl : URL_EXCLUSION) {
filterMap.put(excUrl, "anon");
if(globalProperties.getAuth() != null &&
globalProperties.getAuth().getToken() != null){
Set<String> urlExclusion = globalProperties.getAuth().getToken().getUrlExclusion();
if(CollUtil.isNotEmpty(urlExclusion)){
for (String excUrl : urlExclusion) {
filterMap.put(excUrl, "anon");
}
}
}
@ -105,8 +94,8 @@ public class ShiroConfig {
filterMap.put("/captcha.jpg", "anon");
// 导出Excel\模版 不做自动拦截 手动拦截
filterMap.put(API_URL_PREFIX + "/**/exportExcel", "anon");
filterMap.put(API_URL_PREFIX + "/**/importExcel/template", "anon");
filterMap.put(apiPathProperties.getGlobalPrefix() + "/**/exportExcel", "anon");
filterMap.put(apiPathProperties.getGlobalPrefix() + "/**/importExcel/template", "anon");
filterMap.put("/webjars/**", "anon");
filterMap.put("/druid/**", "anon");
@ -197,7 +186,7 @@ public class ShiroConfig {
/**
* shiro
* @param securityManager
* @return
* @return AuthorizationAttributeSourceAdvisor
*/
@Bean("authorizationAttributeSourceAdvisor")
public AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor(SecurityManager securityManager) {

@ -13,11 +13,11 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
package org.opsli.core.conf;
package org.opsli.core.autoconfigure.conf;
import lombok.extern.slf4j.Slf4j;
import org.opsli.common.annotation.ApiRestController;
import org.opsli.core.autoconfigure.ApiPathProperties;
import org.opsli.core.autoconfigure.properties.ApiPathProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.cors.CorsConfiguration;

@ -13,16 +13,15 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
package org.opsli.core.conf;
package org.opsli.core.autoconfigure.conf;
import com.fasterxml.classmate.TypeResolver;
import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
import com.google.common.collect.Lists;
import io.swagger.annotations.ApiOperation;
import org.opsli.core.autoconfigure.GlobalProperties;
import org.opsli.core.autoconfigure.properties.GlobalProperties;
import org.opsli.core.utils.UserTokenUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
@ -38,6 +37,7 @@ import springfox.documentation.spi.service.contexts.SecurityContext;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
import javax.annotation.Resource;
import java.util.List;
/**
@ -50,8 +50,8 @@ import java.util.List;
public class SwaggerConfig {
/** 配置类 */
@Autowired
protected GlobalProperties globalProperties;
@Resource
private GlobalProperties globalProperties;
private final TypeResolver typeResolver;

@ -13,17 +13,17 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
package org.opsli.core.conf;
package org.opsli.core.autoconfigure.conf;
import cn.hutool.core.convert.Convert;
import org.opsli.core.autoconfigure.GlobalProperties;
import org.opsli.core.autoconfigure.properties.GlobalProperties;
import org.opsli.core.waf.filter.WafFilter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import javax.annotation.Resource;
import javax.servlet.DispatcherType;
/**
@ -36,7 +36,7 @@ import javax.servlet.DispatcherType;
@Configuration
public class WafConfig {
@Autowired
@Resource
private GlobalProperties globalProperties;
@Bean

@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
package org.opsli.core.autoconfigure;
package org.opsli.core.autoconfigure.properties;
import lombok.Data;
import lombok.EqualsAndHashCode;

@ -1,4 +1,4 @@
package org.opsli.core.autoconfigure;
package org.opsli.core.autoconfigure.properties;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;

@ -1,4 +1,4 @@
package org.opsli.core.autoconfigure;
package org.opsli.core.autoconfigure.properties;
import lombok.Data;
import lombok.EqualsAndHashCode;

@ -37,7 +37,7 @@ import org.opsli.common.exception.TokenException;
import org.opsli.common.msg.CommonMsg;
import org.opsli.common.utils.OutputStreamUtil;
import org.opsli.common.utils.WrapperUtil;
import org.opsli.core.autoconfigure.GlobalProperties;
import org.opsli.core.autoconfigure.properties.GlobalProperties;
import org.opsli.core.base.entity.BaseEntity;
import org.opsli.core.base.service.interfaces.CrudServiceInterface;
import org.opsli.core.cache.local.CacheUtil;

@ -21,11 +21,11 @@ import cn.hutool.core.lang.Console;
import cn.hutool.core.thread.ThreadUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.opsli.core.autoconfigure.GlobalProperties;
import org.opsli.core.autoconfigure.properties.GlobalProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Date;
@ -138,9 +138,9 @@ public class StartPrint {
/***
*
* @param globalProperties
* @param globalProperties
*/
@PostConstruct
@Autowired
public void init(GlobalProperties globalProperties){
if(globalProperties != null){
// 设置系统名称

@ -8,7 +8,7 @@ import com.auth0.jwt.algorithms.Algorithm;
import com.auth0.jwt.exceptions.JWTDecodeException;
import com.auth0.jwt.interfaces.DecodedJWT;
import lombok.extern.slf4j.Slf4j;
import org.opsli.core.autoconfigure.GlobalProperties;
import org.opsli.core.autoconfigure.properties.GlobalProperties;
import org.opsli.common.constants.SignConstants;
import org.opsli.common.constants.TokenTypeConstants;
import org.opsli.common.exception.JwtException;

@ -32,7 +32,7 @@ import org.opsli.common.constants.TokenConstants;
import org.opsli.common.constants.TokenTypeConstants;
import org.opsli.common.exception.TokenException;
import org.opsli.common.utils.Props;
import org.opsli.core.autoconfigure.GlobalProperties;
import org.opsli.core.autoconfigure.properties.GlobalProperties;
import org.opsli.core.msg.TokenMsg;
import org.opsli.plugins.redis.RedisPlugin;
import org.springframework.beans.factory.annotation.Autowired;

@ -28,7 +28,7 @@ import org.opsli.api.wrapper.system.menu.MenuModel;
import org.opsli.api.wrapper.system.user.UserModel;
import org.opsli.common.api.TokenThreadLocal;
import org.opsli.common.exception.TokenException;
import org.opsli.core.autoconfigure.GlobalProperties;
import org.opsli.core.autoconfigure.properties.GlobalProperties;
import org.opsli.core.cache.local.CacheUtil;
import org.opsli.core.cache.pushsub.msgs.UserMsgFactory;
import org.opsli.core.msg.TokenMsg;

@ -60,20 +60,20 @@
{
"name": "opsli.system-name",
"sourceType": "org.opsli.core.autoconfigure.GlobalProperties",
"sourceType": "org.opsli.core.autoconfigure.properties.GlobalProperties",
"type": "java.lang.String",
"defaultValue": "OPSLI 快速开发平台",
"description": "系统名称."
},
{
"name": "opsli.system-starter-time",
"sourceType": "org.opsli.core.autoconfigure.GlobalProperties",
"sourceType": "org.opsli.core.autoconfigure.properties.GlobalProperties",
"type": "java.lang.String",
"description": "系统启动时间 为空则默认 真实当前系统启动时间."
},
{
"name": "opsli.enable-demo",
"sourceType": "org.opsli.core.autoconfigure.GlobalProperties",
"sourceType": "org.opsli.core.autoconfigure.properties.GlobalProperties",
"type": "java.lang.Boolean",
"defaultValue": false,
"description": "是否开启演示模式."
@ -83,28 +83,28 @@
{
"name": "opsli.waf.enable",
"sourceType": "org.opsli.core.autoconfigure.GlobalProperties$Waf",
"sourceType": "org.opsli.core.autoconfigure.properties.GlobalProperties$Waf",
"type": "java.lang.Boolean",
"defaultValue": false,
"description": "软防火墙是否开启."
},
{
"name": "opsli.waf.xss-filter",
"sourceType": "org.opsli.core.autoconfigure.GlobalProperties$Waf",
"sourceType": "org.opsli.core.autoconfigure.properties.GlobalProperties$Waf",
"type": "java.lang.Boolean",
"defaultValue": false,
"description": "软防火墙 xss 过滤开启状态."
},
{
"name": "opsli.waf.sql-filter",
"sourceType": "org.opsli.core.autoconfigure.GlobalProperties$Waf",
"sourceType": "org.opsli.core.autoconfigure.properties.GlobalProperties$Waf",
"type": "java.lang.Boolean",
"defaultValue": false,
"description": "软防火墙 sql 过滤开启状态."
},
{
"name": "opsli.waf.url-patterns",
"sourceType": "org.opsli.core.autoconfigure.GlobalProperties$Waf",
"sourceType": "org.opsli.core.autoconfigure.properties.GlobalProperties$Waf",
"type": "java.util.Set<java.lang.String>",
"defaultValue": [
"/*"
@ -113,13 +113,13 @@
},
{
"name": "opsli.waf.url-exclusion",
"sourceType": "org.opsli.core.autoconfigure.GlobalProperties$Waf",
"sourceType": "org.opsli.core.autoconfigure.properties.GlobalProperties$Waf",
"type": "java.util.Set<java.lang.String>",
"description": "软防火墙 过滤器需要排除过滤的路径."
},
{
"name": "opsli.waf.order",
"sourceType": "org.opsli.core.autoconfigure.GlobalProperties$Waf",
"sourceType": "org.opsli.core.autoconfigure.properties.GlobalProperties$Waf",
"type": "java.lang.Integer",
"defaultValue": 0,
"description": "软防火墙 过滤器的优先级,值越小优先级越高."
@ -129,7 +129,7 @@
{
"name": "opsli.web.upload-path",
"sourceType": "org.opsli.core.autoconfigure.GlobalProperties$Web",
"sourceType": "org.opsli.core.autoconfigure.properties.GlobalProperties$Web",
"type": "java.lang.String",
"defaultValue": "",
"description": "Web 上传地址."
@ -139,14 +139,14 @@
{
"name": "opsli.auth.super-admin",
"sourceType": "org.opsli.core.autoconfigure.GlobalProperties$Auth",
"sourceType": "org.opsli.core.autoconfigure.properties.GlobalProperties$Auth",
"type": "java.lang.String",
"defaultValue": "system",
"description": "认证类 超级管理员账户."
},
{
"name": "opsli.auth.default-pass",
"sourceType": "org.opsli.core.autoconfigure.GlobalProperties$Auth",
"sourceType": "org.opsli.core.autoconfigure.properties.GlobalProperties$Auth",
"type": "java.lang.String",
"defaultValue": "Aa123456",
"description": "认证类 默认密码 (密码至少包含大小写字母数字且不少于6位)."
@ -154,42 +154,42 @@
{
"name": "opsli.auth.token.secret",
"sourceType": "org.opsli.core.autoconfigure.GlobalProperties$Auth$Token",
"sourceType": "org.opsli.core.autoconfigure.properties.GlobalProperties$Auth$Token",
"type": "java.lang.String",
"defaultValue": "53c0e33c9d4c5538969abf2fcf48351d",
"description": "认证类 Token 盐值."
},
{
"name": "opsli.auth.token.effective-time",
"sourceType": "org.opsli.core.autoconfigure.GlobalProperties$Auth$Token",
"sourceType": "org.opsli.core.autoconfigure.properties.GlobalProperties$Auth$Token",
"type": "java.lang.Integer",
"defaultValue": 120,
"description": "认证类 Token 有效时间."
},
{
"name": "opsli.auth.token.url-exclusion",
"sourceType": "org.opsli.core.autoconfigure.GlobalProperties$Auth$Token",
"sourceType": "org.opsli.core.autoconfigure.properties.GlobalProperties$Auth$Token",
"type": "java.util.Set<java.lang.String>",
"description": "认证类 Token 排除URL."
},
{
"name": "opsli.auth.login.slip-count",
"sourceType": "org.opsli.core.autoconfigure.GlobalProperties$Auth$Login",
"sourceType": "org.opsli.core.autoconfigure.properties.GlobalProperties$Auth$Login",
"type": "java.lang.Integer",
"defaultValue": 5,
"description": "认证类 登录 失败次数."
},
{
"name": "opsli.auth.login.slip-verify-count",
"sourceType": "org.opsli.core.autoconfigure.GlobalProperties$Auth$Login",
"sourceType": "org.opsli.core.autoconfigure.properties.GlobalProperties$Auth$Login",
"type": "java.lang.Integer",
"defaultValue": 3,
"description": "认证类 登录 失败N次后弹出验证码 (超过验证码阈值 弹出验证码)."
},
{
"name": "opsli.auth.login.slip-lock-speed",
"sourceType": "org.opsli.core.autoconfigure.GlobalProperties$Auth$Login",
"sourceType": "org.opsli.core.autoconfigure.properties.GlobalProperties$Auth$Login",
"type": "java.lang.Integer",
"defaultValue": 300,
"description": "认证类 登录 失败锁定时间(秒)."
@ -199,14 +199,14 @@
{
"name": "opsli.excel.import-max-count",
"sourceType": "org.opsli.core.autoconfigure.GlobalProperties$Excel",
"sourceType": "org.opsli.core.autoconfigure.properties.GlobalProperties$Excel",
"type": "java.lang.Integer",
"defaultValue": 20000,
"description": "Excel 导入最大操作数."
},
{
"name": "opsli.excel.export-max-count",
"sourceType": "org.opsli.core.autoconfigure.GlobalProperties$Excel",
"sourceType": "org.opsli.core.autoconfigure.properties.GlobalProperties$Excel",
"type": "java.lang.Integer",
"defaultValue": 20000,
"description": "Excel 导出最大操作数."

@ -21,7 +21,7 @@ import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.opsli.core.autoconfigure.DbSourceProperties;
import org.opsli.core.autoconfigure.properties.DbSourceProperties;
import org.opsli.core.creater.enums.DataBaseType;
import org.opsli.core.utils.SpringContextHolder;
import org.opsli.modulars.creater.importable.entity.DatabaseColumn;

@ -27,7 +27,7 @@ import org.opsli.api.wrapper.system.user.UserModel;
import org.opsli.common.annotation.ApiRestController;
import org.opsli.common.annotation.EnableLog;
import org.opsli.common.exception.ServiceException;
import org.opsli.core.autoconfigure.GlobalProperties;
import org.opsli.core.autoconfigure.properties.GlobalProperties;
import org.opsli.core.msg.CoreMsg;
import org.opsli.core.utils.UserUtil;
import org.opsli.modulars.system.SystemMsg;
@ -35,7 +35,6 @@ import org.opsli.modulars.system.menu.entity.SysMenu;
import org.opsli.modulars.system.role.service.IRoleMenuRefService;
import org.opsli.modulars.system.role.service.IRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import java.util.List;
import java.util.Map;

@ -24,13 +24,12 @@ import org.opsli.api.wrapper.system.user.UserModel;
import org.opsli.api.wrapper.system.user.UserOrgRefModel;
import org.opsli.common.annotation.ApiRestController;
import org.opsli.common.exception.ServiceException;
import org.opsli.core.autoconfigure.GlobalProperties;
import org.opsli.core.autoconfigure.properties.GlobalProperties;
import org.opsli.core.msg.CoreMsg;
import org.opsli.core.utils.UserUtil;
import org.opsli.modulars.system.SystemMsg;
import org.opsli.modulars.system.user.service.IUserOrgRefService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
/**

@ -24,13 +24,12 @@ import org.opsli.api.wrapper.system.user.UserModel;
import org.opsli.api.wrapper.system.user.UserRoleRefModel;
import org.opsli.common.annotation.ApiRestController;
import org.opsli.common.exception.ServiceException;
import org.opsli.core.autoconfigure.GlobalProperties;
import org.opsli.core.autoconfigure.properties.GlobalProperties;
import org.opsli.core.msg.CoreMsg;
import org.opsli.core.utils.UserUtil;
import org.opsli.modulars.system.SystemMsg;
import org.opsli.modulars.system.user.service.IUserRoleRefService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
/**

Loading…
Cancel
Save