add getNodeFromDevice to NodeService
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
package ltd.hlaeja.service
|
||||
|
||||
import java.util.UUID
|
||||
import ltd.hlaeja.entity.NodeEntity
|
||||
import ltd.hlaeja.repository.NodeRepository
|
||||
import mu.KotlinLogging
|
||||
import org.springframework.http.HttpStatus.NOT_FOUND
|
||||
import org.springframework.stereotype.Service
|
||||
import org.springframework.web.server.ResponseStatusException
|
||||
|
||||
private val log = KotlinLogging.logger {}
|
||||
|
||||
@@ -16,4 +19,9 @@ class NodeService(
|
||||
node: NodeEntity,
|
||||
): NodeEntity = nodeRepository.save(node)
|
||||
.also { log.debug { "Added node ${it.id}" } }
|
||||
|
||||
suspend fun getNodeFromDevice(
|
||||
device: UUID,
|
||||
): NodeEntity = nodeRepository.findByDevice(device)
|
||||
?: throw ResponseStatusException(NOT_FOUND)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user