Commit 8688d6d9 by fengshuonan

删除swagger开关

parent 14c52954
...@@ -19,7 +19,6 @@ import cn.stylefeng.guns.sys.core.attribute.AttributeSetInteceptor; ...@@ -19,7 +19,6 @@ import cn.stylefeng.guns.sys.core.attribute.AttributeSetInteceptor;
import cn.stylefeng.guns.sys.core.constant.Const; import cn.stylefeng.guns.sys.core.constant.Const;
import cn.stylefeng.guns.sys.core.exception.page.GunsErrorView; import cn.stylefeng.guns.sys.core.exception.page.GunsErrorView;
import cn.stylefeng.guns.sys.core.listener.ConfigListener; import cn.stylefeng.guns.sys.core.listener.ConfigListener;
import cn.stylefeng.guns.sys.core.properties.GunsProperties;
import cn.stylefeng.guns.sys.modular.api.aop.RestApiInteceptor; import cn.stylefeng.guns.sys.modular.api.aop.RestApiInteceptor;
import cn.stylefeng.roses.core.xss.XssFilter; import cn.stylefeng.roses.core.xss.XssFilter;
import com.alibaba.druid.pool.DruidDataSource; import com.alibaba.druid.pool.DruidDataSource;
...@@ -32,7 +31,6 @@ import com.google.code.kaptcha.util.Config; ...@@ -32,7 +31,6 @@ import com.google.code.kaptcha.util.Config;
import org.springframework.aop.Advisor; import org.springframework.aop.Advisor;
import org.springframework.aop.support.DefaultPointcutAdvisor; import org.springframework.aop.support.DefaultPointcutAdvisor;
import org.springframework.aop.support.JdkRegexpMethodPointcut; import org.springframework.aop.support.JdkRegexpMethodPointcut;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.servlet.FilterRegistrationBean; import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.boot.web.servlet.ServletListenerRegistrationBean; import org.springframework.boot.web.servlet.ServletListenerRegistrationBean;
import org.springframework.boot.web.servlet.ServletRegistrationBean; import org.springframework.boot.web.servlet.ServletRegistrationBean;
...@@ -54,20 +52,15 @@ import java.util.Properties; ...@@ -54,20 +52,15 @@ import java.util.Properties;
@Configuration @Configuration
public class WebConfig implements WebMvcConfigurer { public class WebConfig implements WebMvcConfigurer {
@Autowired
private GunsProperties gunsProperties;
/** /**
* 静态资源映射 * 静态资源映射
*/ */
@Override @Override
public void addResourceHandlers(ResourceHandlerRegistry registry) { public void addResourceHandlers(ResourceHandlerRegistry registry) {
if (gunsProperties.getSwaggerOpen()) {
//swagger //swagger
registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/"); registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/");
registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/"); registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
}
//本应用 //本应用
registry.addResourceHandler("/assets/**").addResourceLocations("classpath:/assets/"); registry.addResourceHandler("/assets/**").addResourceLocations("classpath:/assets/");
......
...@@ -38,7 +38,7 @@ public interface Const { ...@@ -38,7 +38,7 @@ public interface Const {
String DEFAULT_WELCOME_TIP = "欢迎使用Guns快速开发平台!"; String DEFAULT_WELCOME_TIP = "欢迎使用Guns快速开发平台!";
/** /**
* 系统默认的管理员密码 * 重置密码
*/ */
String DEFAULT_PWD = "111111"; String DEFAULT_PWD = "111111";
...@@ -58,11 +58,6 @@ public interface Const { ...@@ -58,11 +58,6 @@ public interface Const {
Long ADMIN_ROLE_ID = 1L; Long ADMIN_ROLE_ID = 1L;
/** /**
* 接口文档的菜单名
*/
String API_MENU_NAME = "接口文档";
/**
* 不需要权限验证的资源表达式 * 不需要权限验证的资源表达式
*/ */
List<String> NONE_PERMISSION_RES = CollectionUtil.newLinkedList("/assets/**", "/gunsApi/**", "/login", "/global/sessionError", "/kaptcha", "/error", "/global/error", "/oauth/**"); List<String> NONE_PERMISSION_RES = CollectionUtil.newLinkedList("/assets/**", "/gunsApi/**", "/login", "/global/sessionError", "/kaptcha", "/error", "/global/error", "/oauth/**");
......
...@@ -35,8 +35,6 @@ public class GunsProperties { ...@@ -35,8 +35,6 @@ public class GunsProperties {
private Boolean kaptchaOpen = false; private Boolean kaptchaOpen = false;
private Boolean swaggerOpen = false;
private String fileUploadPath; private String fileUploadPath;
private Boolean haveCreatePath = false; private Boolean haveCreatePath = false;
...@@ -54,14 +52,17 @@ public class GunsProperties { ...@@ -54,14 +52,17 @@ public class GunsProperties {
private Integer sessionValidationInterval = 15 * 60; private Integer sessionValidationInterval = 15 * 60;
public String getFileUploadPath() { public String getFileUploadPath() {
//如果没有写文件上传路径,保存到临时目录 //如果没有写文件上传路径,保存到临时目录
if (ToolUtil.isEmpty(fileUploadPath)) { if (ToolUtil.isEmpty(fileUploadPath)) {
return getTempPath(); return getTempPath();
} else { } else {
//判断有没有结尾符,没有得加上 //判断有没有结尾符,没有得加上
if (!fileUploadPath.endsWith(File.separator)) { if (!fileUploadPath.endsWith(File.separator)) {
fileUploadPath = fileUploadPath + File.separator; fileUploadPath = fileUploadPath + File.separator;
} }
//判断目录存不存在,不存在得加上 //判断目录存不存在,不存在得加上
if (!haveCreatePath) { if (!haveCreatePath) {
File file = new File(fileUploadPath); File file = new File(fileUploadPath);
......
/**
* Copyright 2018-2020 stylefeng & fengshuonan (https://gitee.com/stylefeng)
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.stylefeng.guns.sys.core.util;
import cn.stylefeng.guns.base.pojo.node.MenuNode;
import cn.stylefeng.guns.sys.core.constant.Const;
import cn.stylefeng.guns.sys.core.properties.GunsProperties;
import cn.stylefeng.roses.core.util.SpringContextHolder;
import java.util.ArrayList;
import java.util.List;
/**
* api接口文档显示过滤
*
* @author fengshuonan
* @date 2017-08-17 16:55
*/
public class ApiMenuFilter extends MenuNode {
public static List<MenuNode> build(List<MenuNode> nodes) {
//如果关闭了接口文档,则不显示接口文档菜单
GunsProperties gunsProperties = SpringContextHolder.getBean(GunsProperties.class);
if (!gunsProperties.getSwaggerOpen()) {
List<MenuNode> menuNodesCopy = new ArrayList<>();
for (MenuNode menuNode : nodes) {
if (Const.API_MENU_NAME.equals(menuNode.getName())) {
continue;
} else {
menuNodesCopy.add(menuNode);
}
}
nodes = menuNodesCopy;
}
return nodes;
}
}
...@@ -11,7 +11,6 @@ import cn.stylefeng.guns.sys.core.constant.state.ManagerStatus; ...@@ -11,7 +11,6 @@ import cn.stylefeng.guns.sys.core.constant.state.ManagerStatus;
import cn.stylefeng.guns.sys.core.exception.enums.BizExceptionEnum; import cn.stylefeng.guns.sys.core.exception.enums.BizExceptionEnum;
import cn.stylefeng.guns.sys.core.shiro.ShiroKit; import cn.stylefeng.guns.sys.core.shiro.ShiroKit;
import cn.stylefeng.guns.sys.core.shiro.service.UserAuthService; import cn.stylefeng.guns.sys.core.shiro.service.UserAuthService;
import cn.stylefeng.guns.sys.core.util.ApiMenuFilter;
import cn.stylefeng.guns.sys.modular.system.entity.User; import cn.stylefeng.guns.sys.modular.system.entity.User;
import cn.stylefeng.guns.sys.modular.system.factory.UserFactory; import cn.stylefeng.guns.sys.modular.system.factory.UserFactory;
import cn.stylefeng.guns.sys.modular.system.mapper.UserMapper; import cn.stylefeng.guns.sys.modular.system.mapper.UserMapper;
...@@ -177,8 +176,7 @@ public class UserService extends ServiceImpl<UserMapper, User> { ...@@ -177,8 +176,7 @@ public class UserService extends ServiceImpl<UserMapper, User> {
return new ArrayList<>(); return new ArrayList<>();
} else { } else {
List<MenuNode> menus = menuService.getMenusByRoleIds(roleList); List<MenuNode> menus = menuService.getMenusByRoleIds(roleList);
List<MenuNode> titles = MenuNode.buildTitle(menus); return MenuNode.buildTitle(menus);
return ApiMenuFilter.build(titles);
} }
} }
......
...@@ -3,7 +3,6 @@ server: ...@@ -3,7 +3,6 @@ server:
max-http-header-size: 10240 max-http-header-size: 10240
guns: guns:
swagger-open: true #是否开启swagger (true/false)
kaptcha-open: false #是否开启登录时验证码 (true/false) kaptcha-open: false #是否开启登录时验证码 (true/false)
spring-session-open: false #是否开启spring session,如果是多机环境需要开启(true/false) spring-session-open: false #是否开启spring session,如果是多机环境需要开启(true/false)
session-invalidate-time: 1800 #session失效时间(只在单机环境下生效,多机环境在SpringSessionConfig类中配置) 单位:秒 session-invalidate-time: 1800 #session失效时间(只在单机环境下生效,多机环境在SpringSessionConfig类中配置) 单位:秒
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment