pull/346/head
parent
50d4180e4d
commit
2ab12ec2a7
@ -0,0 +1,20 @@
|
|||||||
|
package com.ruoyi.web.admin.config;
|
||||||
|
|
||||||
|
import org.springframework.boot.autoconfigure.web.servlet.WebMvcRegistrations;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自动补全路由前缀配置类
|
||||||
|
* @author 1763113879@qq.com
|
||||||
|
* @version V2.1
|
||||||
|
* @since 2.1.0 2023/11/15 14:48
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class AutoPrefixConfiguration implements WebMvcRegistrations {
|
||||||
|
@Override
|
||||||
|
public RequestMappingHandlerMapping getRequestMappingHandlerMapping() {
|
||||||
|
return new AutoPrefixUrlMapping();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,84 @@
|
|||||||
|
package com.ruoyi.web.admin.config;
|
||||||
|
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
import org.springframework.web.servlet.mvc.method.RequestMappingInfo;
|
||||||
|
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 按照目录结构/包名添加前缀
|
||||||
|
*
|
||||||
|
* @author 1763113879@qq.com
|
||||||
|
* @version V2.1
|
||||||
|
* @since 2.1.0 2023/11/15 14:20
|
||||||
|
*/
|
||||||
|
public class AutoPrefixUrlMapping extends RequestMappingHandlerMapping {
|
||||||
|
|
||||||
|
// 路由映射
|
||||||
|
static Map<String, String> routesMap = new HashMap<String, String>();
|
||||||
|
|
||||||
|
static {
|
||||||
|
// # 认证中心 uri: lb://ruoyi-auth
|
||||||
|
routesMap.put("com.ruoyi.auth.controller", "/auth");
|
||||||
|
// # 代码生成 uri: lb://ruoyi-gen
|
||||||
|
routesMap.put("com.ruoyi.gen.controller", "/code");
|
||||||
|
// # 定时任务 uri: lb://ruoyi-job
|
||||||
|
routesMap.put("com.ruoyi.job.controller", "/schedule");
|
||||||
|
// # 系统模块 uri: lb://ruoyi-system
|
||||||
|
routesMap.put("com.ruoyi.system.controller", "/system");
|
||||||
|
// # 文件服务 uri: lb://ruoyi-file
|
||||||
|
routesMap.put("com.ruoyi.file.controller", "/file");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 重写方法路由获取
|
||||||
|
*
|
||||||
|
* @param method
|
||||||
|
* @param handlerType
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected RequestMappingInfo getMappingForMethod(Method method, Class<?> handlerType) {
|
||||||
|
RequestMappingInfo mappingInfo = super.getMappingForMethod(method, handlerType);
|
||||||
|
|
||||||
|
if (Objects.nonNull(mappingInfo)) {
|
||||||
|
String prefix = this.getPrefix(handlerType);
|
||||||
|
|
||||||
|
if (prefix != null) {
|
||||||
|
String[] paths = mappingInfo.getPatternValues()
|
||||||
|
.stream()
|
||||||
|
.map(path -> prefix + path)
|
||||||
|
.toArray(String[]::new);
|
||||||
|
|
||||||
|
return mappingInfo.mutate()
|
||||||
|
.paths(paths)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return mappingInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取方法路由前缀
|
||||||
|
*
|
||||||
|
* @param handleType
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private String getPrefix(Class<?> handleType) {
|
||||||
|
String packageName = handleType.getPackage()
|
||||||
|
.getName();
|
||||||
|
// 使用foreach循环遍历HashMap 符合路由规则的添加前缀
|
||||||
|
for (String key : routesMap.keySet()) {
|
||||||
|
if (packageName.startsWith(key)) {
|
||||||
|
return routesMap.get(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,61 +0,0 @@
|
|||||||
# 数据源配置
|
|
||||||
spring:
|
|
||||||
datasource:
|
|
||||||
type: com.alibaba.druid.pool.DruidDataSource
|
|
||||||
driverClassName: com.mysql.cj.jdbc.Driver
|
|
||||||
druid:
|
|
||||||
# 主库数据源
|
|
||||||
master:
|
|
||||||
url: jdbc:mysql://localhost:3306/ry-config?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
|
|
||||||
username: root
|
|
||||||
password: chenroot
|
|
||||||
# 从库数据源
|
|
||||||
slave:
|
|
||||||
# 从数据源开关/默认关闭
|
|
||||||
enabled: false
|
|
||||||
url:
|
|
||||||
username:
|
|
||||||
password:
|
|
||||||
# 初始连接数
|
|
||||||
initialSize: 5
|
|
||||||
# 最小连接池数量
|
|
||||||
minIdle: 10
|
|
||||||
# 最大连接池数量
|
|
||||||
maxActive: 20
|
|
||||||
# 配置获取连接等待超时的时间
|
|
||||||
maxWait: 60000
|
|
||||||
# 配置连接超时时间
|
|
||||||
connectTimeout: 30000
|
|
||||||
# 配置网络超时时间
|
|
||||||
socketTimeout: 60000
|
|
||||||
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
|
|
||||||
timeBetweenEvictionRunsMillis: 60000
|
|
||||||
# 配置一个连接在池中最小生存的时间,单位是毫秒
|
|
||||||
minEvictableIdleTimeMillis: 300000
|
|
||||||
# 配置一个连接在池中最大生存的时间,单位是毫秒
|
|
||||||
maxEvictableIdleTimeMillis: 900000
|
|
||||||
# 配置检测连接是否有效
|
|
||||||
validationQuery: SELECT 1 FROM DUAL
|
|
||||||
testWhileIdle: true
|
|
||||||
testOnBorrow: false
|
|
||||||
testOnReturn: false
|
|
||||||
webStatFilter:
|
|
||||||
enabled: true
|
|
||||||
statViewServlet:
|
|
||||||
enabled: true
|
|
||||||
# 设置白名单,不填则允许所有访问
|
|
||||||
allow:
|
|
||||||
url-pattern: /druid/*
|
|
||||||
# 控制台管理用户名和密码
|
|
||||||
login-username: ruoyi
|
|
||||||
login-password: 123456
|
|
||||||
filter:
|
|
||||||
stat:
|
|
||||||
enabled: true
|
|
||||||
# 慢SQL记录
|
|
||||||
log-slow-sql: true
|
|
||||||
slow-sql-millis: 1000
|
|
||||||
merge-sql: true
|
|
||||||
wall:
|
|
||||||
config:
|
|
||||||
multi-statement-allow: true
|
|
@ -0,0 +1,79 @@
|
|||||||
|
# Tomcat
|
||||||
|
server:
|
||||||
|
port: 8080
|
||||||
|
|
||||||
|
# Spring
|
||||||
|
spring:
|
||||||
|
application:
|
||||||
|
# 应用名称
|
||||||
|
name: ruoyi-web-admin
|
||||||
|
profiles:
|
||||||
|
# 环境配置
|
||||||
|
active: local
|
||||||
|
|
||||||
|
# Spring Web 公共配置
|
||||||
|
autoconfigure:
|
||||||
|
exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure
|
||||||
|
mvc:
|
||||||
|
pathmatch:
|
||||||
|
matching-strategy: ant_path_matcher
|
||||||
|
cloud:
|
||||||
|
gateway:
|
||||||
|
discovery:
|
||||||
|
locator:
|
||||||
|
lowerCaseServiceId: true
|
||||||
|
enabled: true
|
||||||
|
|
||||||
|
# feign 配置
|
||||||
|
feign:
|
||||||
|
sentinel:
|
||||||
|
enabled: true
|
||||||
|
okhttp:
|
||||||
|
enabled: true
|
||||||
|
httpclient:
|
||||||
|
enabled: false
|
||||||
|
client:
|
||||||
|
config:
|
||||||
|
default:
|
||||||
|
connectTimeout: 10000
|
||||||
|
readTimeout: 10000
|
||||||
|
compression:
|
||||||
|
request:
|
||||||
|
enabled: true
|
||||||
|
response:
|
||||||
|
enabled: true
|
||||||
|
|
||||||
|
# 暴露监控端点
|
||||||
|
management:
|
||||||
|
endpoints:
|
||||||
|
web:
|
||||||
|
exposure:
|
||||||
|
include: '*'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# 安全配置
|
||||||
|
security:
|
||||||
|
# 验证码
|
||||||
|
captcha:
|
||||||
|
enabled: true
|
||||||
|
type: math
|
||||||
|
# 防止XSS攻击
|
||||||
|
xss:
|
||||||
|
enabled: true
|
||||||
|
excludeUrls:
|
||||||
|
- /system/notice
|
||||||
|
# 不校验白名单
|
||||||
|
ignore:
|
||||||
|
whites:
|
||||||
|
- /auth/logout
|
||||||
|
- /auth/login
|
||||||
|
- /auth/register
|
||||||
|
- /*/v2/api-docs
|
||||||
|
- /csrf
|
||||||
|
|
||||||
|
# swagger配置
|
||||||
|
swagger:
|
||||||
|
title: 系统模块接口文档
|
||||||
|
license: Powered By ruoyi
|
||||||
|
licenseUrl: https://ruoyi.vip
|
Loading…
Reference in new issue