From e6468b012d5b33dd16992652da57f11dd5a6e82f Mon Sep 17 00:00:00 2001 From: Jokler Date: Sun, 21 Jun 2020 06:37:46 +0200 Subject: Initial commit --- src/model.rs | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 src/model.rs (limited to 'src/model.rs') diff --git a/src/model.rs b/src/model.rs new file mode 100644 index 0000000..1d399da --- /dev/null +++ b/src/model.rs @@ -0,0 +1,54 @@ +use actix::{Actor, SyncContext}; +use chrono::NaiveDateTime; +use diesel::mysql::MysqlConnection; +use r2d2::Pool; +use r2d2_diesel::ConnectionManager; + +use crate::schema::{passwords, transactions, users}; + +pub struct DbExecutor(pub Pool>); + +impl Actor for DbExecutor { + type Context = SyncContext; +} + +#[derive(Debug, Clone, Insertable)] +#[table_name = "transactions"] +pub struct NewTransaction<'a> { + pub sender: u64, + pub receiver: u64, + pub amount: u64, + pub sender_balance: u64, + pub receiver_balance: u64, + pub purpose: &'a str, +} + +#[derive(Debug, Clone, Queryable)] +pub struct User { + pub id: u64, + pub power_level: i32, + pub name: String, + pub created: NaiveDateTime, + pub balance: u64, +} + +#[derive(Debug, Clone, Insertable)] +#[table_name = "users"] +pub struct NewUser { + pub power_level: i32, + pub name: String, + pub balance: u64, +} + +#[derive(Debug, Clone, Queryable)] +pub struct Password { + pub id: u64, + pub hash: String, +} + +#[derive(Debug, Clone, Insertable)] +#[table_name = "passwords"] +pub struct NewPassword<'a> { + pub id: u64, + pub hash: &'a str, +} -- cgit v1.2.3-70-g09d2