mirror of
https://gitee.com/log4j/pig.git
synced 2024-12-31 08:14:18 +08:00
⬆️ Upgrading dependencies. 升级 mybatis-plus 3.4.1 支持插件主体配置设置 https://gitee.com/log4j/pig/issues/I24QAB
This commit is contained in:
parent
f42db4eaaf
commit
2f35983fa1
@ -17,16 +17,13 @@
|
||||
package com.pig4cloud.pig.common.core.config;
|
||||
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import com.pig4cloud.pig.common.core.mybatis.SqlFilterArgumentResolver;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.format.FormatterRegistry;
|
||||
import org.springframework.format.datetime.standard.DateTimeFormatterRegistrar;
|
||||
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.List;
|
||||
|
||||
import static org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type.SERVLET;
|
||||
|
||||
@ -40,11 +37,6 @@ import static org.springframework.boot.autoconfigure.condition.ConditionalOnWebA
|
||||
@ConditionalOnWebApplication(type = SERVLET)
|
||||
public class WebMvcConfiguration implements WebMvcConfigurer {
|
||||
|
||||
@Override
|
||||
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
|
||||
argumentResolvers.add(new SqlFilterArgumentResolver());
|
||||
}
|
||||
|
||||
/**
|
||||
* 增加GET请求参数中时间类型转换 {@link com.pig4cloud.pig.common.core.jackson.PigJavaTimeModule}
|
||||
* <ul>
|
||||
|
@ -1,36 +0,0 @@
|
||||
package com.pig4cloud.pig.common.core.mybatis;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @author lengleng
|
||||
* @date 2020/10/12
|
||||
*/
|
||||
public class SqlFilterArgumentResolverTest {
|
||||
|
||||
@Test
|
||||
public void supportsParameter() {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void resolveArgument() {
|
||||
String param = "delete create_time";
|
||||
|
||||
System.out.println(clear(param));
|
||||
}
|
||||
|
||||
private String clear(String param) {
|
||||
if (StrUtil.isBlank(param)) {
|
||||
return StrUtil.trim(param);
|
||||
}
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for (int i = 0; i < param.length(); i++) {
|
||||
char c = param.charAt(i);
|
||||
if (Character.isJavaIdentifierPart(c)) {
|
||||
builder.append(c);
|
||||
}
|
||||
}
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
@ -31,6 +31,12 @@
|
||||
|
||||
|
||||
<dependencies>
|
||||
<!--hutool-->
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-core</artifactId>
|
||||
<version>${hutool.version}</version>
|
||||
</dependency>
|
||||
<!--mybatis-->
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
@ -42,5 +48,15 @@
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
</dependency>
|
||||
<!--server-api-->
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-webmvc</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
@ -16,9 +16,16 @@
|
||||
|
||||
package com.pig4cloud.pig.common.mybatis;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
|
||||
import com.baomidou.mybatisplus.annotation.DbType;
|
||||
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
||||
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
|
||||
import com.pig4cloud.pig.common.mybatis.resolver.SqlFilterArgumentResolver;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author lengleng
|
||||
@ -27,15 +34,25 @@ import org.springframework.context.annotation.Configuration;
|
||||
* mybatis plus 统一配置
|
||||
*/
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
public class MybatisAutoConfiguration {
|
||||
public class MybatisAutoConfiguration implements WebMvcConfigurer {
|
||||
|
||||
/**
|
||||
* 分页插件
|
||||
* @return PaginationInterceptor
|
||||
* SQL 过滤器避免SQL 注入
|
||||
* @param argumentResolvers
|
||||
*/
|
||||
@Override
|
||||
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
|
||||
argumentResolvers.add(new SqlFilterArgumentResolver());
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页插件, 对于单一数据库类型来说,都建议配置该值,避免每次分页都去抓取数据库类型
|
||||
*/
|
||||
@Bean
|
||||
public PaginationInterceptor paginationInterceptor() {
|
||||
return new PaginationInterceptor();
|
||||
public MybatisPlusInterceptor mybatisPlusInterceptor() {
|
||||
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
|
||||
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
|
||||
return interceptor;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -16,7 +16,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
package com.pig4cloud.pig.common.core.mybatis;
|
||||
package com.pig4cloud.pig.common.mybatis.resolver;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
Loading…
Reference in New Issue
Block a user