Skip to content

Commit

Permalink
feat: add basic support of kotlin coroutines
Browse files Browse the repository at this point in the history
  • Loading branch information
Handiwork committed Feb 18, 2024
1 parent 92d4cd8 commit 33edc35
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
8 changes: 8 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ dependencies {
// kotlin
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-reactor")

// kotlin-logging
implementation("io.github.oshai:kotlin-logging-jvm:6.0.3")
Expand Down Expand Up @@ -152,6 +154,12 @@ swaggerSources {
}
}

tasks {
forkedSpringBootRun {
doNotTrackState("See https://github.com/springdoc/springdoc-openapi-gradle-plugin/issues/102")
}
}


gitProperties {
failOnNoGitDirectory = false
Expand Down
18 changes: 11 additions & 7 deletions src/main/kotlin/plus/maa/backend/controller/SystemController.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package plus.maa.backend.controller

import io.swagger.v3.oas.annotations.tags.Tag
import kotlinx.coroutines.delay
import org.springframework.boot.info.GitProperties
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RequestMapping
Expand All @@ -15,16 +16,19 @@ import plus.maa.backend.controller.response.MaaResult
@RequestMapping("")
@RestController
class SystemController(
private val properties: MaaCopilotProperties,
private val gitProperties: GitProperties
private val properties: MaaCopilotProperties,
private val gitProperties: GitProperties
) {

/**
* Tests if the server is ready.
* @return 系统启动信息
*/
@GetMapping("/")
fun test() = MaaResult.success("Maa Copilot Server is Running", null)
suspend fun test(): MaaResult<Nothing> {
delay(1000L)
return MaaResult.success("Maa Copilot Server is Running", null)
}


/**
Expand All @@ -39,9 +43,9 @@ class SystemController(
}

data class MaaSystemInfo(
val title: String,
val description: String,
val version: String,
val git: GitProperties,
val title: String,
val description: String,
val version: String,
val git: GitProperties,
)
}

0 comments on commit 33edc35

Please sign in to comment.