Skip to content

Commit f940454

Browse files
committed
feat: conditional lark components
1 parent 23ecb15 commit f940454

File tree

5 files changed

+9
-0
lines changed

5 files changed

+9
-0
lines changed

src/main/kotlin/cn/scutbot/sim/rmdispatcher/config/LarkConfig.kt

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import java.util.concurrent.TimeUnit
1212
@Configuration
1313
@ConfigurationProperties(prefix = "lark")
1414
data class LarkConfig(
15+
var enabled: Boolean = false,
1516
var appId: String = "",
1617
var appSecret: String = "",
1718
var cardId: String = "",

src/main/kotlin/cn/scutbot/sim/rmdispatcher/controllers/MatchController.kt

+2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ package cn.scutbot.sim.rmdispatcher.controllers
22

33
import cn.scutbot.sim.rmdispatcher.service.IMatchService
44
import org.springframework.beans.factory.annotation.Autowired
5+
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
56
import org.springframework.web.bind.annotation.GetMapping
67
import org.springframework.web.bind.annotation.RequestParam
78
import org.springframework.web.bind.annotation.RestController
89

910
@RestController("/match")
11+
@ConditionalOnProperty(prefix = "lark", name = ["enabled"], havingValue = "true")
1012
class MatchController(
1113
@Autowired val matchService: IMatchService
1214
) {

src/main/kotlin/cn/scutbot/sim/rmdispatcher/listener/impl/LarkMatchEndListener.kt

+2
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@ import cn.scutbot.sim.rmdispatcher.service.IMatchService
1010
import cn.scutbot.sim.rmdispatcher.utils.logger
1111
import org.springframework.beans.factory.annotation.Autowired
1212
import org.springframework.beans.factory.annotation.Value
13+
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
1314
import org.springframework.scheduling.TaskScheduler
1415
import org.springframework.scheduling.annotation.Async
1516
import org.springframework.stereotype.Component
1617
import java.time.Instant
1718

1819
@Component
20+
@ConditionalOnProperty(prefix = "lark", name = ["enabled"], havingValue = "true")
1921
class LarkMatchEndListener(
2022
@Autowired val larkService: ILarkService,
2123
@Autowired val djiService: IDjiService,

src/main/kotlin/cn/scutbot/sim/rmdispatcher/listener/impl/LarkMatchSessionEndListener.kt

+2
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@ import cn.scutbot.sim.rmdispatcher.service.IMatchService
99
import cn.scutbot.sim.rmdispatcher.utils.logger
1010
import org.springframework.beans.factory.annotation.Autowired
1111
import org.springframework.beans.factory.annotation.Value
12+
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
1213
import org.springframework.scheduling.annotation.Async
1314
import org.springframework.stereotype.Component
1415

1516
@Component
17+
@ConditionalOnProperty(prefix = "lark", name = ["enabled"], havingValue = "true")
1618
class LarkMatchSessionEndListener(
1719
@Autowired val larkService: ILarkService,
1820
@Autowired val matchService: IMatchService,

src/main/kotlin/cn/scutbot/sim/rmdispatcher/listener/impl/LarkMatchStartListener.kt

+2
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@ import cn.scutbot.sim.rmdispatcher.service.IMatchService
88
import cn.scutbot.sim.rmdispatcher.utils.logger
99
import org.springframework.beans.factory.annotation.Autowired
1010
import org.springframework.beans.factory.annotation.Value
11+
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
1112
import org.springframework.scheduling.annotation.Async
1213
import org.springframework.stereotype.Component
1314

1415
@Component
16+
@ConditionalOnProperty(prefix = "lark", name = ["enabled"], havingValue = "true")
1517
class LarkMatchStartListener(
1618
@Autowired val larkService: ILarkService,
1719
@Autowired val matchService: IMatchService,

0 commit comments

Comments
 (0)