update for common messages v0.2.0
- change DeviceController addDevice to use toDeviceResponse - add DeviceEntity.toDeviceResponse to Mapping.kt
This commit is contained in:
@@ -1,11 +1,14 @@
|
||||
package ltd.hlaeja.util
|
||||
|
||||
import java.time.ZonedDateTime
|
||||
import ltd.hlaeja.entity.DeviceEntity
|
||||
import ltd.hlaeja.entity.NodeEntity
|
||||
import ltd.hlaeja.entity.TypeEntity
|
||||
import ltd.hlaeja.library.deviceRegistry.Device
|
||||
import ltd.hlaeja.library.deviceRegistry.Identity
|
||||
import ltd.hlaeja.library.deviceRegistry.Node
|
||||
import ltd.hlaeja.library.deviceRegistry.Type
|
||||
import ltd.hlaeja.service.JwtService
|
||||
import org.springframework.http.HttpStatus.EXPECTATION_FAILED
|
||||
import org.springframework.web.server.ResponseStatusException
|
||||
|
||||
@@ -36,3 +39,11 @@ fun NodeEntity.toIdentityResponse(): Identity.Response = Identity.Response(
|
||||
id ?: throw ResponseStatusException(EXPECTATION_FAILED),
|
||||
device,
|
||||
)
|
||||
|
||||
suspend fun DeviceEntity.toDeviceResponse(
|
||||
jwtService: JwtService,
|
||||
): Device.Response = Device.Response(
|
||||
id ?: throw ResponseStatusException(EXPECTATION_FAILED),
|
||||
type,
|
||||
jwtService.makeIdentity(id),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user