Add addType to TypeController
This commit is contained in:
@@ -4,8 +4,11 @@ import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.map
|
||||
import ltd.hlaeja.library.deviceRegistry.Type
|
||||
import ltd.hlaeja.service.TypeService
|
||||
import ltd.hlaeja.util.toTypeEntity
|
||||
import ltd.hlaeja.util.toTypeResponse
|
||||
import org.springframework.web.bind.annotation.GetMapping
|
||||
import org.springframework.web.bind.annotation.PostMapping
|
||||
import org.springframework.web.bind.annotation.RequestBody
|
||||
import org.springframework.web.bind.annotation.RestController
|
||||
|
||||
@RestController
|
||||
@@ -15,4 +18,9 @@ class TypeController(
|
||||
|
||||
@GetMapping("/types")
|
||||
fun getTypes(): Flow<Type.Response> = service.getTypes().map { it.toTypeResponse() }
|
||||
|
||||
@PostMapping("/type")
|
||||
suspend fun addType(
|
||||
@RequestBody register: Type.Request,
|
||||
): Type.Response = service.addType(register.toTypeEntity()).toTypeResponse()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user