add `/<uuid> route + backend handling

This commit is contained in:
2025-08-02 19:11:39 +02:00
parent 9badb4a4ad
commit 96a9ab361a
10 changed files with 116 additions and 50 deletions

View File

@@ -1,15 +1,30 @@
use crate::Backend;
use serde::{Deserialize, Serialize};
use sqlx::FromRow;
use uuid::Uuid;
#[derive(FromRow, Debug, Serialize, Deserialize)]
pub struct Camera {
pub uuid: String,
pub desc: String,
pub desc: Option<String>,
pub name: String,
}
impl Backend {
pub(crate) async fn camera_by_uuid(&self, uuid: Uuid) -> Option<Camera> {
let uuid = uuid.to_string();
match self {
Backend::Sqlite(db) => sqlx::query_as!(
Camera,
"SELECT uuid, desc, name FROM camera WHERE uuid = ?",
uuid
)
.fetch_optional(db)
.await
.unwrap(),
}
}
pub(crate) async fn amount_total_cameras(&self) -> i64 {
match self {
Backend::Sqlite(db) => {