diff --git a/Cargo.lock b/Cargo.lock index 3699eb2..b5de244 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -222,6 +222,15 @@ dependencies = [ "alloc-no-stdlib", ] +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + [[package]] name = "anymap2" version = "0.13.0" @@ -239,7 +248,7 @@ name = "backend" version = "0.1.0" dependencies = [ "actix-web", - "chrono", + "chrono 0.2.25", "common", "diesel", "dotenv", @@ -356,6 +365,28 @@ dependencies = [ "time 0.1.45", ] +[[package]] +name = "chrono" +version = "0.4.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16b0a3d9ed01224b22057780a37bb8c5dbfe1be8ba48678e7bf57ec4b385411f" +dependencies = [ + "iana-time-zone", + "num-integer", + "num-traits", + "winapi", +] + +[[package]] +name = "codespan-reporting" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" +dependencies = [ + "termcolor", + "unicode-width", +] + [[package]] name = "common" version = "0.1.0" @@ -391,6 +422,12 @@ dependencies = [ "version_check", ] +[[package]] +name = "core-foundation-sys" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" + [[package]] name = "cpufeatures" version = "0.2.5" @@ -419,6 +456,50 @@ dependencies = [ "typenum", ] +[[package]] +name = "cxx" +version = "1.0.85" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5add3fc1717409d029b20c5b6903fc0c0b02fa6741d820054f4a2efa5e5816fd" +dependencies = [ + "cc", + "cxxbridge-flags", + "cxxbridge-macro", + "link-cplusplus", +] + +[[package]] +name = "cxx-build" +version = "1.0.85" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4c87959ba14bc6fbc61df77c3fcfe180fc32b93538c4f1031dd802ccb5f2ff0" +dependencies = [ + "cc", + "codespan-reporting", + "once_cell", + "proc-macro2", + "quote", + "scratch", + "syn", +] + +[[package]] +name = "cxxbridge-flags" +version = "1.0.85" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69a3e162fde4e594ed2b07d0f83c6c67b745e7f28ce58c6df5e6b6bef99dfb59" + +[[package]] +name = "cxxbridge-macro" +version = "1.0.85" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e7e2adeb6a0d4a282e581096b06e1791532b7d576dcde5ccd9382acf55db8e6" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "db-frontend" version = "0.1.0" @@ -458,6 +539,7 @@ checksum = "68c186a7418a2aac330bb76cde82f16c36b03a66fb91db32d20214311f9f6545" dependencies = [ "bitflags", "byteorder", + "chrono 0.4.23", "diesel_derives", "itoa", "pq-sys", @@ -846,6 +928,30 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" +[[package]] +name = "iana-time-zone" +version = "0.1.53" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64c122667b287044802d6ce17ee2ddf13207ed924c712de9a66a5814d5b64765" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "wasm-bindgen", + "winapi", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0703ae284fc167426161c2e3f1da3ea71d94b21bedbcc9494e92b28e334e3dca" +dependencies = [ + "cxx", + "cxx-build", +] + [[package]] name = "idna" version = "0.3.0" @@ -911,6 +1017,15 @@ version = "0.2.138" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "db6d7e329c562c5dfab7a46a2afabc8b987ab9a4834c9d1ca04dc54c1546cef8" +[[package]] +name = "link-cplusplus" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecd207c9c713c34f95a097a5b029ac2ce6010530c7b49d7fea24d977dede04f5" +dependencies = [ + "cc", +] + [[package]] name = "local-channel" version = "0.1.3" @@ -1303,6 +1418,12 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" +[[package]] +name = "scratch" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddccb15bcce173023b3fedd9436f882a0739b8dfb45e4f6b6002bee5929f61b2" + [[package]] name = "semver" version = "1.0.14" @@ -1420,6 +1541,15 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "termcolor" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755" +dependencies = [ + "winapi-util", +] + [[package]] name = "thiserror" version = "1.0.37" @@ -1609,6 +1739,12 @@ dependencies = [ "tinyvec", ] +[[package]] +name = "unicode-width" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" + [[package]] name = "url" version = "2.3.1" @@ -1736,6 +1872,15 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +[[package]] +name = "winapi-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +dependencies = [ + "winapi", +] + [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" diff --git a/backend/Cargo.toml b/backend/Cargo.toml index 62d7f34..69164b7 100644 --- a/backend/Cargo.toml +++ b/backend/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -diesel = { version = "2.0.0",features = ["postgres","r2d2"] } +diesel = { version = "2.0.0",features = ["postgres","r2d2","chrono"] } dotenv = "0.15" chrono = "0.2.25" common = { path = "../common"} diff --git a/backend/src/driver_data.rs b/backend/src/driver_data.rs index e06fedd..9cdd38f 100644 --- a/backend/src/driver_data.rs +++ b/backend/src/driver_data.rs @@ -1,20 +1,16 @@ -use diesel::prelude::*; -use diesel::pg::data_types::PgDate; +use crate::models::{Driver, NewDriver}; use common::CommonDriver; -use crate::models::{Driver,NewDriver}; +use diesel::prelude::*; -pub fn listdrivers(connection: &mut PgConnection) -{ +pub fn listdrivers(connection: &mut PgConnection) { use crate::schema::drivers::dsl::*; let queury = drivers.load::(connection).expect("KANKER"); - for driver in queury - { - println!("{} {}",driver.name ,driver.address); + for driver in queury { + println!("{} {}", driver.name, driver.address); } } -pub fn addriver(connection: &mut PgConnection, new_driver: NewDriver){ - +pub fn addriver(connection: &mut PgConnection, new_driver: NewDriver) { use crate::schema::drivers::dsl::*; diesel::insert_into(drivers) .values(&new_driver) @@ -33,7 +29,6 @@ pub fn get_driver(connection: &mut PgConnection, driver_id: i32) -> CommonDriver id: driver.id, name: String::from(&driver.name), address: String::from(&driver.address), - reg_date: &driver.regdate, - birthdate: String::from(&driver.birthdate), }; -} \ No newline at end of file +} + diff --git a/backend/src/models.rs b/backend/src/models.rs index 9fb5b38..0b4698c 100644 --- a/backend/src/models.rs +++ b/backend/src/models.rs @@ -1,34 +1,30 @@ -use diesel::{prelude::*, data_types::PgDate}; use crate::schema::*; - - +use diesel::{data_types::PgDate, prelude::*}; //Admins -#[derive(Queryable,Debug,AsChangeset,Identifiable)] -pub -struct Admin { +#[derive(Queryable, Debug, AsChangeset, Identifiable)] +pub struct Admin { pub id: i32, pub name: String, - pub address: String + pub address: String, } #[derive(Insertable)] #[diesel(table_name = admins)] -pub -struct NewAdmin<'a> { +pub struct NewAdmin<'a> { pub id: i32, pub name: &'a str, - pub address: &'a str + pub address: &'a str, } -#[derive(Queryable,AsChangeset,Associations)] +#[derive(Queryable, AsChangeset, Associations)] #[diesel(belongs_to(Admin))] pub struct AdminEmail { pub admin_id: i32, pub email: String, } -#[derive(Insertable,Associations)] +#[derive(Insertable, Associations)] #[diesel(belongs_to(Admin))] #[diesel(table_name = admin_emails)] pub struct NewAdminEmail<'a> { @@ -36,14 +32,13 @@ pub struct NewAdminEmail<'a> { pub email: &'a str, } - //Ticket things #[derive(Queryable)] pub struct Ticket { pub id: i32, pub category: String, pub description: String, - pub issue_date: PgDate + pub issue_date: PgDate, } #[derive(Insertable)] @@ -72,7 +67,7 @@ pub struct AutoIssuedTicket<'a> { } //Drivers -#[derive(Queryable,AsChangeset,Identifiable)] +#[derive(Queryable, AsChangeset, Identifiable)] pub struct Driver { pub id: i32, pub name: String, @@ -92,7 +87,7 @@ pub struct NewDriver<'a> { } //Vehicles -#[derive(Queryable,AsChangeset)] +#[derive(Queryable, AsChangeset)] #[diesel(belongs_to(Driver))] pub struct Vehicle { pub model: Option, @@ -100,6 +95,5 @@ pub struct Vehicle { pub chasse_num: i32, pub plate_num: String, pub vehicle_type: String, - pub owner: i32 - + pub owner: i32, } diff --git a/common/src/lib.rs b/common/src/lib.rs index 3a5f98b..7899bf3 100644 --- a/common/src/lib.rs +++ b/common/src/lib.rs @@ -22,6 +22,5 @@ pub struct CommonDriver { pub id: i32, pub name: String, pub address: String, - pub reg_date: i32, - pub birthdate: i32, -} \ No newline at end of file +} +