From 35c83ed9eb970058d0d686b5db8ed5ff148e47b5 Mon Sep 17 00:00:00 2001 From: ultrageese Date: Thu, 28 May 2026 16:44:29 +1000 Subject: [PATCH] =?UTF-8?q?=D0=90=20=D1=85=D0=BE=D1=82=D1=8F=20=D0=B8=20?= =?UTF-8?q?=D1=82=D0=B0=D0=BA=20=D0=BD=D0=BE=D1=80=D0=BC,=20=D0=BF=D1=80?= =?UTF-8?q?=D0=B8=D0=BB=D0=BE=D0=B6=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BE=D1=82?= =?UTF-8?q?=20=D1=8D=D1=82=D0=BE=D0=B3=D0=BE=20=D0=BD=D0=B5=20=D0=BF=D0=B0?= =?UTF-8?q?=D0=B4=D0=B0=D0=B5=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- code/src/app.rs | 16 +++++++--------- code/src/database.rs | 7 +++---- code/src/main.rs | 6 ++---- 3 files changed, 12 insertions(+), 17 deletions(-) diff --git a/code/src/app.rs b/code/src/app.rs index 9913a48..57a9d61 100644 --- a/code/src/app.rs +++ b/code/src/app.rs @@ -1,11 +1,9 @@ use std::sync::Arc; -use chrono::NaiveDate; -use egui::{WidgetText::RichText, mutex::RwLock}; +use egui::mutex::RwLock; use egui_dock::{DockArea, Style, TabViewer}; -use rust_decimal::prelude::Zero; -use sqlx::{Connection, MySqlConnection, MySqlPool, types::BigDecimal}; -use crate::{database::DBOperator, models::{self, Equipment, Position, Salary, Worker}}; +use sqlx::types::BigDecimal; +use crate::{database::DBOperator, models::{Equipment, Position, Worker}}; static TABS_CAN_BE_WINDOWS: bool = false; @@ -33,7 +31,7 @@ pub struct App{ impl Default for App{ fn default() -> Self{ - let mut tree = egui_dock::DockState::new(vec![ + let tree = egui_dock::DockState::new(vec![ Tab{ tab_type: TabTypes::Equipment, title:"Оборудование".to_owned(), @@ -82,8 +80,8 @@ impl eframe::App for App{ .style(Style::from_egui(ui.style().as_ref())) .show_inside(ui, &mut self.main_viewer); } - fn update(&mut self, ctx: &egui::Context, frame: &mut eframe::Frame) { - if (self.main_viewer.is_dark_theme){ + fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) { + if self.main_viewer.is_dark_theme { ctx.set_visuals(egui::Visuals::dark()); }else{ ctx.set_visuals(egui::Visuals::light()); @@ -343,7 +341,7 @@ impl WorkerTabViewer{ }); - if(chrono::NaiveDate::parse_from_str(&self.add_worker_hire_date, "%d-%m-%Y").is_err()){ + if chrono::NaiveDate::parse_from_str(&self.add_worker_hire_date, "%d-%m-%Y").is_err() { ui.label(egui::RichText::new("ДАТА УКАЗАНА НЕВЕРНО").color(egui::Color32::RED)); self.can_add_worker = false; }else{ diff --git a/code/src/database.rs b/code/src/database.rs index da870a0..7f9cff3 100644 --- a/code/src/database.rs +++ b/code/src/database.rs @@ -3,7 +3,6 @@ use sqlx::mysql::MySqlPool; use dotenvy::dotenv_override; -use sqlx::mysql::MySqlQueryResult; use std::env; // use crate::schema::equipment::dsl::*; // use crate::schema::worker::dsl::*; @@ -64,13 +63,13 @@ impl DBOperator{ } pub async fn add_worker(&self, worker: Worker) -> Result{ // sqlx::query!("INSERT INTO Brewery.worker (id, position_id, hire_date, is_fired, full_name) VALUES(0, ?, ?, ?, ?);",worker.position.id, worker.hire_date ,worker.is_fired,worker.full_name) - match(sqlx::query("INSERT INTO Brewery.worker (id, position_id, hire_date, is_fired, full_name) VALUES(0, ?, ?, ?, ?);") + match sqlx::query("INSERT INTO Brewery.worker (id, position_id, hire_date, is_fired, full_name) VALUES(0, ?, ?, ?, ?);") .bind(worker.position.id) .bind(worker.hire_date) .bind(worker.is_fired) .bind(worker.full_name) .execute(&self.pool) - .await){ + .await { Ok(_) =>{ return Ok(true) }, @@ -147,7 +146,7 @@ impl DBOperator{ pub async fn estabilish_connection() -> Result<(), sqlx::Error>{ dotenv_override().ok(); let db_url = env::var("DATABASE_URL").expect("DATABASE_URL установи!"); - let pool = MySqlPoolOptions::new() + let _pool = MySqlPoolOptions::new() .max_connections(5) .connect(&db_url).await?; diff --git a/code/src/main.rs b/code/src/main.rs index 592c136..c64ca9e 100644 --- a/code/src/main.rs +++ b/code/src/main.rs @@ -1,16 +1,14 @@ #![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] -use egui::mutex::RwLock; -use sqlx::MySqlPool; -use crate::database::DBOperator; mod app; mod models; mod database; // mod schema; fn main() { - dotenvy::dotenv().ok(); database::estabilish_connection(); + dotenvy::dotenv().ok(); + database::estabilish_connection(); let native_opts = eframe::NativeOptions { viewport: egui::ViewportBuilder::default() .with_inner_size([400.0,300.0])