-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add ScriptExecution first route
- Loading branch information
1 parent
2413aab
commit ab1767e
Showing
7 changed files
with
100 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
modules/app-server/domain/src/main/kotlin/script/execution/ScriptExecutionService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package script.execution | ||
|
||
import java.util.* | ||
|
||
class ScriptExecutionService( | ||
private val scriptExecutionDao: ScriptExecutionDaoInterface | ||
) { | ||
fun insert(data: ScriptExecutionCreationRequest): ScriptExecution = | ||
scriptExecutionDao.insert(data) | ||
|
||
fun updateScriptExecutionStartData( | ||
scriptExecutionId: UUID, | ||
executionStartData: ScriptExecutionStartUpdateRequest | ||
): ScriptExecution? = | ||
scriptExecutionDao.updateScriptExecutionStartData(scriptExecutionId, executionStartData) | ||
|
||
fun updateScriptExecutionEndData( | ||
scriptExecutionId: UUID, | ||
executionEndData: ScriptExecutionEndUpdateRequest | ||
): ScriptExecution? = | ||
scriptExecutionDao.updateScriptExecutionEndData(scriptExecutionId, executionEndData) | ||
|
||
fun delete(id: UUID) = scriptExecutionDao.delete(id) | ||
|
||
fun findOneById(id: UUID): ScriptExecution? = scriptExecutionDao.findOneById(id) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
...es/app-server/rest/src/main/kotlin/rest/v1/route/script/execution/ScriptExecutionDtoV1.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package rest.v1.route.script.execution | ||
|
||
import execution.Status | ||
import kotlinx.serialization.Serializable | ||
import rest.OffsetDateTimeSerializer | ||
import rest.UUIDSerializer | ||
import rest.v1.route.execution.StatusDtoV1 | ||
import rest.v1.route.execution.toDtoV1 | ||
import script.execution.ScriptExecution | ||
import java.time.OffsetDateTime | ||
import java.util.UUID | ||
|
||
@Serializable | ||
data class ScriptExecutionDtoV1( | ||
@Serializable(with = UUIDSerializer::class) | ||
val id: UUID, | ||
@Serializable(with = OffsetDateTimeSerializer::class) | ||
val startDate: OffsetDateTime? = null, | ||
@Serializable(with = OffsetDateTimeSerializer::class) | ||
val endDate: OffsetDateTime? = null, | ||
val durationInMs: Int? = null, | ||
val executionOrderIndex: Int, | ||
val output: String? = null, | ||
val status: StatusDtoV1? = null | ||
) | ||
|
||
fun ScriptExecution.toDtoV1() = ScriptExecutionDtoV1( | ||
id = this.id, | ||
startDate = this.startDate, | ||
endDate = this.endDate, | ||
durationInMs = this.durationInMs, | ||
executionOrderIndex = this.executionOrderIndex, | ||
output = this.output, | ||
status = this.status?.toDtoV1() | ||
) |
17 changes: 17 additions & 0 deletions
17
...app-server/rest/src/main/kotlin/rest/v1/route/script/execution/ScriptExecutionRoutesV1.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package rest.v1.route.script.execution | ||
|
||
import io.ktor.server.application.* | ||
import io.ktor.server.response.* | ||
import io.ktor.server.routing.* | ||
import script.execution.ScriptExecutionService | ||
import java.util.UUID | ||
|
||
internal const val scriptExecutionId = "scriptExecutionId" | ||
|
||
internal fun ApplicationCall.scriptExecutionId() = UUID.fromString(this.parameters[scriptExecutionId]) | ||
|
||
internal fun Route.scriptExecutionV1Routes(scriptExecutionService: ScriptExecutionService) { | ||
get("/scriptExecutions/{$scriptExecutionId}") { | ||
call.respondNullable(call.scriptExecutionId()?.let { scriptExecutionService.findOneById(it)?.toDtoV1() }) | ||
} | ||
} |