/*
 * ********************************************************************************************************************
 *
 *                     :*$@@%$*:                         ;:                ;;    ;;
 *                   :@@%!  :!@@%:                       %!             ;%%@@%$ =@@@@@@@%;     @%@@@%%%%@@@@@
 *                  :@%;       :$=                       %%$$$%$$         ;$$  ;$@=   !@$
 *                  =@!                                  %!              @ $=;%   !@@@%:      !$$$$$$$$$$$$$$=
 *                  =@*                                  %!              @ $= % %@=   =%@!      %=
 *             *$%%! @@=        ;=$%%%$*:                %!              @ $= % =%%%%%%@$      *%:         =%
 *           %@@!:    !@@@%=$@@@@%!  :*@@$:              %!              @ $= % $*     ;@      @*          :%*
 *         ;@@!          ;!!!;:         ;@%:      =======@%========*     @ $$ % $%*****$@     :@$=*********=@$
 *         $@*   ;@@@%=!:                *@*
 *         =@$    ;;;!=%@@@@=!           =@!
 *          %@$:      =@%: :*@@@*       %@=                    Copyright (c) 2016-2019.  北京上格云技术有限公司
 *           ;%@@$=$@@%*       *@@@$=%@@%;
 *              ::;::             ::;::                                              All rights reserved.
 *
 * ********************************************************************************************************************
 */

package com.persagy.server

import com.persagy.service.json.SJsonHttpMessageConverter
import org.mybatis.spring.annotation.MapperScan
import org.slf4j.LoggerFactory
import org.springframework.boot.SpringApplication
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.builder.SpringApplicationBuilder
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.ComponentScan
import org.springframework.scheduling.annotation.EnableScheduling

/**
 * 应用配置
 *
 * @author  Andy
 */
@ComponentScan(basePackages = ["com.persagy"])           // 配置组件扫描路径
@MapperScan("com.persagy")                       // Mapper组件扫描路径
//@EnableEurekaClient
//@EnableDiscoveryClient
@SpringBootApplication
@EnableScheduling
open class EquipComponentApp : SpringBootServletInitializer() {
    companion object {
        // 日志
        private val logger = LoggerFactory.getLogger(EquipComponentApp::class.java)
    } // Companion object

    /**
     * 配置应用
     *
     * @param   application     应用构建对象
     */
    override fun configure(application: SpringApplicationBuilder): SpringApplicationBuilder {
        return application.sources(EquipComponentApp::class.java)
    } // Function configure

    /**
     * 配置FastJson
     *
     * @return  HttpMessageConverters
     */
    @Bean
    @Suppress("MoveLambdaOutsideParentheses")
    open fun jsonHttpMessageConverters(): SJsonHttpMessageConverter {
        val fastConverter = SJsonHttpMessageConverter()
        fastConverter.propertyNamingStrategy = com.alibaba.fastjson.PropertyNamingStrategy.PascalCase
        return fastConverter
    } // Function fastJsonHttpMessageConverters()

} // Class Application

/**
 * Web应用入口
 *
 * @param   args        命令行参数
 */
fun main(args: Array<String>) {
    SpringApplication.run(EquipComponentApp::class.java, *args)
    return
} // Function main()
