package com.face.global.config;

import com.baomidou.mybatisplus.core.incrementer.DefaultIdentifierGenerator;
import com.baomidou.mybatisplus.core.incrementer.IdentifierGenerator;
import org.springframework.cloud.commons.util.InetUtils;
import org.springframework.cloud.commons.util.InetUtilsProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class IdConfig {

    @Bean
    public IdentifierGenerator identifierGenerator() {
        try (InetUtils inetUtils = new InetUtils(new InetUtilsProperties());){
            return new DefaultIdentifierGenerator(inetUtils.findFirstNonLoopbackAddress());
        }
    }
}
