add toIdentityResponse to mapping

This commit is contained in:
2024-11-22 23:44:14 +01:00
parent 18d85c8266
commit 919ede7da8
2 changed files with 51 additions and 0 deletions

View File

@@ -3,6 +3,7 @@ package ltd.hlaeja.util
import java.time.ZonedDateTime
import ltd.hlaeja.entity.NodeEntity
import ltd.hlaeja.entity.TypeEntity
import ltd.hlaeja.library.deviceRegistry.Identity
import ltd.hlaeja.library.deviceRegistry.Node
import ltd.hlaeja.library.deviceRegistry.Type
import org.springframework.http.HttpStatus.EXPECTATION_FAILED
@@ -29,3 +30,9 @@ fun NodeEntity.toNodeResponse(): Node.Response = Node.Response(
device,
name,
)
fun NodeEntity.toIdentityResponse(): Identity.Response = Identity.Response(
client,
id ?: throw ResponseStatusException(EXPECTATION_FAILED),
device,
)