| | |
| | | package com.moral.api.config.mybatis; |
| | | |
| | | import com.baomidou.mybatisplus.core.parser.ISqlParser; |
| | | import com.baomidou.mybatisplus.extension.parsers.DynamicTableNameParser; |
| | | import com.baomidou.mybatisplus.extension.parsers.ITableNameHandler; |
| | | import com.baomidou.mybatisplus.annotation.DbType; |
| | | import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; |
| | | import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor; |
| | | import com.baomidou.mybatisplus.extension.plugins.handler.TableNameHandler; |
| | | import com.baomidou.mybatisplus.extension.plugins.inner.DynamicTableNameInnerInterceptor; |
| | | import org.apache.ibatis.reflection.MetaObject; |
| | | import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | |
| | |
| | | public class MybatisPlusConfig { |
| | | |
| | | /** |
| | | * 分页插件 |
| | | */ |
| | | @Bean |
| | | public PaginationInterceptor paginationInterceptor() { |
| | | PaginationInterceptor paginationInterceptor = new PaginationInterceptor(); |
| | | return paginationInterceptor; |
| | | } |
| | | |
| | | /** |
| | | * @Description: 设置动态表名 |
| | | * @Param: [] |
| | | * @return: com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor |
| | |
| | | @Bean |
| | | public MybatisPlusInterceptor mybatisPlusInterceptor(){ |
| | | MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); |
| | | //分页插件 |
| | | interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL)); |
| | | DynamicTableNameInnerInterceptor dynamicTableNameInnerInterceptor = new DynamicTableNameInnerInterceptor(); |
| | | HashMap<String, TableNameHandler> map = new HashMap<String, TableNameHandler>(); |
| | | map.put("history_five_minutely",(sql,tableName)->{ Date date = new Date(); |