增加默认分页配置

This commit is contained in:
mazhicheng 2020-06-25 21:02:15 +08:00
parent f4b8f9fe07
commit 1693408b73
1 changed files with 13 additions and 1 deletions

View File

@ -18,6 +18,7 @@ package com.diboot.core.starter;
import com.alibaba.fastjson.serializer.SerializerFeature; import com.alibaba.fastjson.serializer.SerializerFeature;
import com.alibaba.fastjson.support.config.FastJsonConfig; import com.alibaba.fastjson.support.config.FastJsonConfig;
import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter; import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import com.diboot.core.config.Cons; import com.diboot.core.config.Cons;
import com.diboot.core.util.DateConverter; import com.diboot.core.util.DateConverter;
import org.mybatis.spring.annotation.MapperScan; import org.mybatis.spring.annotation.MapperScan;
@ -72,7 +73,7 @@ public class CoreAutoConfiguration implements WebMvcConfigurer {
} }
@Bean @Bean
@ConditionalOnMissingBean(HttpMessageConverters.class) @ConditionalOnMissingBean
public HttpMessageConverters fastJsonHttpMessageConverters() { public HttpMessageConverters fastJsonHttpMessageConverters() {
FastJsonHttpMessageConverter converter = new FastJsonHttpMessageConverter(); FastJsonHttpMessageConverter converter = new FastJsonHttpMessageConverter();
converter.setDefaultCharset(Charset.forName(Cons.CHARSET_UTF8)); converter.setDefaultCharset(Charset.forName(Cons.CHARSET_UTF8));
@ -90,6 +91,16 @@ public class CoreAutoConfiguration implements WebMvcConfigurer {
return new HttpMessageConverters(httpMsgConverter); return new HttpMessageConverters(httpMsgConverter);
} }
/**
* Mybatis-plus分页插件
*/
@Bean
@ConditionalOnMissingBean
public PaginationInterceptor paginationInterceptor() {
PaginationInterceptor paginationInterceptor = new PaginationInterceptor();
return paginationInterceptor;
}
/** /**
* 默认支持String-Date类型转换 * 默认支持String-Date类型转换
* @param registry * @param registry
@ -98,4 +109,5 @@ public class CoreAutoConfiguration implements WebMvcConfigurer {
public void addFormatters(FormatterRegistry registry) { public void addFormatters(FormatterRegistry registry) {
registry.addConverter(new DateConverter()); registry.addConverter(new DateConverter());
} }
} }