about summary refs log tree commit diff stats
path: root/crates/rocie-server/src/api/set/barcode.rs
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2025-12-09 13:07:14 +0100
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2025-12-09 13:07:14 +0100
commitc91dce4f77ae12453203f0a28b91efb6533cc095 (patch)
tree4f50e755dff7f717d45309b08f9fe2c8c87f88bd /crates/rocie-server/src/api/set/barcode.rs
parentchore(rocie-client): Regenerate (diff)
downloadserver-c91dce4f77ae12453203f0a28b91efb6533cc095.zip
feat(rocie-server): Implement basic user handling and authentication
Diffstat (limited to 'crates/rocie-server/src/api/set/barcode.rs')
-rw-r--r--crates/rocie-server/src/api/set/barcode.rs105
1 files changed, 0 insertions, 105 deletions
diff --git a/crates/rocie-server/src/api/set/barcode.rs b/crates/rocie-server/src/api/set/barcode.rs
deleted file mode 100644
index bb84bbf..0000000
--- a/crates/rocie-server/src/api/set/barcode.rs
+++ /dev/null
@@ -1,105 +0,0 @@
-use actix_web::{HttpResponse, Responder, Result, post, web};
-use log::debug;
-
-use crate::{
-    app::App,
-    storage::sql::{
-        barcode::{Barcode, BarcodeId, BarcodeIdStub},
-        insert::Operations,
-        unit::UnitAmount,
-    },
-};
-
-/// Buy an barcode
-#[utoipa::path(
-    responses(
-        (
-            status = OK,
-            description = "Barcode successfully bought",
-        ),
-        (
-            status = NOT_FOUND,
-            description = "Barcode id was not found",
-        ),
-        (
-            status = INTERNAL_SERVER_ERROR,
-            description = "Server encountered error",
-            body = String,
-        )
-    ),
-    params(
-        ("barcode_id" = BarcodeId, description = "The numeric value of the barcode"),
-        ("times" = u16, description = "How often to buy the barcode"),
-    )
-)]
-#[post("/barcode/{barcode_id}/buy/{times}")]
-pub(crate) async fn buy_barcode(
-    app: web::Data<App>,
-    path: web::Path<(BarcodeIdStub, u16)>,
-) -> Result<impl Responder> {
-    let (barcode_id, times) = path.into_inner();
-
-    let mut ops = Operations::new("buy barcode unit");
-
-    let barcode = Barcode::from_id(&app, barcode_id.into()).await?;
-
-    match barcode {
-        Some(barcode) => {
-            for _ in 0..times {
-                barcode.buy(&mut ops);
-            }
-
-            ops.apply(&app).await?;
-
-            Ok(HttpResponse::Ok().finish())
-        }
-        None => Ok(HttpResponse::NotFound().finish()),
-    }
-}
-
-/// Consume an barcode
-#[utoipa::path(
-    responses(
-        (
-            status = OK,
-            description = "Barcode successfully consumed",
-        ),
-        (
-            status = NOT_FOUND,
-            description = "Barcode id was not found",
-        ),
-        (
-            status = INTERNAL_SERVER_ERROR,
-            description = "Server encountered error",
-            body = String,
-        )
-    ),
-    params(
-        ("id" = BarcodeId, description = "The numeric value of the barcode"),
-    ),
-    request_body = UnitAmount,
-)]
-#[post("/barcode/{id}/consume")]
-pub(crate) async fn consume_barcode(
-    app: web::Data<App>,
-    barcode_id: web::Path<BarcodeIdStub>,
-    unit_amount: web::Json<UnitAmount>,
-) -> Result<impl Responder> {
-    let mut ops = Operations::new("consume barcode unit");
-
-    let barcode = Barcode::from_id(&app, barcode_id.into_inner().into()).await?;
-    debug!("Starting consume for barcode: {barcode:?}");
-
-    match barcode {
-        Some(barcode) => {
-            barcode
-                .consume(&app, unit_amount.into_inner(), &mut ops)
-                .await?;
-
-            ops.apply(&app).await?;
-
-            Ok(HttpResponse::Ok().finish())
-        }
-        None => Ok(HttpResponse::NotFound().finish()),
-    }
-}