Add toTypeEntity to Mapping

This commit is contained in:
2024-11-23 03:25:15 +01:00
parent 2a98cdf38f
commit ba6f38a585
2 changed files with 36 additions and 0 deletions

View File

@@ -1,10 +1,13 @@
package ltd.hlaeja.util
import java.time.ZonedDateTime
import ltd.hlaeja.entity.TypeEntity
import ltd.hlaeja.library.deviceRegistry.Type
import org.springframework.http.HttpStatus.EXPECTATION_FAILED
import org.springframework.web.server.ResponseStatusException
fun Type.Request.toTypeEntity(): TypeEntity = TypeEntity(null, ZonedDateTime.now(), name)
fun TypeEntity.toTypeResponse(): Type.Response {
return Type.Response(id ?: throw ResponseStatusException(EXPECTATION_FAILED), name)
}