From 1096001a22aec93423c0a2b6cd6ccab1924c5b02 Mon Sep 17 00:00:00 2001 From: wj <1285151836@qq.com> Date: Sun, 23 Apr 2023 16:47:25 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8=E6=88=B7=E6=95=B0=E6=8D=AE=E5=90=8C?= =?UTF-8?q?=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/config/MasterDataSourceConfig.java | 28 ++++++++++++++++++- .../admin/constant/BasicExportTypeEnum.java | 5 ++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/api-admin/src/main/java/com/glxp/sale/admin/config/MasterDataSourceConfig.java b/api-admin/src/main/java/com/glxp/sale/admin/config/MasterDataSourceConfig.java index 70f418d..15f713f 100644 --- a/api-admin/src/main/java/com/glxp/sale/admin/config/MasterDataSourceConfig.java +++ b/api-admin/src/main/java/com/glxp/sale/admin/config/MasterDataSourceConfig.java @@ -1,5 +1,9 @@ package com.glxp.sale.admin.config; +import com.baomidou.mybatisplus.core.MybatisConfiguration; +import com.baomidou.mybatisplus.core.config.GlobalConfig; +import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; +import com.baomidou.mybatisplus.extension.plugins.inner.BlockAttackInnerInterceptor; import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean; import org.apache.ibatis.session.SqlSessionFactory; import org.mybatis.spring.SqlSessionFactoryBean; @@ -36,14 +40,36 @@ public class MasterDataSourceConfig {//TODO Mapper return new DataSourceTransactionManager(masterDataSource()); } + + @Configuration + @ConfigurationProperties(prefix = "mybatis-plus.configuration") + public class CusMybatisConfiguration extends MybatisConfiguration{ + } + @Configuration + @ConfigurationProperties(prefix = "mybatis-plus.global-config") + public class CusGlobalConfig extends GlobalConfig { + } + @Bean(name = "masterSqlSessionFactory") @Primary - public SqlSessionFactory masterSqlSessionFactory(@Qualifier("masterDataSource") DataSource masterDataSource) + public SqlSessionFactory masterSqlSessionFactory(@Qualifier("masterDataSource") DataSource masterDataSource, CusMybatisConfiguration configuration, CusGlobalConfig globalConfig) throws Exception { final MybatisSqlSessionFactoryBean sessionFactory = new MybatisSqlSessionFactoryBean(); sessionFactory.setDataSource(masterDataSource); + sessionFactory.setConfiguration((MybatisConfiguration) configuration); + sessionFactory.setGlobalConfig(globalConfig); sessionFactory.setMapperLocations(new PathMatchingResourcePatternResolver() .getResources(MasterDataSourceConfig.MAPPER_LOCATION)); return sessionFactory.getObject(); } + + /** + * 防全表更新与删除插件 + */ + @Bean + public MybatisPlusInterceptor mybatisPlusInterceptor() { + MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); + interceptor.addInnerInterceptor(new BlockAttackInnerInterceptor()); + return interceptor; + } } diff --git a/api-admin/src/main/java/com/glxp/sale/admin/constant/BasicExportTypeEnum.java b/api-admin/src/main/java/com/glxp/sale/admin/constant/BasicExportTypeEnum.java index b6cef9d..ae03561 100644 --- a/api-admin/src/main/java/com/glxp/sale/admin/constant/BasicExportTypeEnum.java +++ b/api-admin/src/main/java/com/glxp/sale/admin/constant/BasicExportTypeEnum.java @@ -26,6 +26,11 @@ public enum BasicExportTypeEnum { * 其他数据 */ OTHER_DATA("other_data", "其他数据"), + + /** + * 用户数据 + */ + USER_DATA("user_data", "用户数据"), ; private String key;