feiyu02
2024-11-19 752e00503f672ddfe2066afb6c235721a3a912b5
src/main/kotlin/cn/flightfeather/supervision/SupervisionApplication.kt
@@ -1,16 +1,22 @@
package cn.flightfeather.supervision
import cn.flightfeather.supervision.timingtask.TaskController
import cn.flightfeather.supervision.common.wx.WxTokenManager
import cn.flightfeather.supervision.bgtask.TaskController
import cn.flightfeather.supervision.websocket.VMRoomWebSocketServer
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.beans.factory.annotation.Value
import org.springframework.boot.ApplicationRunner
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.runApplication
import org.springframework.context.annotation.Bean
import org.springframework.scheduling.annotation.EnableScheduling
@SpringBootApplication
class SupervisionApplication {
@EnableScheduling
class SupervisionApplication(
    @Value("\${mode}") var mode: String,
) {
    @Autowired
    lateinit var webSocketServer: VMRoomWebSocketServer
@@ -18,10 +24,21 @@
    @Autowired
    lateinit var taskController: TaskController
    @Autowired
    lateinit var wxTokenManager: WxTokenManager
    @Bean
    fun runner() = ApplicationRunner {
        webSocketServer.start()
        taskController.run()
        // 2023.8.20 应用于安卓app后台,后续应该合并于小程序后台
        if (mode == "proapp") {
            webSocketServer.start()
        }
        // 应用于微信小程序后台
        else if (mode == "pro") {
            wxTokenManager.run()
        }
        println("mode: $mode")
    }
}