-
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.
- Loading branch information
1 parent
d0cade2
commit 81654ce
Showing
10 changed files
with
86 additions
and
18 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
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
7 changes: 7 additions & 0 deletions
7
modules/app-server/domain/src/main/kotlin/script/ScriptDaoInterface.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,7 @@ | ||
package script | ||
|
||
interface ScriptDaoInterface { | ||
fun insert(data: ScriptCreationRequest): Script | ||
fun delete(checksum: String) | ||
fun findOneByChecksum(checksum: String): Script? | ||
} |
13 changes: 13 additions & 0 deletions
13
modules/app-server/domain/src/main/kotlin/script/ScriptService.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,13 @@ | ||
package script | ||
|
||
class ScriptService( | ||
private val scriptDao: ScriptDaoInterface | ||
) { | ||
fun insert(data: ScriptCreationRequest): Script = | ||
scriptDao.insert(data) | ||
|
||
fun delete(checksum: String) = scriptDao.delete(checksum) | ||
|
||
fun findOneByChecksum(checksum: String): Script? = | ||
scriptDao.findOneByChecksum(checksum) | ||
} |
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
16 changes: 16 additions & 0 deletions
16
modules/app-server/rest/src/main/kotlin/rest/v1/route/script/ScriptDto.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,16 @@ | ||
package rest.v1.route.script | ||
|
||
import script.Script | ||
|
||
@kotlinx.serialization.Serializable | ||
data class ScriptDtoV1( | ||
val name: String, | ||
val checksum: String, | ||
val content: String | ||
) | ||
|
||
fun Script.toDtoV1() = ScriptDtoV1( | ||
name = this.name, | ||
checksum = this.checksum, | ||
content = this.checksum | ||
) |
16 changes: 16 additions & 0 deletions
16
modules/app-server/rest/src/main/kotlin/rest/v1/route/script/ScriptRoutesV1.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,16 @@ | ||
package rest.v1.route.script | ||
|
||
import io.ktor.server.application.* | ||
import io.ktor.server.response.* | ||
import io.ktor.server.routing.* | ||
import script.ScriptService | ||
|
||
internal const val scriptId = "scriptId" | ||
|
||
internal fun ApplicationCall.scriptId() = this.parameters[scriptId] | ||
|
||
internal fun Route.scriptV1Routes(scriptService: ScriptService) { | ||
get("/scripts/{$scriptId}") { | ||
call.respondNullable(call.scriptId()?.let{ scriptService.findOneByChecksum(it) }?.toDtoV1()) | ||
} | ||
} |