package com.jkcredit.invoice;

import com.jkcredit.invoice.credit.SimpleCoreFilter;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.server.ConfigurableWebServerFactory;
import org.springframework.boot.web.server.ErrorPage;
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.http.HttpStatus;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;

/**
 * 应用启动器
 * @author mumuxigua
 */
@EnableAsync
@EnableScheduling
@SpringBootApplication
public class SysInvoiceApplication {

    public static void main(String[] args) {
        SpringApplication.run(SysInvoiceApplication.class, args);
    }


    /**
     * 跨域处理
     *
     * @return
     */
    @Bean
    public SimpleCoreFilter simpleCoreFilter(){
        return new SimpleCoreFilter();
    }
    @Bean
    public WebServerFactoryCustomizer<ConfigurableWebServerFactory> webServerFactoryWebServerFactoryCustomizer(){
        return factory -> {
            ErrorPage errorPage = new ErrorPage(HttpStatus.NOT_FOUND,"/index.html");
            factory.addErrorPages(errorPage);
        };
    }
}
