|
|
|
@ -1,9 +1,12 @@
|
|
|
|
|
package org.dromara.common.mybatis.config;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.net.NetUtil;
|
|
|
|
|
import com.baomidou.mybatisplus.autoconfigure.DdlApplicationRunner;
|
|
|
|
|
import com.baomidou.mybatisplus.autoconfigure.MybatisPlusAutoConfiguration;
|
|
|
|
|
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
|
|
|
|
|
import com.baomidou.mybatisplus.core.incrementer.DefaultIdentifierGenerator;
|
|
|
|
|
import com.baomidou.mybatisplus.core.incrementer.IdentifierGenerator;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.ddl.IDdl;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
|
|
|
|
@ -11,19 +14,21 @@ import org.dromara.common.core.factory.YmlPropertySourceFactory;
|
|
|
|
|
import org.dromara.common.mybatis.handler.InjectionMetaObjectHandler;
|
|
|
|
|
import org.dromara.common.mybatis.interceptor.PlusDataPermissionInterceptor;
|
|
|
|
|
import org.mybatis.spring.annotation.MapperScan;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
|
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
|
|
import org.springframework.context.annotation.Primary;
|
|
|
|
|
import org.springframework.context.annotation.PropertySource;
|
|
|
|
|
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
|
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* mybatis-plus配置类(下方注释有插件介绍)
|
|
|
|
|
*
|
|
|
|
|
* @author Lion Li
|
|
|
|
|
*/
|
|
|
|
|
@AutoConfiguration
|
|
|
|
|
@EnableTransactionManagement(proxyTargetClass = true)
|
|
|
|
|
@AutoConfiguration(before = MybatisPlusAutoConfiguration.class)
|
|
|
|
|
@MapperScan("${mybatis-plus.mapperPackage}")
|
|
|
|
|
@PropertySource(value = "classpath:common-mybatis.yml", factory = YmlPropertySourceFactory.class)
|
|
|
|
|
public class MybatisPlusConfiguration {
|
|
|
|
@ -78,7 +83,6 @@ public class MybatisPlusConfiguration {
|
|
|
|
|
* 使用网卡信息绑定雪花生成器
|
|
|
|
|
* 防止集群雪花ID重复
|
|
|
|
|
*/
|
|
|
|
|
@Primary
|
|
|
|
|
@Bean
|
|
|
|
|
public IdentifierGenerator idGenerator() {
|
|
|
|
|
return new DefaultIdentifierGenerator(NetUtil.getLocalhost());
|
|
|
|
@ -104,4 +108,9 @@ public class MybatisPlusConfiguration {
|
|
|
|
|
* https://baomidou.com/pages/2a45ff/
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
@Bean
|
|
|
|
|
public DdlApplicationRunner ddlApplicationRunner(@Autowired(required = false) List<IDdl> ddlList) {
|
|
|
|
|
return new DdlApplicationRunner(ddlList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|