From 2a029266241b742e8e014ed4671c1386a20954a5 Mon Sep 17 00:00:00 2001 From: LinlyBoi Date: Fri, 23 Dec 2022 11:33:45 +0200 Subject: [PATCH] YES? --- .gitmodules | 6 ------ Cargo.lock | 34 ++++++++++++++++++++++++++++++---- Cargo.toml | 3 +++ common/src/lib.rs | 8 ++++++++ src/main.rs | 30 ++++++++++++++++-------------- 5 files changed, 57 insertions(+), 24 deletions(-) delete mode 100644 .gitmodules diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 9f9b9e8..0000000 --- a/.gitmodules +++ /dev/null @@ -1,6 +0,0 @@ -[submodule "backend"] - path = backend - url = https://github.com/LinlyBoi/FCDS-DB.rs -[submodule "frontend"] - path = frontend - url = git@github.com:LinlyBoi/Deans-FrontQuest.git diff --git a/Cargo.lock b/Cargo.lock index f6240ca..2ec7f3f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -242,7 +242,7 @@ dependencies = [ "chrono", "common", "diesel", - "dotenvy", + "dotenv", "tokio", "yew", ] @@ -430,6 +430,11 @@ dependencies = [ [[package]] name = "deans-full-quest" version = "0.1.0" +dependencies = [ + "actix-web", + "backend", + "common", +] [[package]] name = "derive_more" @@ -455,6 +460,7 @@ dependencies = [ "diesel_derives", "itoa", "pq-sys", + "r2d2", ] [[package]] @@ -480,10 +486,10 @@ dependencies = [ ] [[package]] -name = "dotenvy" -version = "0.15.6" +name = "dotenv" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03d8c417d7a8cb362e0c37e5d815f5eb7c37f79ff93707329d5a194e42e54ca0" +checksum = "77c90badedccf4105eca100756a0b1289e191f6fcbdadd3cee1d2f614f97da8f" [[package]] name = "encoding_rs" @@ -1193,6 +1199,17 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "r2d2" +version = "0.8.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51de85fb3fb6524929c8a2eb85e6b6d363de4e8c48f9e2c2eac4944abc181c93" +dependencies = [ + "log", + "parking_lot", + "scheduled-thread-pool", +] + [[package]] name = "rand" version = "0.8.5" @@ -1270,6 +1287,15 @@ version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09" +[[package]] +name = "scheduled-thread-pool" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "977a7519bff143a44f842fd07e80ad1329295bd71686457f18e496736f4bf9bf" +dependencies = [ + "parking_lot", +] + [[package]] name = "scopeguard" version = "1.1.0" diff --git a/Cargo.toml b/Cargo.toml index d4fcdca..5b95419 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,6 +6,9 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +common = { path = "./common"} +backend = {path = "./backend"} +actix-web = "4.0.0-rc.1" [workspace] members = ["frontend","backend","common"] diff --git a/common/src/lib.rs b/common/src/lib.rs index fd3d802..38bde4f 100644 --- a/common/src/lib.rs +++ b/common/src/lib.rs @@ -7,3 +7,11 @@ pub struct CommonTicket { pub category: String, pub description: String, } + +#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)] +#[serde(rename_all = "camelCase")] +pub struct CommonAdmin { + pub id: i32, + pub name: String, + pub address: String, +} diff --git a/src/main.rs b/src/main.rs index 08cb6e7..891e447 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,29 +1,31 @@ use actix_web::{ get, web::{self, Json}, - App, HttpResponse, HttpServer, Responder, + App, HttpServer, }; -use backend::admin_data::listadmins; -use backend::establish_connection; -use backend::ticket_data::get_ticket; +use backend::{establish_connection, ticket_data::get_ticket}; use common::CommonTicket; -#[get("/ggsya")] -async fn ggsya() -> impl Responder { - HttpResponse::Ok().body("Ggsya is here") -} -#[get("/admins")] -async fn admins() -> impl Responder { - HttpResponse::Ok().body(listadmins(&mut establish_connection())) -} -#[get("/ticket/{id}")] +// //Admin Services +// #[get("/api/admin/{id}")] +// async fn admin(id: web::Path) -> Json { +// Json(get_admin(&mut establish_connection(), *id)) +// } +// #[get("/api/admins{amount}")] +// async fn admins(amount: web::Path) -> Json> { +// Json(get_admins(&mut establish_connection(), *amount)) +// } + +//Ticket Table Services +#[get("api/ticket/{id}")] async fn ticket(id: web::Path) -> Json { let fetched_ticket = get_ticket(&mut establish_connection(), *id); Json(fetched_ticket) } + #[actix_web::main] async fn main() -> std::io::Result<()> { - HttpServer::new(|| App::new().service(ggsya).service(admins).service(ticket)) + HttpServer::new(|| App::new().service(ticket)) .bind(("127.0.0.1", 8081))? .run() .await