package com.mcwl;

import com.fasterxml.jackson.databind.SerializationFeature;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.amqp.support.converter.MessageConverter;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;

/**
 * 启动程序
 *
 * @author mcwl
 */
@EnableConfigurationProperties
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
public class McWlApplication
{
    public static void main(String[] args)
    {
        SpringApplication.run(McWlApplication.class, args);
        System.out.println("(♥◠‿◠)ﾉﾞ  魔创未来启动成功   ლ(´ڡ`ლ)ﾞ  ");
    }

    // 序列化枚举值为前端返回值
    @Bean
    public Jackson2ObjectMapperBuilderCustomizer customizer() {
        return builder -> builder.featuresToEnable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
    }

    // mq 消息转换器
    @Bean
    public MessageConverter jacksonMessageConverter() {
        return new Jackson2JsonMessageConverter();
    }
}
