mirror of
https://github.com/dromara/RuoYi-Vue-Plus.git
synced 2025-11-25 10:16:54 +08:00
Compare commits
5 Commits
554152635d
...
84f17011ad
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
84f17011ad | ||
|
|
f47bd39644 | ||
|
|
89f9617ccb | ||
|
|
bf10a13088 | ||
|
|
f2e0361fb6 |
46
pom.xml
46
pom.xml
@@ -14,12 +14,12 @@
|
|||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<revision>5.4.1</revision>
|
<revision>5.4.1</revision>
|
||||||
<spring-boot.version>3.4.7</spring-boot.version>
|
<spring-boot.version>3.5.4</spring-boot.version>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
<java.version>17</java.version>
|
<java.version>17</java.version>
|
||||||
<mybatis.version>3.5.16</mybatis.version>
|
<mybatis.version>3.5.16</mybatis.version>
|
||||||
<springdoc.version>2.8.8</springdoc.version>
|
<springdoc.version>2.8.9</springdoc.version>
|
||||||
<therapi-javadoc.version>0.15.0</therapi-javadoc.version>
|
<therapi-javadoc.version>0.15.0</therapi-javadoc.version>
|
||||||
<fastexcel.version>1.2.0</fastexcel.version>
|
<fastexcel.version>1.2.0</fastexcel.version>
|
||||||
<velocity.version>2.3</velocity.version>
|
<velocity.version>2.3</velocity.version>
|
||||||
@@ -27,14 +27,14 @@
|
|||||||
<mybatis-plus.version>3.5.12</mybatis-plus.version>
|
<mybatis-plus.version>3.5.12</mybatis-plus.version>
|
||||||
<p6spy.version>3.9.1</p6spy.version>
|
<p6spy.version>3.9.1</p6spy.version>
|
||||||
<hutool.version>5.8.38</hutool.version>
|
<hutool.version>5.8.38</hutool.version>
|
||||||
<spring-boot-admin.version>3.4.7</spring-boot-admin.version>
|
<spring-boot-admin.version>3.5.1</spring-boot-admin.version>
|
||||||
<redisson.version>3.50.0</redisson.version>
|
<redisson.version>3.50.0</redisson.version>
|
||||||
<lock4j.version>2.2.7</lock4j.version>
|
<lock4j.version>2.2.7</lock4j.version>
|
||||||
<dynamic-ds.version>4.3.1</dynamic-ds.version>
|
<dynamic-ds.version>4.3.1</dynamic-ds.version>
|
||||||
<snailjob.version>1.6.0</snailjob.version>
|
<snailjob.version>1.6.0</snailjob.version>
|
||||||
<mapstruct-plus.version>1.4.8</mapstruct-plus.version>
|
<mapstruct-plus.version>1.4.8</mapstruct-plus.version>
|
||||||
<mapstruct-plus.lombok.version>0.2.0</mapstruct-plus.lombok.version>
|
<mapstruct-plus.lombok.version>0.2.0</mapstruct-plus.lombok.version>
|
||||||
<lombok.version>1.18.36</lombok.version>
|
<lombok.version>1.18.38</lombok.version>
|
||||||
<bouncycastle.version>1.80</bouncycastle.version>
|
<bouncycastle.version>1.80</bouncycastle.version>
|
||||||
<justauth.version>1.16.7</justauth.version>
|
<justauth.version>1.16.7</justauth.version>
|
||||||
<!-- 离线IP地址定位库 -->
|
<!-- 离线IP地址定位库 -->
|
||||||
@@ -118,25 +118,6 @@
|
|||||||
<scope>import</scope>
|
<scope>import</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Warm-Flow国产工作流引擎, 在线文档:http://warm-flow.cn/ -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.dromara.warm</groupId>
|
|
||||||
<artifactId>warm-flow-mybatis-plus-sb3-starter</artifactId>
|
|
||||||
<version>${warm-flow.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.dromara.warm</groupId>
|
|
||||||
<artifactId>warm-flow-plugin-ui-sb-web</artifactId>
|
|
||||||
<version>${warm-flow.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- JustAuth 的依赖配置-->
|
|
||||||
<dependency>
|
|
||||||
<groupId>me.zhyd.oauth</groupId>
|
|
||||||
<artifactId>JustAuth</artifactId>
|
|
||||||
<version>${justauth.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- common 的依赖配置-->
|
<!-- common 的依赖配置-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.dromara</groupId>
|
<groupId>org.dromara</groupId>
|
||||||
@@ -313,6 +294,25 @@
|
|||||||
<version>${mapstruct-plus.version}</version>
|
<version>${mapstruct-plus.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Warm-Flow国产工作流引擎, 在线文档:http://warm-flow.cn/ -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.dromara.warm</groupId>
|
||||||
|
<artifactId>warm-flow-mybatis-plus-sb3-starter</artifactId>
|
||||||
|
<version>${warm-flow.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.dromara.warm</groupId>
|
||||||
|
<artifactId>warm-flow-plugin-ui-sb-web</artifactId>
|
||||||
|
<version>${warm-flow.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- JustAuth 的依赖配置-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>me.zhyd.oauth</groupId>
|
||||||
|
<artifactId>JustAuth</artifactId>
|
||||||
|
<version>${justauth.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- 离线IP地址定位库 ip2region -->
|
<!-- 离线IP地址定位库 ip2region -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.lionsoul</groupId>
|
<groupId>org.lionsoul</groupId>
|
||||||
|
|||||||
@@ -57,6 +57,11 @@ spring:
|
|||||||
# 开启虚拟线程 仅jdk21可用
|
# 开启虚拟线程 仅jdk21可用
|
||||||
virtual:
|
virtual:
|
||||||
enabled: false
|
enabled: false
|
||||||
|
task:
|
||||||
|
execution:
|
||||||
|
# 从 springboot 3.5 开始 spring自带线程池
|
||||||
|
# 不再需要 AsyncConfig与ThreadPoolConfig 可直接注入线程池使用
|
||||||
|
thread-name-prefix: async-
|
||||||
# 资源信息
|
# 资源信息
|
||||||
messages:
|
messages:
|
||||||
# 国际化资源文件路径
|
# 国际化资源文件路径
|
||||||
@@ -211,16 +216,6 @@ xss:
|
|||||||
excludeUrls:
|
excludeUrls:
|
||||||
- /system/notice
|
- /system/notice
|
||||||
|
|
||||||
# 全局线程池相关配置
|
|
||||||
# 如使用JDK21请直接使用虚拟线程 不要开启此配置
|
|
||||||
thread-pool:
|
|
||||||
# 是否开启线程池
|
|
||||||
enabled: false
|
|
||||||
# 队列最大长度
|
|
||||||
queueCapacity: 128
|
|
||||||
# 线程池维护线程所允许的空闲时间
|
|
||||||
keepAliveSeconds: 300
|
|
||||||
|
|
||||||
--- # 分布式锁 lock4j 全局配置
|
--- # 分布式锁 lock4j 全局配置
|
||||||
lock4j:
|
lock4j:
|
||||||
# 获取分布式锁超时时间,默认为 3000 毫秒
|
# 获取分布式锁超时时间,默认为 3000 毫秒
|
||||||
|
|||||||
@@ -1,52 +0,0 @@
|
|||||||
package org.dromara.common.core.config;
|
|
||||||
|
|
||||||
import cn.hutool.core.util.ArrayUtil;
|
|
||||||
import org.dromara.common.core.exception.ServiceException;
|
|
||||||
import org.dromara.common.core.utils.SpringUtils;
|
|
||||||
import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;
|
|
||||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
|
||||||
import org.springframework.core.task.VirtualThreadTaskExecutor;
|
|
||||||
import org.springframework.scheduling.annotation.AsyncConfigurer;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.concurrent.Executor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 异步配置
|
|
||||||
* <p>
|
|
||||||
* 如果未使用虚拟线程则生效
|
|
||||||
*
|
|
||||||
* @author Lion Li
|
|
||||||
*/
|
|
||||||
@AutoConfiguration
|
|
||||||
public class AsyncConfig implements AsyncConfigurer {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 自定义 @Async 注解使用系统线程池
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Executor getAsyncExecutor() {
|
|
||||||
if(SpringUtils.isVirtual()) {
|
|
||||||
return new VirtualThreadTaskExecutor("async-");
|
|
||||||
}
|
|
||||||
return SpringUtils.getBean("scheduledExecutorService");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 异步执行异常处理
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
|
|
||||||
return (throwable, method, objects) -> {
|
|
||||||
throwable.printStackTrace();
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
sb.append("Exception message - ").append(throwable.getMessage())
|
|
||||||
.append(", Method name - ").append(method.getName());
|
|
||||||
if (ArrayUtil.isNotEmpty(objects)) {
|
|
||||||
sb.append(", Parameter value - ").append(Arrays.toString(objects));
|
|
||||||
}
|
|
||||||
throw new ServiceException(sb.toString());
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -7,11 +7,9 @@ import org.dromara.common.core.config.properties.ThreadPoolProperties;
|
|||||||
import org.dromara.common.core.utils.SpringUtils;
|
import org.dromara.common.core.utils.SpringUtils;
|
||||||
import org.dromara.common.core.utils.Threads;
|
import org.dromara.common.core.utils.Threads;
|
||||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
|
||||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.core.task.VirtualThreadTaskExecutor;
|
import org.springframework.core.task.VirtualThreadTaskExecutor;
|
||||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
|
||||||
|
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
||||||
@@ -34,18 +32,6 @@ public class ThreadPoolConfig {
|
|||||||
|
|
||||||
private ScheduledExecutorService scheduledExecutorService;
|
private ScheduledExecutorService scheduledExecutorService;
|
||||||
|
|
||||||
@Bean(name = "threadPoolTaskExecutor")
|
|
||||||
@ConditionalOnProperty(prefix = "thread-pool", name = "enabled", havingValue = "true")
|
|
||||||
public ThreadPoolTaskExecutor threadPoolTaskExecutor(ThreadPoolProperties threadPoolProperties) {
|
|
||||||
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
|
|
||||||
executor.setCorePoolSize(core);
|
|
||||||
executor.setMaxPoolSize(core * 2);
|
|
||||||
executor.setQueueCapacity(threadPoolProperties.getQueueCapacity());
|
|
||||||
executor.setKeepAliveSeconds(threadPoolProperties.getKeepAliveSeconds());
|
|
||||||
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
|
|
||||||
return executor;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 执行周期性或定时任务
|
* 执行周期性或定时任务
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
org.dromara.common.core.config.ApplicationConfig
|
org.dromara.common.core.config.ApplicationConfig
|
||||||
org.dromara.common.core.config.AsyncConfig
|
|
||||||
org.dromara.common.core.config.ThreadPoolConfig
|
org.dromara.common.core.config.ThreadPoolConfig
|
||||||
org.dromara.common.core.config.ValidatorConfig
|
org.dromara.common.core.config.ValidatorConfig
|
||||||
org.dromara.common.core.utils.SpringUtils
|
org.dromara.common.core.utils.SpringUtils
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import org.dromara.common.encrypt.properties.ApiDecryptProperties;
|
|||||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||||
|
import org.springframework.boot.web.servlet.FilterRegistration;
|
||||||
import org.springframework.boot.web.servlet.FilterRegistrationBean;
|
import org.springframework.boot.web.servlet.FilterRegistrationBean;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
|
|
||||||
@@ -20,13 +21,14 @@ import org.springframework.context.annotation.Bean;
|
|||||||
public class ApiDecryptAutoConfiguration {
|
public class ApiDecryptAutoConfiguration {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public FilterRegistrationBean<CryptoFilter> cryptoFilterRegistration(ApiDecryptProperties properties) {
|
@FilterRegistration(
|
||||||
FilterRegistrationBean<CryptoFilter> registration = new FilterRegistrationBean<>();
|
name = "cryptoFilter",
|
||||||
registration.setDispatcherTypes(DispatcherType.REQUEST);
|
urlPatterns = "/*",
|
||||||
registration.setFilter(new CryptoFilter(properties));
|
order = FilterRegistrationBean.HIGHEST_PRECEDENCE,
|
||||||
registration.addUrlPatterns("/*");
|
dispatcherTypes = DispatcherType.REQUEST
|
||||||
registration.setName("cryptoFilter");
|
)
|
||||||
registration.setOrder(FilterRegistrationBean.HIGHEST_PRECEDENCE);
|
public CryptoFilter cryptoFilter(ApiDecryptProperties properties) {
|
||||||
return registration;
|
return new CryptoFilter(properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,9 +6,11 @@ import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.reflect.GenericTypeUtils;
|
import com.baomidou.mybatisplus.core.toolkit.reflect.GenericTypeUtils;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.toolkit.Db;
|
import com.baomidou.mybatisplus.extension.toolkit.Db;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
import org.apache.ibatis.logging.Log;
|
import org.apache.ibatis.logging.Log;
|
||||||
import org.apache.ibatis.logging.LogFactory;
|
import org.apache.ibatis.logging.LogFactory;
|
||||||
import org.dromara.common.core.utils.MapstructUtils;
|
import org.dromara.common.core.utils.MapstructUtils;
|
||||||
@@ -130,7 +132,7 @@ public interface BaseMapperPlus<T, V> extends BaseMapper<T> {
|
|||||||
* @return 查询到的单个VO对象
|
* @return 查询到的单个VO对象
|
||||||
*/
|
*/
|
||||||
default V selectVoById(Serializable id) {
|
default V selectVoById(Serializable id) {
|
||||||
return selectVoById(id, this.currentVoClass());
|
return this.selectVoById(id, this.currentVoClass());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -156,7 +158,7 @@ public interface BaseMapperPlus<T, V> extends BaseMapper<T> {
|
|||||||
* @return 查询到的VO对象列表
|
* @return 查询到的VO对象列表
|
||||||
*/
|
*/
|
||||||
default List<V> selectVoByIds(Collection<? extends Serializable> idList) {
|
default List<V> selectVoByIds(Collection<? extends Serializable> idList) {
|
||||||
return selectVoByIds(idList, this.currentVoClass());
|
return this.selectVoByIds(idList, this.currentVoClass());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -182,7 +184,7 @@ public interface BaseMapperPlus<T, V> extends BaseMapper<T> {
|
|||||||
* @return 查询到的VO对象列表
|
* @return 查询到的VO对象列表
|
||||||
*/
|
*/
|
||||||
default List<V> selectVoByMap(Map<String, Object> map) {
|
default List<V> selectVoByMap(Map<String, Object> map) {
|
||||||
return selectVoByMap(map, this.currentVoClass());
|
return this.selectVoByMap(map, this.currentVoClass());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -208,7 +210,7 @@ public interface BaseMapperPlus<T, V> extends BaseMapper<T> {
|
|||||||
* @return 查询到的单个VO对象
|
* @return 查询到的单个VO对象
|
||||||
*/
|
*/
|
||||||
default V selectVoOne(Wrapper<T> wrapper) {
|
default V selectVoOne(Wrapper<T> wrapper) {
|
||||||
return selectVoOne(wrapper, this.currentVoClass());
|
return this.selectVoOne(wrapper, this.currentVoClass());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -219,11 +221,12 @@ public interface BaseMapperPlus<T, V> extends BaseMapper<T> {
|
|||||||
* @return 查询到的单个VO对象
|
* @return 查询到的单个VO对象
|
||||||
*/
|
*/
|
||||||
default V selectVoOne(Wrapper<T> wrapper, boolean throwEx) {
|
default V selectVoOne(Wrapper<T> wrapper, boolean throwEx) {
|
||||||
return selectVoOne(wrapper, this.currentVoClass(), throwEx);
|
return this.selectVoOne(wrapper, this.currentVoClass(), throwEx);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据条件查询单个VO对象,并指定返回的VO对象的类型
|
* 根据条件查询单个VO对象,并指定返回的VO对象的类型(自动拼接 limit 1)
|
||||||
|
* 注意不要再自己添加 limit 1 做限制了
|
||||||
*
|
*
|
||||||
* @param wrapper 查询条件Wrapper
|
* @param wrapper 查询条件Wrapper
|
||||||
* @param voClass 返回的VO对象的Class对象
|
* @param voClass 返回的VO对象的Class对象
|
||||||
@@ -231,11 +234,12 @@ public interface BaseMapperPlus<T, V> extends BaseMapper<T> {
|
|||||||
* @return 查询到的单个VO对象,经过类型转换为指定的VO类后返回
|
* @return 查询到的单个VO对象,经过类型转换为指定的VO类后返回
|
||||||
*/
|
*/
|
||||||
default <C> C selectVoOne(Wrapper<T> wrapper, Class<C> voClass) {
|
default <C> C selectVoOne(Wrapper<T> wrapper, Class<C> voClass) {
|
||||||
return selectVoOne(wrapper, voClass, true);
|
return this.selectVoOne(wrapper, voClass, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据条件查询单个实体对象,并将其转换为指定的VO对象
|
* 根据条件查询单个实体对象,并将其转换为指定的VO对象(自动拼接 limit 1)
|
||||||
|
* 注意不要再自己添加 limit 1 做限制了
|
||||||
*
|
*
|
||||||
* @param wrapper 查询条件Wrapper
|
* @param wrapper 查询条件Wrapper
|
||||||
* @param voClass 要转换的VO类的Class对象
|
* @param voClass 要转换的VO类的Class对象
|
||||||
@@ -251,13 +255,33 @@ public interface BaseMapperPlus<T, V> extends BaseMapper<T> {
|
|||||||
return MapstructUtils.convert(obj, voClass);
|
return MapstructUtils.convert(obj, voClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据条件查询单条记录(自动拼接 limit 1 限制返回 1 条数据,不依赖 {@code throwEx} 参数)
|
||||||
|
* 注意不要再自己添加 limit 1 做限制了
|
||||||
|
* <p>
|
||||||
|
* <strong>注意:</strong>
|
||||||
|
* 1. 使用 {@code Page<>(1, 1)} 强制分页查询,确保 SQL 自动添加 {@code LIMIT 1},因此 {@code throwEx} 参数不再生效
|
||||||
|
* 2. 原方法的 {@code throwEx} 逻辑(多条数据抛异常)已被优化掉,因为分页查询不会返回多条记录
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @param queryWrapper 查询条件(可为 null)
|
||||||
|
* @param throwEx <del>是否抛出异常(已弃用,此参数不再生效)</del>
|
||||||
|
* @return 单条记录或无数据时返回 null
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
default T selectOne(@Param(Constants.WRAPPER) Wrapper<T> queryWrapper, boolean throwEx) {
|
||||||
|
// 强制分页查询(LIMIT 1),确保最多返回 1 条记录
|
||||||
|
List<T> list = this.selectList(new Page<>(1, 1), queryWrapper);
|
||||||
|
return CollUtil.isEmpty(list) ? null : list.get(0);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询所有VO对象列表
|
* 查询所有VO对象列表
|
||||||
*
|
*
|
||||||
* @return 查询到的VO对象列表
|
* @return 查询到的VO对象列表
|
||||||
*/
|
*/
|
||||||
default List<V> selectVoList() {
|
default List<V> selectVoList() {
|
||||||
return selectVoList(new QueryWrapper<>(), this.currentVoClass());
|
return this.selectVoList(new QueryWrapper<>(), this.currentVoClass());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -294,7 +318,7 @@ public interface BaseMapperPlus<T, V> extends BaseMapper<T> {
|
|||||||
* @return 查询到的VO对象分页列表
|
* @return 查询到的VO对象分页列表
|
||||||
*/
|
*/
|
||||||
default <P extends IPage<V>> P selectVoPage(IPage<T> page, Wrapper<T> wrapper) {
|
default <P extends IPage<V>> P selectVoPage(IPage<T> page, Wrapper<T> wrapper) {
|
||||||
return selectVoPage(page, wrapper, this.currentVoClass());
|
return this.selectVoPage(page, wrapper, this.currentVoClass());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import org.dromara.common.web.filter.XssFilter;
|
|||||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||||
|
import org.springframework.boot.web.servlet.FilterRegistration;
|
||||||
import org.springframework.boot.web.servlet.FilterRegistrationBean;
|
import org.springframework.boot.web.servlet.FilterRegistrationBean;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
|
|
||||||
@@ -21,24 +22,20 @@ public class FilterConfig {
|
|||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnProperty(value = "xss.enabled", havingValue = "true")
|
@ConditionalOnProperty(value = "xss.enabled", havingValue = "true")
|
||||||
public FilterRegistrationBean<XssFilter> xssFilterRegistration() {
|
@FilterRegistration(
|
||||||
FilterRegistrationBean<XssFilter> registration = new FilterRegistrationBean<>();
|
name = "xssFilter",
|
||||||
registration.setDispatcherTypes(DispatcherType.REQUEST);
|
urlPatterns = "/*",
|
||||||
registration.setFilter(new XssFilter());
|
order = FilterRegistrationBean.HIGHEST_PRECEDENCE + 1,
|
||||||
registration.addUrlPatterns("/*");
|
dispatcherTypes = DispatcherType.REQUEST
|
||||||
registration.setName("xssFilter");
|
)
|
||||||
registration.setOrder(FilterRegistrationBean.HIGHEST_PRECEDENCE + 1);
|
public XssFilter xssFilter() {
|
||||||
return registration;
|
return new XssFilter();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public FilterRegistrationBean<RepeatableFilter> someFilterRegistration() {
|
@FilterRegistration(name = "repeatableFilter", urlPatterns = "/*")
|
||||||
FilterRegistrationBean<RepeatableFilter> registration = new FilterRegistrationBean<>();
|
public RepeatableFilter repeatableFilter() {
|
||||||
registration.setFilter(new RepeatableFilter());
|
return new RepeatableFilter();
|
||||||
registration.addUrlPatterns("/*");
|
|
||||||
registration.setName("repeatableFilter");
|
|
||||||
registration.setOrder(FilterRegistrationBean.LOWEST_PRECEDENCE);
|
|
||||||
return registration;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package org.dromara.monitor.admin.config;
|
|||||||
import de.codecentric.boot.admin.server.config.AdminServerProperties;
|
import de.codecentric.boot.admin.server.config.AdminServerProperties;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.context.annotation.Scope;
|
|
||||||
import org.springframework.security.config.Customizer;
|
import org.springframework.security.config.Customizer;
|
||||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
||||||
@@ -11,8 +10,7 @@ import org.springframework.security.config.annotation.web.configurers.AbstractHt
|
|||||||
import org.springframework.security.config.annotation.web.configurers.HeadersConfigurer;
|
import org.springframework.security.config.annotation.web.configurers.HeadersConfigurer;
|
||||||
import org.springframework.security.web.SecurityFilterChain;
|
import org.springframework.security.web.SecurityFilterChain;
|
||||||
import org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler;
|
import org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler;
|
||||||
import org.springframework.security.web.servlet.util.matcher.MvcRequestMatcher;
|
import org.springframework.security.web.servlet.util.matcher.PathPatternRequestMatcher;
|
||||||
import org.springframework.web.servlet.handler.HandlerMappingIntrospector;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* admin 监控 安全配置
|
* admin 监控 安全配置
|
||||||
@@ -30,18 +28,18 @@ public class SecurityConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public SecurityFilterChain filterChain(HttpSecurity httpSecurity, MvcRequestMatcher.Builder mvc) throws Exception {
|
public SecurityFilterChain filterChain(HttpSecurity httpSecurity) throws Exception {
|
||||||
SavedRequestAwareAuthenticationSuccessHandler successHandler = new SavedRequestAwareAuthenticationSuccessHandler();
|
SavedRequestAwareAuthenticationSuccessHandler successHandler = new SavedRequestAwareAuthenticationSuccessHandler();
|
||||||
successHandler.setTargetUrlParameter("redirectTo");
|
successHandler.setTargetUrlParameter("redirectTo");
|
||||||
successHandler.setDefaultTargetUrl(adminContextPath + "/");
|
successHandler.setDefaultTargetUrl(adminContextPath + "/");
|
||||||
|
PathPatternRequestMatcher.Builder mvc = PathPatternRequestMatcher.withDefaults();
|
||||||
return httpSecurity
|
return httpSecurity
|
||||||
.headers((header) ->
|
.headers((header) ->
|
||||||
header.frameOptions(HeadersConfigurer.FrameOptionsConfig::disable))
|
header.frameOptions(HeadersConfigurer.FrameOptionsConfig::disable))
|
||||||
.authorizeHttpRequests((authorize) ->
|
.authorizeHttpRequests((authorize) ->
|
||||||
authorize.requestMatchers(
|
authorize.requestMatchers(
|
||||||
mvc.pattern(adminContextPath + "/assets/**"),
|
mvc.matcher(adminContextPath + "/assets/**"),
|
||||||
mvc.pattern(adminContextPath + "/login")
|
mvc.matcher(adminContextPath + "/login")
|
||||||
).permitAll()
|
).permitAll()
|
||||||
.anyRequest().authenticated())
|
.anyRequest().authenticated())
|
||||||
.formLogin((formLogin) ->
|
.formLogin((formLogin) ->
|
||||||
@@ -53,10 +51,4 @@ public class SecurityConfig {
|
|||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Scope("prototype")
|
|
||||||
@Bean
|
|
||||||
public MvcRequestMatcher.Builder mvc(HandlerMappingIntrospector introspector) {
|
|
||||||
return new MvcRequestMatcher.Builder(introspector);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,12 +53,6 @@
|
|||||||
<artifactId>velocity-engine-core</artifactId>
|
<artifactId>velocity-engine-core</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.anyline</groupId>
|
|
||||||
<artifactId>anyline-environment-spring-data-jdbc</artifactId>
|
|
||||||
<version>${anyline.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.anyline</groupId>
|
<groupId>org.anyline</groupId>
|
||||||
<artifactId>anyline-data-jdbc-mysql</artifactId>
|
<artifactId>anyline-data-jdbc-mysql</artifactId>
|
||||||
|
|||||||
Reference in New Issue
Block a user