package tech.easyflow.starter;

import com.mybatisflex.core.FlexGlobalConfig;
import com.mybatisflex.core.audit.AuditManager;
import com.mybatisflex.core.audit.ConsoleMessageCollector;
import com.mybatisflex.core.audit.MessageCollector;
import com.mybatisflex.spring.boot.MyBatisFlexCustomizer;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MybatisConfig implements MyBatisFlexCustomizer {


    @Override
    public void customize(FlexGlobalConfig flexGlobalConfig) {
        //开启审计功能
        AuditManager.setAuditEnable(true);

        // 统一使用标准 0/1 逻辑删除语义。
        flexGlobalConfig.setNormalValueOfLogicDelete(0);
        flexGlobalConfig.setDeletedValueOfLogicDelete(1);

        //取消控制台的 Banner 打印
        flexGlobalConfig.setPrintBanner(false);

        //设置 SQL 审计收集器
        MessageCollector collector = new ConsoleMessageCollector();
        AuditManager.setMessageCollector(collector);
    }
}
