feiyu02
2024-11-19 752e00503f672ddfe2066afb6c235721a3a912b5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package cn.flightfeather.supervision
 
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
@EnableScheduling
class SupervisionApplication(
    @Value("\${mode}") var mode: String,
) {
 
    @Autowired
    lateinit var webSocketServer: VMRoomWebSocketServer
 
    @Autowired
    lateinit var taskController: TaskController
 
    @Autowired
    lateinit var wxTokenManager: WxTokenManager
 
    @Bean
    fun runner() = ApplicationRunner {
        taskController.run()
        // 2023.8.20 应用于安卓app后台,后续应该合并于小程序后台
        if (mode == "proapp") {
            webSocketServer.start()
        }
        // 应用于微信小程序后台
        else if (mode == "pro") {
            wxTokenManager.run()
        }
        println("mode: $mode")
    }
}
 
fun main(args: Array<String>) {
    runApplication<SupervisionApplication>(*args)
}