All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.dromara.trans.config.EasyTransMybatisPlusConfig Maven / Gradle / Ivy

There is a newer version: 3.1.1
Show newest version
package org.dromara.trans.config;

import com.baomidou.mybatisplus.annotation.TableId;
import org.dromara.core.trans.util.ReflectUtils;
import org.dromara.trans.extend.MybatisPlusSimpleTransDiver;
import org.dromara.trans.extend.MybatisPlusTransableRegister;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

/**
 * mybatis plus适配器
 *
 * @author wanglei
 */
@Slf4j
@Configuration
public class EasyTransMybatisPlusConfig {

    /**
     * service的包路径
     */
    @Value("${easy-trans.autotrans.package:com.*.*.service.impl}")
    private String packageNames;

    @Bean
    @ConditionalOnProperty(name = "easy-trans.is-enable-auto", havingValue = "true")
    public MybatisPlusTransableRegister mybatisPlusTransableRegister() {
        MybatisPlusTransableRegister result = new MybatisPlusTransableRegister();
        result.setPackageNames(packageNames);
        return result;
    }

    @Bean
    @Primary
    public MybatisPlusSimpleTransDiver MybatisPlusSimpleTransDiver() {
        ReflectUtils.ID_ANNO.add(TableId.class);
        return new MybatisPlusSimpleTransDiver();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy