feat: load billing adapters #125
8 changed files with 1123 additions and 3 deletions
115
src/ordering/adapters/input/web/category.rs
Normal file
115
src/ordering/adapters/input/web/category.rs
Normal file
|
@ -0,0 +1,115 @@
|
||||||
|
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
|
use actix_identity::Identity;
|
||||||
|
use actix_web::{get, http::header::ContentType, post, web, HttpRequest, HttpResponse, Responder};
|
||||||
|
use derive_builder::Builder;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use url::Url;
|
||||||
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
use super::errors::*;
|
||||||
|
use super::types;
|
||||||
|
//use crate::utils::uuid::WebGetUUIDInterfaceObj;
|
||||||
|
|
||||||
|
pub fn services(cfg: &mut web::ServiceConfig) {
|
||||||
|
cfg.service(add_category_ui_handler);
|
||||||
|
cfg.service(add_category_form_submission_handler);
|
||||||
|
|
||||||
|
cfg.service(update_category_ui_handler);
|
||||||
|
cfg.service(update_category_form_submission_handler);
|
||||||
|
}
|
||||||
|
|
||||||
|
// add_category handlers
|
||||||
|
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
|
#[get("/ordering/menu/category/add")]
|
||||||
|
#[tracing::instrument(name = "add_category UI handler", skip())]
|
||||||
|
async fn add_category_ui_handler() -> WebJsonRepsonse<impl Responder> {
|
||||||
|
use web_ui::ordering::add_category::*;
|
||||||
|
|
||||||
|
let page = AddCategoryPage::page();
|
||||||
|
|
||||||
|
Ok(HttpResponse::Ok()
|
||||||
|
.insert_header(ContentType::html())
|
||||||
|
.body(page))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Serialize, Deserialize)]
|
||||||
|
struct AddCategoryPayload {
|
||||||
|
password: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
|
#[post("/ordering/menu/category/add")]
|
||||||
|
#[tracing::instrument(
|
||||||
|
name = "add_category form submission handler"
|
||||||
|
skip(id, req, payload, ordering_cqrs_exec)
|
||||||
|
)]
|
||||||
|
async fn add_category_form_submission_handler(
|
||||||
|
ordering_cqrs_exec: types::WebOrderingCqrsExec,
|
||||||
|
req: HttpRequest,
|
||||||
|
id: Identity,
|
||||||
|
payload: web::Form<AddCategoryPayload>,
|
||||||
|
) -> WebJsonRepsonse<impl Responder> {
|
||||||
|
let store = "";
|
||||||
|
|
||||||
|
Ok(HttpResponse::Ok().json(store))
|
||||||
|
}
|
||||||
|
|
||||||
|
// update_category handlers
|
||||||
|
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
|
#[get("/ordering/menu/{category_uuid}/update")]
|
||||||
|
#[tracing::instrument(name = "update_category UI handler", skip())]
|
||||||
|
async fn update_category_ui_handler() -> WebJsonRepsonse<impl Responder> {
|
||||||
|
use web_ui::ordering::update_category::*;
|
||||||
|
|
||||||
|
let page = UpdateCategoryPage::page();
|
||||||
|
|
||||||
|
Ok(HttpResponse::Ok()
|
||||||
|
.insert_header(ContentType::html())
|
||||||
|
.body(page))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Serialize, Deserialize)]
|
||||||
|
struct UpdateCategoryPayload {
|
||||||
|
password: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
|
#[post("/ordering/menu/{category_uuid}/update")]
|
||||||
|
#[tracing::instrument(
|
||||||
|
name = "update_category form submission handler"
|
||||||
|
skip(id, req, payload, ordering_cqrs_exec)
|
||||||
|
)]
|
||||||
|
async fn update_category_form_submission_handler(
|
||||||
|
ordering_cqrs_exec: types::WebOrderingCqrsExec,
|
||||||
|
req: HttpRequest,
|
||||||
|
id: Identity,
|
||||||
|
payload: web::Form<UpdateCategoryPayload>,
|
||||||
|
) -> WebJsonRepsonse<impl Responder> {
|
||||||
|
let store = "";
|
||||||
|
|
||||||
|
Ok(HttpResponse::Ok().json(store))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use crate::utils::uuid::tests::UUID;
|
||||||
|
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[actix_rt::test]
|
||||||
|
async fn ordering_web_add_category_ui_works() {
|
||||||
|
let routes = crate::ordering::adapters::input::web::RoutesRepository::default();
|
||||||
|
crate::tests::actix_web_test_utils::page_test_runner(&routes.add_category).await;
|
||||||
|
}
|
||||||
|
|
||||||
|
#[actix_rt::test]
|
||||||
|
async fn ordering_web_update_category_ui_works() {
|
||||||
|
let routes = crate::ordering::adapters::input::web::RoutesRepository::default();
|
||||||
|
crate::tests::actix_web_test_utils::page_test_runner(&routes.update_category(UUID)).await;
|
||||||
|
}
|
||||||
|
}
|
118
src/ordering/adapters/input/web/customization.rs
Normal file
118
src/ordering/adapters/input/web/customization.rs
Normal file
|
@ -0,0 +1,118 @@
|
||||||
|
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
|
use actix_identity::Identity;
|
||||||
|
use actix_web::{get, http::header::ContentType, post, web, HttpRequest, HttpResponse, Responder};
|
||||||
|
use derive_builder::Builder;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use url::Url;
|
||||||
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
use super::errors::*;
|
||||||
|
use super::types;
|
||||||
|
//use crate::utils::uuid::WebGetUUIDInterfaceObj;
|
||||||
|
|
||||||
|
pub fn services(cfg: &mut web::ServiceConfig) {
|
||||||
|
cfg.service(add_customization_ui_handler);
|
||||||
|
cfg.service(add_customization_form_submission_handler);
|
||||||
|
|
||||||
|
cfg.service(update_customization_ui_handler);
|
||||||
|
cfg.service(update_customization_form_submission_handler);
|
||||||
|
}
|
||||||
|
|
||||||
|
// add_customization handlers
|
||||||
|
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
|
#[get("/ordering/menu/{category_uuid}/{product_uuid}/customization/add")]
|
||||||
|
#[tracing::instrument(name = "add_customization UI handler", skip())]
|
||||||
|
async fn add_customization_ui_handler() -> WebJsonRepsonse<impl Responder> {
|
||||||
|
use web_ui::ordering::add_customization::*;
|
||||||
|
|
||||||
|
let page = AddCustomizationPage::page();
|
||||||
|
|
||||||
|
Ok(HttpResponse::Ok()
|
||||||
|
.insert_header(ContentType::html())
|
||||||
|
.body(page))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Serialize, Deserialize)]
|
||||||
|
struct AddCustomizationPayload {
|
||||||
|
password: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
|
#[post("/ordering/menu/{category_uuid}/{product_uuid}/customization/add")]
|
||||||
|
#[tracing::instrument(
|
||||||
|
name = "add_customization form submission handler"
|
||||||
|
skip(id, req, payload, ordering_cqrs_exec)
|
||||||
|
)]
|
||||||
|
async fn add_customization_form_submission_handler(
|
||||||
|
ordering_cqrs_exec: types::WebOrderingCqrsExec,
|
||||||
|
req: HttpRequest,
|
||||||
|
id: Identity,
|
||||||
|
payload: web::Form<AddCustomizationPayload>,
|
||||||
|
) -> WebJsonRepsonse<impl Responder> {
|
||||||
|
let store = "";
|
||||||
|
|
||||||
|
Ok(HttpResponse::Ok().json(store))
|
||||||
|
}
|
||||||
|
|
||||||
|
// update_customization handlers
|
||||||
|
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
|
#[get("/ordering/menu/{category_uuid}/{product_uuid}/{customization_uuid}/update")]
|
||||||
|
#[tracing::instrument(name = "update_customization UI handler", skip())]
|
||||||
|
async fn update_customization_ui_handler() -> WebJsonRepsonse<impl Responder> {
|
||||||
|
use web_ui::ordering::update_customization::*;
|
||||||
|
|
||||||
|
let page = UpdateCustomizationPage::page();
|
||||||
|
|
||||||
|
Ok(HttpResponse::Ok()
|
||||||
|
.insert_header(ContentType::html())
|
||||||
|
.body(page))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Serialize, Deserialize)]
|
||||||
|
struct UpdateCustomizationPayload {
|
||||||
|
password: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
|
#[post("/ordering/menu/{category_uuid}/{product_uuid}/{customization_uuid}/update")]
|
||||||
|
#[tracing::instrument(
|
||||||
|
name = "update_customization form submission handler"
|
||||||
|
skip(id, req, payload, ordering_cqrs_exec)
|
||||||
|
)]
|
||||||
|
async fn update_customization_form_submission_handler(
|
||||||
|
ordering_cqrs_exec: types::WebOrderingCqrsExec,
|
||||||
|
req: HttpRequest,
|
||||||
|
id: Identity,
|
||||||
|
payload: web::Form<UpdateCustomizationPayload>,
|
||||||
|
) -> WebJsonRepsonse<impl Responder> {
|
||||||
|
let store = "";
|
||||||
|
|
||||||
|
Ok(HttpResponse::Ok().json(store))
|
||||||
|
}
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use crate::utils::uuid::tests::UUID;
|
||||||
|
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[actix_rt::test]
|
||||||
|
async fn ordering_web_add_customization_ui_works() {
|
||||||
|
let routes = crate::ordering::adapters::input::web::RoutesRepository::default();
|
||||||
|
crate::tests::actix_web_test_utils::page_test_runner(&routes.add_customization(UUID, UUID))
|
||||||
|
.await;
|
||||||
|
}
|
||||||
|
|
||||||
|
#[actix_rt::test]
|
||||||
|
async fn ordering_web_update_customization_ui_works() {
|
||||||
|
let routes = crate::ordering::adapters::input::web::RoutesRepository::default();
|
||||||
|
crate::tests::actix_web_test_utils::page_test_runner(
|
||||||
|
&routes.update_customization(UUID, UUID, UUID),
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
}
|
||||||
|
}
|
161
src/ordering/adapters/input/web/kot.rs
Normal file
161
src/ordering/adapters/input/web/kot.rs
Normal file
|
@ -0,0 +1,161 @@
|
||||||
|
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
|
use actix_identity::Identity;
|
||||||
|
use actix_web::{get, http::header::ContentType, post, web, HttpRequest, HttpResponse, Responder};
|
||||||
|
use derive_builder::Builder;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use url::Url;
|
||||||
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
use super::errors::*;
|
||||||
|
use super::types;
|
||||||
|
//use crate::utils::uuid::WebGetUUIDInterfaceObj;
|
||||||
|
|
||||||
|
pub fn services(cfg: &mut web::ServiceConfig) {
|
||||||
|
cfg.service(add_kot_ui_handler);
|
||||||
|
cfg.service(add_kot_form_submission_handler);
|
||||||
|
|
||||||
|
cfg.service(update_kot_ui_handler);
|
||||||
|
cfg.service(update_kot_form_submission_handler);
|
||||||
|
|
||||||
|
cfg.service(delete_kot_ui_handler);
|
||||||
|
cfg.service(delete_kot_form_submission_handler);
|
||||||
|
}
|
||||||
|
|
||||||
|
// add_kot handlers
|
||||||
|
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
|
#[get("/ordering/floor/{order_uuid}/kot/add")]
|
||||||
|
#[tracing::instrument(name = "add_kot UI handler", skip())]
|
||||||
|
async fn add_kot_ui_handler() -> WebJsonRepsonse<impl Responder> {
|
||||||
|
use web_ui::ordering::add_kot::*;
|
||||||
|
|
||||||
|
let page = AddKotPage::page();
|
||||||
|
|
||||||
|
Ok(HttpResponse::Ok()
|
||||||
|
.insert_header(ContentType::html())
|
||||||
|
.body(page))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Serialize, Deserialize)]
|
||||||
|
struct AddKotPayload {
|
||||||
|
password: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
|
#[post("/ordering/floor/{order_uuid}/kot/add")]
|
||||||
|
#[tracing::instrument(
|
||||||
|
name = "add_kot form submission handler"
|
||||||
|
skip(id, req, payload, ordering_cqrs_exec)
|
||||||
|
)]
|
||||||
|
async fn add_kot_form_submission_handler(
|
||||||
|
ordering_cqrs_exec: types::WebOrderingCqrsExec,
|
||||||
|
req: HttpRequest,
|
||||||
|
id: Identity,
|
||||||
|
payload: web::Form<AddKotPayload>,
|
||||||
|
) -> WebJsonRepsonse<impl Responder> {
|
||||||
|
let store = "";
|
||||||
|
|
||||||
|
Ok(HttpResponse::Ok().json(store))
|
||||||
|
}
|
||||||
|
|
||||||
|
// update_kot handlers
|
||||||
|
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
|
#[get("/ordering/floor/{order_uuid}/{kot_uuid}/update")]
|
||||||
|
#[tracing::instrument(name = "update_kot UI handler", skip())]
|
||||||
|
async fn update_kot_ui_handler() -> WebJsonRepsonse<impl Responder> {
|
||||||
|
use web_ui::ordering::update_kot::*;
|
||||||
|
|
||||||
|
let page = UpdateKotPage::page();
|
||||||
|
|
||||||
|
Ok(HttpResponse::Ok()
|
||||||
|
.insert_header(ContentType::html())
|
||||||
|
.body(page))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Serialize, Deserialize)]
|
||||||
|
struct UpdateKotPayload {
|
||||||
|
password: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
|
#[post("/ordering/floor/{order_uuid}/{kot_uuid}/update")]
|
||||||
|
#[tracing::instrument(
|
||||||
|
name = "update_kot form submission handler"
|
||||||
|
skip(id, req, payload, ordering_cqrs_exec)
|
||||||
|
)]
|
||||||
|
async fn update_kot_form_submission_handler(
|
||||||
|
ordering_cqrs_exec: types::WebOrderingCqrsExec,
|
||||||
|
req: HttpRequest,
|
||||||
|
id: Identity,
|
||||||
|
payload: web::Form<UpdateKotPayload>,
|
||||||
|
) -> WebJsonRepsonse<impl Responder> {
|
||||||
|
let store = "";
|
||||||
|
|
||||||
|
Ok(HttpResponse::Ok().json(store))
|
||||||
|
}
|
||||||
|
|
||||||
|
// delete_kot handlers
|
||||||
|
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
|
#[get("/ordering/floor/{order_uuid}/{kot_uuid}/delete")]
|
||||||
|
#[tracing::instrument(name = "delete_kot UI handler", skip())]
|
||||||
|
async fn delete_kot_ui_handler() -> WebJsonRepsonse<impl Responder> {
|
||||||
|
use web_ui::ordering::delete_kot::*;
|
||||||
|
|
||||||
|
let page = DeleteKotPage::page();
|
||||||
|
|
||||||
|
Ok(HttpResponse::Ok()
|
||||||
|
.insert_header(ContentType::html())
|
||||||
|
.body(page))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Serialize, Deserialize)]
|
||||||
|
struct DeleteKotPayload {
|
||||||
|
password: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
|
#[post("/ordering/floor/{order_uuid}/{kot_uuid}/delete")]
|
||||||
|
#[tracing::instrument(
|
||||||
|
name = "delete_kot form submission handler"
|
||||||
|
skip(id, req, payload, ordering_cqrs_exec)
|
||||||
|
)]
|
||||||
|
async fn delete_kot_form_submission_handler(
|
||||||
|
ordering_cqrs_exec: types::WebOrderingCqrsExec,
|
||||||
|
req: HttpRequest,
|
||||||
|
id: Identity,
|
||||||
|
payload: web::Form<DeleteKotPayload>,
|
||||||
|
) -> WebJsonRepsonse<impl Responder> {
|
||||||
|
let store = "";
|
||||||
|
|
||||||
|
Ok(HttpResponse::Ok().json(store))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use crate::utils::uuid::tests::UUID;
|
||||||
|
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[actix_rt::test]
|
||||||
|
async fn ordering_web_add_kot_ui_works() {
|
||||||
|
let routes = crate::ordering::adapters::input::web::RoutesRepository::default();
|
||||||
|
crate::tests::actix_web_test_utils::page_test_runner(&routes.add_kot(UUID)).await;
|
||||||
|
}
|
||||||
|
|
||||||
|
#[actix_rt::test]
|
||||||
|
async fn ordering_web_update_kot_ui_works() {
|
||||||
|
let routes = crate::ordering::adapters::input::web::RoutesRepository::default();
|
||||||
|
crate::tests::actix_web_test_utils::page_test_runner(&routes.update_kot(UUID, UUID)).await;
|
||||||
|
}
|
||||||
|
|
||||||
|
#[actix_rt::test]
|
||||||
|
async fn ordering_web_delete_kot_ui_works() {
|
||||||
|
let routes = crate::ordering::adapters::input::web::RoutesRepository::default();
|
||||||
|
crate::tests::actix_web_test_utils::page_test_runner(&routes.delete_kot(UUID, UUID)).await;
|
||||||
|
}
|
||||||
|
}
|
168
src/ordering/adapters/input/web/line_item.rs
Normal file
168
src/ordering/adapters/input/web/line_item.rs
Normal file
|
@ -0,0 +1,168 @@
|
||||||
|
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
|
use actix_identity::Identity;
|
||||||
|
use actix_web::{get, http::header::ContentType, post, web, HttpRequest, HttpResponse, Responder};
|
||||||
|
use derive_builder::Builder;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use url::Url;
|
||||||
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
use super::errors::*;
|
||||||
|
use super::types;
|
||||||
|
//use crate::utils::uuid::WebGetUUIDInterfaceObj;
|
||||||
|
|
||||||
|
pub fn services(cfg: &mut web::ServiceConfig) {
|
||||||
|
cfg.service(add_line_item_ui_handler);
|
||||||
|
cfg.service(add_line_item_form_submission_handler);
|
||||||
|
|
||||||
|
cfg.service(update_line_item_ui_handler);
|
||||||
|
cfg.service(update_line_item_form_submission_handler);
|
||||||
|
|
||||||
|
cfg.service(delete_line_item_ui_handler);
|
||||||
|
cfg.service(delete_line_item_form_submission_handler);
|
||||||
|
}
|
||||||
|
|
||||||
|
// add_line_item handlers
|
||||||
|
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
|
#[get("/ordering/floor/{order_uuid}/{kot_uuid}/line_item/add")]
|
||||||
|
#[tracing::instrument(name = "add_line_item UI handler", skip())]
|
||||||
|
async fn add_line_item_ui_handler() -> WebJsonRepsonse<impl Responder> {
|
||||||
|
use web_ui::ordering::add_line_item::*;
|
||||||
|
|
||||||
|
let page = AddLineItemPage::page();
|
||||||
|
|
||||||
|
Ok(HttpResponse::Ok()
|
||||||
|
.insert_header(ContentType::html())
|
||||||
|
.body(page))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Serialize, Deserialize)]
|
||||||
|
struct AddLineItemPayload {
|
||||||
|
password: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
|
#[post("/ordering/floor/{order_uuid}/{kot_uuid}/line_item/add")]
|
||||||
|
#[tracing::instrument(
|
||||||
|
name = "add_line_item form submission handler"
|
||||||
|
skip(id, req, payload, ordering_cqrs_exec)
|
||||||
|
)]
|
||||||
|
async fn add_line_item_form_submission_handler(
|
||||||
|
ordering_cqrs_exec: types::WebOrderingCqrsExec,
|
||||||
|
req: HttpRequest,
|
||||||
|
id: Identity,
|
||||||
|
payload: web::Form<AddLineItemPayload>,
|
||||||
|
) -> WebJsonRepsonse<impl Responder> {
|
||||||
|
let store = "";
|
||||||
|
|
||||||
|
Ok(HttpResponse::Ok().json(store))
|
||||||
|
}
|
||||||
|
|
||||||
|
// update_line_item handlers
|
||||||
|
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
|
#[get("/ordering/floor/{order_uuid}/{kot_uuid}/{line_item_uuid}/update")]
|
||||||
|
#[tracing::instrument(name = "update_line_item UI handler", skip())]
|
||||||
|
async fn update_line_item_ui_handler() -> WebJsonRepsonse<impl Responder> {
|
||||||
|
use web_ui::ordering::update_line_item::*;
|
||||||
|
|
||||||
|
let page = UpdateLineItemPage::page();
|
||||||
|
|
||||||
|
Ok(HttpResponse::Ok()
|
||||||
|
.insert_header(ContentType::html())
|
||||||
|
.body(page))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Serialize, Deserialize)]
|
||||||
|
struct UpdateLineItemPayload {
|
||||||
|
password: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
|
#[post("/ordering/floor/{order_uuid}/{kot_uuid}/{line_item_uuid}/update")]
|
||||||
|
#[tracing::instrument(
|
||||||
|
name = "update_line_item form submission handler"
|
||||||
|
skip(id, req, payload, ordering_cqrs_exec)
|
||||||
|
)]
|
||||||
|
async fn update_line_item_form_submission_handler(
|
||||||
|
ordering_cqrs_exec: types::WebOrderingCqrsExec,
|
||||||
|
req: HttpRequest,
|
||||||
|
id: Identity,
|
||||||
|
payload: web::Form<UpdateLineItemPayload>,
|
||||||
|
) -> WebJsonRepsonse<impl Responder> {
|
||||||
|
let store = "";
|
||||||
|
|
||||||
|
Ok(HttpResponse::Ok().json(store))
|
||||||
|
}
|
||||||
|
|
||||||
|
// delete_line_item handlers
|
||||||
|
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
|
#[get("/ordering/floor/{order_uuid}/{kot_uuid}/{line_item_uuid}/delete")]
|
||||||
|
#[tracing::instrument(name = "delete_line_item UI handler", skip())]
|
||||||
|
async fn delete_line_item_ui_handler() -> WebJsonRepsonse<impl Responder> {
|
||||||
|
use web_ui::ordering::delete_line_item::*;
|
||||||
|
|
||||||
|
let page = DeleteLineItemPage::page();
|
||||||
|
|
||||||
|
Ok(HttpResponse::Ok()
|
||||||
|
.insert_header(ContentType::html())
|
||||||
|
.body(page))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Serialize, Deserialize)]
|
||||||
|
struct DeleteLineItemPayload {
|
||||||
|
password: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
|
#[post("/ordering/floor/{order_uuid}/{kot_uuid}/{line_item_uuid}/delete")]
|
||||||
|
#[tracing::instrument(
|
||||||
|
name = "delete_line_item form submission handler"
|
||||||
|
skip(id, req, payload, ordering_cqrs_exec)
|
||||||
|
)]
|
||||||
|
async fn delete_line_item_form_submission_handler(
|
||||||
|
ordering_cqrs_exec: types::WebOrderingCqrsExec,
|
||||||
|
req: HttpRequest,
|
||||||
|
id: Identity,
|
||||||
|
payload: web::Form<DeleteLineItemPayload>,
|
||||||
|
) -> WebJsonRepsonse<impl Responder> {
|
||||||
|
let store = "";
|
||||||
|
|
||||||
|
Ok(HttpResponse::Ok().json(store))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use crate::utils::uuid::tests::UUID;
|
||||||
|
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[actix_rt::test]
|
||||||
|
async fn ordering_web_add_line_item_ui_works() {
|
||||||
|
let routes = crate::ordering::adapters::input::web::RoutesRepository::default();
|
||||||
|
crate::tests::actix_web_test_utils::page_test_runner(&routes.add_line_item(UUID, UUID))
|
||||||
|
.await;
|
||||||
|
}
|
||||||
|
|
||||||
|
#[actix_rt::test]
|
||||||
|
async fn ordering_web_update_line_item_ui_works() {
|
||||||
|
let routes = crate::ordering::adapters::input::web::RoutesRepository::default();
|
||||||
|
crate::tests::actix_web_test_utils::page_test_runner(
|
||||||
|
&routes.update_line_item(UUID, UUID, UUID),
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
}
|
||||||
|
|
||||||
|
#[actix_rt::test]
|
||||||
|
async fn ordering_web_delete_line_item_ui_works() {
|
||||||
|
let routes = crate::ordering::adapters::input::web::RoutesRepository::default();
|
||||||
|
crate::tests::actix_web_test_utils::page_test_runner(
|
||||||
|
&routes.delete_line_item(UUID, UUID, UUID),
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
}
|
||||||
|
}
|
|
@ -11,6 +11,14 @@ use crate::ordering::adapters::types;
|
||||||
mod errors;
|
mod errors;
|
||||||
mod routes;
|
mod routes;
|
||||||
|
|
||||||
|
mod category;
|
||||||
|
mod customization;
|
||||||
|
mod product;
|
||||||
|
|
||||||
|
mod kot;
|
||||||
|
mod line_item;
|
||||||
|
mod order;
|
||||||
|
|
||||||
pub use errors::WebJsonRepsonse;
|
pub use errors::WebJsonRepsonse;
|
||||||
|
|
||||||
pub use routes::RoutesRepository;
|
pub use routes::RoutesRepository;
|
||||||
|
@ -20,6 +28,13 @@ pub fn load_ctx() -> impl FnOnce(&mut web::ServiceConfig) {
|
||||||
|
|
||||||
let f = move |cfg: &mut web::ServiceConfig| {
|
let f = move |cfg: &mut web::ServiceConfig| {
|
||||||
cfg.app_data(routes);
|
cfg.app_data(routes);
|
||||||
|
cfg.configure(customization::services);
|
||||||
|
cfg.configure(product::services);
|
||||||
|
cfg.configure(category::services);
|
||||||
|
|
||||||
|
cfg.configure(line_item::services);
|
||||||
|
cfg.configure(kot::services);
|
||||||
|
cfg.configure(order::services);
|
||||||
};
|
};
|
||||||
|
|
||||||
Box::new(f)
|
Box::new(f)
|
||||||
|
|
161
src/ordering/adapters/input/web/order.rs
Normal file
161
src/ordering/adapters/input/web/order.rs
Normal file
|
@ -0,0 +1,161 @@
|
||||||
|
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
|
use actix_identity::Identity;
|
||||||
|
use actix_web::{get, http::header::ContentType, post, web, HttpRequest, HttpResponse, Responder};
|
||||||
|
use derive_builder::Builder;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use url::Url;
|
||||||
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
use super::errors::*;
|
||||||
|
use super::types;
|
||||||
|
//use crate::utils::uuid::WebGetUUIDInterfaceObj;
|
||||||
|
|
||||||
|
pub fn services(cfg: &mut web::ServiceConfig) {
|
||||||
|
cfg.service(add_order_ui_handler);
|
||||||
|
cfg.service(add_order_form_submission_handler);
|
||||||
|
|
||||||
|
cfg.service(update_order_ui_handler);
|
||||||
|
cfg.service(update_order_form_submission_handler);
|
||||||
|
|
||||||
|
cfg.service(delete_order_ui_handler);
|
||||||
|
cfg.service(delete_order_form_submission_handler);
|
||||||
|
}
|
||||||
|
|
||||||
|
// add_order handlers
|
||||||
|
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
|
#[get("/ordering/floor/order/add")]
|
||||||
|
#[tracing::instrument(name = "add_order UI handler", skip())]
|
||||||
|
async fn add_order_ui_handler() -> WebJsonRepsonse<impl Responder> {
|
||||||
|
use web_ui::ordering::add_order::*;
|
||||||
|
|
||||||
|
let page = AddOrderPage::page();
|
||||||
|
|
||||||
|
Ok(HttpResponse::Ok()
|
||||||
|
.insert_header(ContentType::html())
|
||||||
|
.body(page))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Serialize, Deserialize)]
|
||||||
|
struct AddOrderPayload {
|
||||||
|
password: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
|
#[post("/ordering/floor/order/add")]
|
||||||
|
#[tracing::instrument(
|
||||||
|
name = "add_order form submission handler"
|
||||||
|
skip(id, req, payload, ordering_cqrs_exec)
|
||||||
|
)]
|
||||||
|
async fn add_order_form_submission_handler(
|
||||||
|
ordering_cqrs_exec: types::WebOrderingCqrsExec,
|
||||||
|
req: HttpRequest,
|
||||||
|
id: Identity,
|
||||||
|
payload: web::Form<AddOrderPayload>,
|
||||||
|
) -> WebJsonRepsonse<impl Responder> {
|
||||||
|
let store = "";
|
||||||
|
|
||||||
|
Ok(HttpResponse::Ok().json(store))
|
||||||
|
}
|
||||||
|
|
||||||
|
// update_order handlers
|
||||||
|
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
|
#[get("/ordering/floor/{order_uuid}/update")]
|
||||||
|
#[tracing::instrument(name = "update_order UI handler", skip())]
|
||||||
|
async fn update_order_ui_handler() -> WebJsonRepsonse<impl Responder> {
|
||||||
|
use web_ui::ordering::update_order::*;
|
||||||
|
|
||||||
|
let page = UpdateOrderPage::page();
|
||||||
|
|
||||||
|
Ok(HttpResponse::Ok()
|
||||||
|
.insert_header(ContentType::html())
|
||||||
|
.body(page))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Serialize, Deserialize)]
|
||||||
|
struct UpdateOrderPayload {
|
||||||
|
password: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
|
#[post("/ordering/floor/{order_uuid}/update")]
|
||||||
|
#[tracing::instrument(
|
||||||
|
name = "update_order form submission handler"
|
||||||
|
skip(id, req, payload, ordering_cqrs_exec)
|
||||||
|
)]
|
||||||
|
async fn update_order_form_submission_handler(
|
||||||
|
ordering_cqrs_exec: types::WebOrderingCqrsExec,
|
||||||
|
req: HttpRequest,
|
||||||
|
id: Identity,
|
||||||
|
payload: web::Form<UpdateOrderPayload>,
|
||||||
|
) -> WebJsonRepsonse<impl Responder> {
|
||||||
|
let store = "";
|
||||||
|
|
||||||
|
Ok(HttpResponse::Ok().json(store))
|
||||||
|
}
|
||||||
|
|
||||||
|
// delete_order handlers
|
||||||
|
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
|
#[get("/ordering/floor/{order_uuid}/delete")]
|
||||||
|
#[tracing::instrument(name = "delete_order UI handler", skip())]
|
||||||
|
async fn delete_order_ui_handler() -> WebJsonRepsonse<impl Responder> {
|
||||||
|
use web_ui::ordering::delete_order::*;
|
||||||
|
|
||||||
|
let page = DeleteOrderPage::page();
|
||||||
|
|
||||||
|
Ok(HttpResponse::Ok()
|
||||||
|
.insert_header(ContentType::html())
|
||||||
|
.body(page))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Serialize, Deserialize)]
|
||||||
|
struct DeleteOrderPayload {
|
||||||
|
password: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
|
#[post("/ordering/floor/{order_uuid}/delete")]
|
||||||
|
#[tracing::instrument(
|
||||||
|
name = "delete_order form submission handler"
|
||||||
|
skip(id, req, payload, ordering_cqrs_exec)
|
||||||
|
)]
|
||||||
|
async fn delete_order_form_submission_handler(
|
||||||
|
ordering_cqrs_exec: types::WebOrderingCqrsExec,
|
||||||
|
req: HttpRequest,
|
||||||
|
id: Identity,
|
||||||
|
payload: web::Form<DeleteOrderPayload>,
|
||||||
|
) -> WebJsonRepsonse<impl Responder> {
|
||||||
|
let store = "";
|
||||||
|
|
||||||
|
Ok(HttpResponse::Ok().json(store))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use crate::utils::uuid::tests::UUID;
|
||||||
|
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[actix_rt::test]
|
||||||
|
async fn ordering_web_add_order_ui_works() {
|
||||||
|
let routes = crate::ordering::adapters::input::web::RoutesRepository::default();
|
||||||
|
crate::tests::actix_web_test_utils::page_test_runner(&routes.add_order).await;
|
||||||
|
}
|
||||||
|
|
||||||
|
#[actix_rt::test]
|
||||||
|
async fn ordering_web_update_order_ui_works() {
|
||||||
|
let routes = crate::ordering::adapters::input::web::RoutesRepository::default();
|
||||||
|
crate::tests::actix_web_test_utils::page_test_runner(&routes.update_order(UUID)).await;
|
||||||
|
}
|
||||||
|
|
||||||
|
#[actix_rt::test]
|
||||||
|
async fn ordering_web_delete_order_ui_works() {
|
||||||
|
let routes = crate::ordering::adapters::input::web::RoutesRepository::default();
|
||||||
|
crate::tests::actix_web_test_utils::page_test_runner(&routes.delete_order(UUID)).await;
|
||||||
|
}
|
||||||
|
}
|
114
src/ordering/adapters/input/web/product.rs
Normal file
114
src/ordering/adapters/input/web/product.rs
Normal file
|
@ -0,0 +1,114 @@
|
||||||
|
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
|
use actix_identity::Identity;
|
||||||
|
use actix_web::{get, http::header::ContentType, post, web, HttpRequest, HttpResponse, Responder};
|
||||||
|
use derive_builder::Builder;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use url::Url;
|
||||||
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
use super::errors::*;
|
||||||
|
use super::types;
|
||||||
|
//use crate::utils::uuid::WebGetUUIDInterfaceObj;
|
||||||
|
|
||||||
|
pub fn services(cfg: &mut web::ServiceConfig) {
|
||||||
|
cfg.service(add_product_ui_handler);
|
||||||
|
cfg.service(add_product_form_submission_handler);
|
||||||
|
|
||||||
|
cfg.service(update_product_ui_handler);
|
||||||
|
cfg.service(update_product_form_submission_handler);
|
||||||
|
}
|
||||||
|
// add_product handlers
|
||||||
|
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
|
#[get("/ordering/menu/{category_uuid}/product/add")]
|
||||||
|
#[tracing::instrument(name = "add_product UI handler", skip())]
|
||||||
|
async fn add_product_ui_handler() -> WebJsonRepsonse<impl Responder> {
|
||||||
|
use web_ui::ordering::add_product::*;
|
||||||
|
|
||||||
|
let page = AddProductPage::page();
|
||||||
|
|
||||||
|
Ok(HttpResponse::Ok()
|
||||||
|
.insert_header(ContentType::html())
|
||||||
|
.body(page))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Serialize, Deserialize)]
|
||||||
|
struct AddProductPayload {
|
||||||
|
password: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
|
#[post("/ordering/menu/{category_uuid}/product/add")]
|
||||||
|
#[tracing::instrument(
|
||||||
|
name = "add_product form submission handler"
|
||||||
|
skip(id, req, payload, ordering_cqrs_exec)
|
||||||
|
)]
|
||||||
|
async fn add_product_form_submission_handler(
|
||||||
|
ordering_cqrs_exec: types::WebOrderingCqrsExec,
|
||||||
|
req: HttpRequest,
|
||||||
|
id: Identity,
|
||||||
|
payload: web::Form<AddProductPayload>,
|
||||||
|
) -> WebJsonRepsonse<impl Responder> {
|
||||||
|
let store = "";
|
||||||
|
|
||||||
|
Ok(HttpResponse::Ok().json(store))
|
||||||
|
}
|
||||||
|
|
||||||
|
// update_product handlers
|
||||||
|
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
|
#[get("/ordering/menu/{category_uuid}/{product_uuid}/update")]
|
||||||
|
#[tracing::instrument(name = "update_product UI handler", skip())]
|
||||||
|
async fn update_product_ui_handler() -> WebJsonRepsonse<impl Responder> {
|
||||||
|
use web_ui::ordering::update_product::*;
|
||||||
|
|
||||||
|
let page = UpdateProductPage::page();
|
||||||
|
|
||||||
|
Ok(HttpResponse::Ok()
|
||||||
|
.insert_header(ContentType::html())
|
||||||
|
.body(page))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Serialize, Deserialize)]
|
||||||
|
struct UpdateProductPayload {
|
||||||
|
password: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
|
#[post("/ordering/menu/{category_uuid}/{product_uuid}/update")]
|
||||||
|
#[tracing::instrument(
|
||||||
|
name = "update_product form submission handler"
|
||||||
|
skip(id, req, payload, ordering_cqrs_exec)
|
||||||
|
)]
|
||||||
|
async fn update_product_form_submission_handler(
|
||||||
|
ordering_cqrs_exec: types::WebOrderingCqrsExec,
|
||||||
|
req: HttpRequest,
|
||||||
|
id: Identity,
|
||||||
|
payload: web::Form<UpdateProductPayload>,
|
||||||
|
) -> WebJsonRepsonse<impl Responder> {
|
||||||
|
let store = "";
|
||||||
|
|
||||||
|
Ok(HttpResponse::Ok().json(store))
|
||||||
|
}
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use crate::utils::uuid::tests::UUID;
|
||||||
|
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[actix_rt::test]
|
||||||
|
async fn ordering_web_add_product_ui_works() {
|
||||||
|
let routes = crate::ordering::adapters::input::web::RoutesRepository::default();
|
||||||
|
crate::tests::actix_web_test_utils::page_test_runner(&routes.add_product(UUID)).await;
|
||||||
|
}
|
||||||
|
|
||||||
|
#[actix_rt::test]
|
||||||
|
async fn ordering_web_update_product_ui_works() {
|
||||||
|
let routes = crate::ordering::adapters::input::web::RoutesRepository::default();
|
||||||
|
crate::tests::actix_web_test_utils::page_test_runner(&routes.update_product(UUID, UUID))
|
||||||
|
.await;
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,12 +6,280 @@ use url::Url;
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
|
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
|
||||||
pub struct RoutesRepository {}
|
pub struct RoutesRepository {
|
||||||
|
add_line_item: String,
|
||||||
|
update_line_item: String,
|
||||||
|
delete_line_item: String,
|
||||||
|
|
||||||
|
pub add_order: String,
|
||||||
|
update_order: String,
|
||||||
|
delete_order: String,
|
||||||
|
|
||||||
|
add_kot: String,
|
||||||
|
update_kot: String,
|
||||||
|
delete_kot: String,
|
||||||
|
|
||||||
|
pub add_category: String,
|
||||||
|
update_category: String,
|
||||||
|
|
||||||
|
add_product: String,
|
||||||
|
update_product: String,
|
||||||
|
|
||||||
|
add_customization: String,
|
||||||
|
update_customization: String,
|
||||||
|
}
|
||||||
|
|
||||||
impl Default for RoutesRepository {
|
impl Default for RoutesRepository {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {}
|
Self {
|
||||||
|
add_order: "/ordering/floor/order/add".into(),
|
||||||
|
update_order: "/ordering/floor/{order_uuid}/update".into(),
|
||||||
|
delete_order: "/ordering/floor/{order_uuid}/delete".into(),
|
||||||
|
|
||||||
|
add_kot: "/ordering/floor/{order_uuid}/kot/add".into(),
|
||||||
|
update_kot: "/ordering/floor/{order_uuid}/{kot_uuid}/update".into(),
|
||||||
|
delete_kot: "/ordering/floor/{order_uuid}/{kot_uuid}/delete".into(),
|
||||||
|
|
||||||
|
add_line_item: "/ordering/floor/{order_uuid}/{kot_uuid}/line_item/add".into(),
|
||||||
|
update_line_item: "/ordering/floor/{order_uuid}/{kot_uuid}/{line_item_uuid}/update"
|
||||||
|
.into(),
|
||||||
|
delete_line_item: "/ordering/floor/{order_uuid}/{kot_uuid}/{line_item_uuid}/delete"
|
||||||
|
.into(),
|
||||||
|
|
||||||
|
add_category: "/ordering/menu/category/add".into(),
|
||||||
|
update_category: "/ordering/menu/{category_uuid}/update".into(),
|
||||||
|
|
||||||
|
add_product: "/ordering/menu/{category_uuid}/product/add".into(),
|
||||||
|
update_product: "/ordering/menu/{category_uuid}/{product_uuid}/update".into(),
|
||||||
|
|
||||||
|
add_customization: "/ordering/menu/{category_uuid}/{product_uuid}/customization/add"
|
||||||
|
.into(),
|
||||||
|
update_customization:
|
||||||
|
"/ordering/menu/{category_uuid}/{product_uuid}/{customization_uuid}/update".into(),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RoutesRepository {}
|
impl RoutesRepository {
|
||||||
|
pub fn update_order(&self, order_uuid: Uuid) -> String {
|
||||||
|
self.update_order
|
||||||
|
.replace("{order_uuid}", &order_uuid.to_string())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn delete_order(&self, order_uuid: Uuid) -> String {
|
||||||
|
self.delete_order
|
||||||
|
.replace("{order_uuid}", &order_uuid.to_string())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn add_kot(&self, order_uuid: Uuid) -> String {
|
||||||
|
self.add_kot
|
||||||
|
.replace("{order_uuid}", &order_uuid.to_string())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn update_kot(&self, order_uuid: Uuid, kot_uuid: Uuid) -> String {
|
||||||
|
self.update_kot
|
||||||
|
.replace("{order_uuid}", &order_uuid.to_string())
|
||||||
|
.replace("{kot_uuid}", &kot_uuid.to_string())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn delete_kot(&self, order_uuid: Uuid, kot_uuid: Uuid) -> String {
|
||||||
|
self.delete_kot
|
||||||
|
.replace("{order_uuid}", &order_uuid.to_string())
|
||||||
|
.replace("{kot_uuid}", &kot_uuid.to_string())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn add_line_item(&self, order_uuid: Uuid, kot_uuid: Uuid) -> String {
|
||||||
|
self.add_line_item
|
||||||
|
.replace("{order_uuid}", &order_uuid.to_string())
|
||||||
|
.replace("{kot_uuid}", &kot_uuid.to_string())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn update_line_item(
|
||||||
|
&self,
|
||||||
|
order_uuid: Uuid,
|
||||||
|
kot_uuid: Uuid,
|
||||||
|
line_item_uuid: Uuid,
|
||||||
|
) -> String {
|
||||||
|
self.update_line_item
|
||||||
|
.replace("{order_uuid}", &order_uuid.to_string())
|
||||||
|
.replace("{kot_uuid}", &kot_uuid.to_string())
|
||||||
|
.replace("{line_item_uuid}", &line_item_uuid.to_string())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn delete_line_item(
|
||||||
|
&self,
|
||||||
|
order_uuid: Uuid,
|
||||||
|
kot_uuid: Uuid,
|
||||||
|
line_item_uuid: Uuid,
|
||||||
|
) -> String {
|
||||||
|
self.delete_line_item
|
||||||
|
.replace("{order_uuid}", &order_uuid.to_string())
|
||||||
|
.replace("{kot_uuid}", &kot_uuid.to_string())
|
||||||
|
.replace("{line_item_uuid}", &line_item_uuid.to_string())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn update_category(&self, category_uuid: Uuid) -> String {
|
||||||
|
self.update_category
|
||||||
|
.replace("{category_uuid}", &category_uuid.to_string())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn add_product(&self, category_uuid: Uuid) -> String {
|
||||||
|
self.add_product
|
||||||
|
.replace("{category_uuid}", &category_uuid.to_string())
|
||||||
|
}
|
||||||
|
pub fn update_product(&self, category_uuid: Uuid, product_uuid: Uuid) -> String {
|
||||||
|
self.update_product
|
||||||
|
.replace("{category_uuid}", &category_uuid.to_string())
|
||||||
|
.replace("{product_uuid}", &product_uuid.to_string())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn add_customization(&self, category_uuid: Uuid, product_uuid: Uuid) -> String {
|
||||||
|
self.add_customization
|
||||||
|
.replace("{category_uuid}", &category_uuid.to_string())
|
||||||
|
.replace("{product_uuid}", &product_uuid.to_string())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn update_customization(
|
||||||
|
&self,
|
||||||
|
category_uuid: Uuid,
|
||||||
|
product_uuid: Uuid,
|
||||||
|
customization_uuid: Uuid,
|
||||||
|
) -> String {
|
||||||
|
self.update_customization
|
||||||
|
.replace("{category_uuid}", &category_uuid.to_string())
|
||||||
|
.replace("{product_uuid}", &product_uuid.to_string())
|
||||||
|
.replace("{customization_uuid}", &customization_uuid.to_string())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use crate::utils::uuid::tests::UUID;
|
||||||
|
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn ordering_web_route_update_order() {
|
||||||
|
let r = RoutesRepository::default();
|
||||||
|
assert_eq!(
|
||||||
|
r.update_order(UUID),
|
||||||
|
format!("/ordering/floor/{UUID}/update")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn ordering_web_route_delete_order() {
|
||||||
|
let r = RoutesRepository::default();
|
||||||
|
assert_eq!(
|
||||||
|
r.delete_order(UUID),
|
||||||
|
format!("/ordering/floor/{UUID}/delete")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn ordering_web_route_add_kot() {
|
||||||
|
let r = RoutesRepository::default();
|
||||||
|
assert_eq!(r.add_kot(UUID), format!("/ordering/floor/{UUID}/kot/add"));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn ordering_web_route_update_kot() {
|
||||||
|
let r = RoutesRepository::default();
|
||||||
|
let kot_uuid = Uuid::new_v4();
|
||||||
|
assert_eq!(
|
||||||
|
r.update_kot(UUID, kot_uuid),
|
||||||
|
format!("/ordering/floor/{UUID}/{kot_uuid}/update")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn ordering_web_route_delete_kot() {
|
||||||
|
let r = RoutesRepository::default();
|
||||||
|
let kot_uuid = Uuid::new_v4();
|
||||||
|
assert_eq!(
|
||||||
|
r.delete_kot(UUID, kot_uuid),
|
||||||
|
format!("/ordering/floor/{UUID}/{kot_uuid}/delete")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn ordering_web_route_add_line_item() {
|
||||||
|
let r = RoutesRepository::default();
|
||||||
|
let kot_uuid = Uuid::new_v4();
|
||||||
|
assert_eq!(
|
||||||
|
r.add_line_item(UUID, kot_uuid),
|
||||||
|
format!("/ordering/floor/{UUID}/{kot_uuid}/line_item/add")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn ordering_web_route_update_line_item() {
|
||||||
|
let r = RoutesRepository::default();
|
||||||
|
let kot_uuid = Uuid::new_v4();
|
||||||
|
let line_item_uuid = Uuid::new_v4();
|
||||||
|
assert_eq!(
|
||||||
|
r.update_line_item(UUID, kot_uuid, line_item_uuid),
|
||||||
|
format!("/ordering/floor/{UUID}/{kot_uuid}/{line_item_uuid}/update")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn ordering_web_route_delete_line_item() {
|
||||||
|
let r = RoutesRepository::default();
|
||||||
|
let kot_uuid = Uuid::new_v4();
|
||||||
|
let line_item_uuid = Uuid::new_v4();
|
||||||
|
assert_eq!(
|
||||||
|
r.delete_line_item(UUID, kot_uuid, line_item_uuid),
|
||||||
|
format!("/ordering/floor/{UUID}/{kot_uuid}/{line_item_uuid}/delete")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn ordering_web_route_update_category() {
|
||||||
|
let r = RoutesRepository::default();
|
||||||
|
assert_eq!(
|
||||||
|
r.update_category(UUID),
|
||||||
|
format!("/ordering/menu/{UUID}/update")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn ordering_web_route_add_product() {
|
||||||
|
let r = RoutesRepository::default();
|
||||||
|
assert_eq!(
|
||||||
|
r.add_product(UUID),
|
||||||
|
format!("/ordering/menu/{UUID}/product/add")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn ordering_web_route_update_product() {
|
||||||
|
let r = RoutesRepository::default();
|
||||||
|
let product_id = Uuid::new_v4();
|
||||||
|
assert_eq!(
|
||||||
|
r.update_product(UUID, product_id),
|
||||||
|
format!("/ordering/menu/{UUID}/{product_id}/update")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn ordering_web_route_add_customization() {
|
||||||
|
let r = RoutesRepository::default();
|
||||||
|
let product_id = Uuid::new_v4();
|
||||||
|
assert_eq!(
|
||||||
|
r.add_customization(UUID, product_id),
|
||||||
|
format!("/ordering/menu/{UUID}/{product_id}/customization/add")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn ordering_web_route_update_customization() {
|
||||||
|
let r = RoutesRepository::default();
|
||||||
|
let product_id = Uuid::new_v4();
|
||||||
|
let customization_id = Uuid::new_v4();
|
||||||
|
assert_eq!(
|
||||||
|
r.update_customization(UUID, product_id, customization_id),
|
||||||
|
format!("/ordering/menu/{UUID}/{product_id}/{customization_id}/update")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue