This commit is contained in:
LinlyBoi
2022-12-23 11:33:45 +02:00
parent b67c3c073d
commit 2a02926624
5 changed files with 57 additions and 24 deletions

6
.gitmodules vendored
View File

@@ -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

34
Cargo.lock generated
View File

@@ -242,7 +242,7 @@ dependencies = [
"chrono", "chrono",
"common", "common",
"diesel", "diesel",
"dotenvy", "dotenv",
"tokio", "tokio",
"yew", "yew",
] ]
@@ -430,6 +430,11 @@ dependencies = [
[[package]] [[package]]
name = "deans-full-quest" name = "deans-full-quest"
version = "0.1.0" version = "0.1.0"
dependencies = [
"actix-web",
"backend",
"common",
]
[[package]] [[package]]
name = "derive_more" name = "derive_more"
@@ -455,6 +460,7 @@ dependencies = [
"diesel_derives", "diesel_derives",
"itoa", "itoa",
"pq-sys", "pq-sys",
"r2d2",
] ]
[[package]] [[package]]
@@ -480,10 +486,10 @@ dependencies = [
] ]
[[package]] [[package]]
name = "dotenvy" name = "dotenv"
version = "0.15.6" version = "0.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "03d8c417d7a8cb362e0c37e5d815f5eb7c37f79ff93707329d5a194e42e54ca0" checksum = "77c90badedccf4105eca100756a0b1289e191f6fcbdadd3cee1d2f614f97da8f"
[[package]] [[package]]
name = "encoding_rs" name = "encoding_rs"
@@ -1193,6 +1199,17 @@ dependencies = [
"proc-macro2", "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]] [[package]]
name = "rand" name = "rand"
version = "0.8.5" version = "0.8.5"
@@ -1270,6 +1287,15 @@ version = "1.0.11"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09" 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]] [[package]]
name = "scopeguard" name = "scopeguard"
version = "1.1.0" version = "1.1.0"

View File

@@ -6,6 +6,9 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
common = { path = "./common"}
backend = {path = "./backend"}
actix-web = "4.0.0-rc.1"
[workspace] [workspace]
members = ["frontend","backend","common"] members = ["frontend","backend","common"]

View File

@@ -7,3 +7,11 @@ pub struct CommonTicket {
pub category: String, pub category: String,
pub description: 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,
}

View File

@@ -1,29 +1,31 @@
use actix_web::{ use actix_web::{
get, get,
web::{self, Json}, web::{self, Json},
App, HttpResponse, HttpServer, Responder, App, HttpServer,
}; };
use backend::admin_data::listadmins; use backend::{establish_connection, ticket_data::get_ticket};
use backend::establish_connection;
use backend::ticket_data::get_ticket;
use common::CommonTicket; use common::CommonTicket;
#[get("/ggsya")] // //Admin Services
async fn ggsya() -> impl Responder { // #[get("/api/admin/{id}")]
HttpResponse::Ok().body("Ggsya is here") // async fn admin(id: web::Path<i32>) -> Json<CommonAdmin> {
} // Json(get_admin(&mut establish_connection(), *id))
#[get("/admins")] // }
async fn admins() -> impl Responder { // #[get("/api/admins{amount}")]
HttpResponse::Ok().body(listadmins(&mut establish_connection())) // async fn admins(amount: web::Path<i64>) -> Json<Vec<CommonAdmin>> {
} // Json(get_admins(&mut establish_connection(), *amount))
#[get("/ticket/{id}")] // }
//Ticket Table Services
#[get("api/ticket/{id}")]
async fn ticket(id: web::Path<i32>) -> Json<CommonTicket> { async fn ticket(id: web::Path<i32>) -> Json<CommonTicket> {
let fetched_ticket = get_ticket(&mut establish_connection(), *id); let fetched_ticket = get_ticket(&mut establish_connection(), *id);
Json(fetched_ticket) Json(fetched_ticket)
} }
#[actix_web::main] #[actix_web::main]
async fn main() -> std::io::Result<()> { 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))? .bind(("127.0.0.1", 8081))?
.run() .run()
.await .await