From c9da24e464d2676203ac5375f39812cad5a0d341 Mon Sep 17 00:00:00 2001 From: filipriec Date: Sat, 22 Feb 2025 13:41:42 +0100 Subject: [PATCH] more changes to the structure of the project --- proto/common.proto | 1 + proto/table_structure.proto | 1 + src/adresar/handlers.rs | 2 - src/adresar/handlers/get_table_structure.rs | 104 ------------------ src/proto/descriptor.bin | Bin 10644 -> 10697 bytes src/server/mod.rs | 19 ++-- src/uctovnictvo/handlers.rs | 2 - .../handlers/get_table_structure.rs | 80 -------------- .../handlers/get_uctovnictvo_by_position.rs | 2 +- 9 files changed, 10 insertions(+), 201 deletions(-) delete mode 100644 src/adresar/handlers/get_table_structure.rs delete mode 100644 src/uctovnictvo/handlers/get_table_structure.rs diff --git a/proto/common.proto b/proto/common.proto index e54271e..1d889d8 100644 --- a/proto/common.proto +++ b/proto/common.proto @@ -1,3 +1,4 @@ +// proto/common.proto syntax = "proto3"; package multieko2.common; diff --git a/proto/table_structure.proto b/proto/table_structure.proto index 21cbcb5..e9c246f 100644 --- a/proto/table_structure.proto +++ b/proto/table_structure.proto @@ -1,3 +1,4 @@ +// proto/table_structure.proto syntax = "proto3"; package multieko2.table_structure; diff --git a/src/adresar/handlers.rs b/src/adresar/handlers.rs index 99c3808..72ae187 100644 --- a/src/adresar/handlers.rs +++ b/src/adresar/handlers.rs @@ -6,7 +6,6 @@ pub mod put_adresar; pub mod delete_adresar; pub mod get_adresar_count; pub mod get_adresar_by_position; -pub mod get_table_structure; pub use post_adresar::post_adresar; pub use get_adresar::get_adresar; @@ -14,4 +13,3 @@ pub use put_adresar::put_adresar; pub use delete_adresar::delete_adresar; pub use get_adresar_count::get_adresar_count; pub use get_adresar_by_position::get_adresar_by_position; -pub use get_table_structure::get_table_structure; diff --git a/src/adresar/handlers/get_table_structure.rs b/src/adresar/handlers/get_table_structure.rs deleted file mode 100644 index 0b98a52..0000000 --- a/src/adresar/handlers/get_table_structure.rs +++ /dev/null @@ -1,104 +0,0 @@ -// src/adresar/handlers/get_table_structure.rs -use tonic::Status; -use sqlx::PgPool; -use crate::proto::multieko2::adresar::{TableStructureResponse, TableColumn, Empty}; - -pub async fn get_table_structure( - db_pool: &PgPool, - _request: Empty, -) -> Result { - let columns = vec![ - TableColumn { - name: "firma".to_string(), - data_type: "TEXT".to_string(), - is_nullable: false, - is_primary_key: false, - }, - TableColumn { - name: "kz".to_string(), - data_type: "TEXT".to_string(), - is_nullable: true, - is_primary_key: false, - }, - TableColumn { - name: "drc".to_string(), - data_type: "TEXT".to_string(), - is_nullable: true, - is_primary_key: false, - }, - TableColumn { - name: "ulica".to_string(), - data_type: "TEXT".to_string(), - is_nullable: true, - is_primary_key: false, - }, - TableColumn { - name: "psc".to_string(), - data_type: "TEXT".to_string(), - is_nullable: true, - is_primary_key: false, - }, - TableColumn { - name: "mesto".to_string(), - data_type: "TEXT".to_string(), - is_nullable: true, - is_primary_key: false, - }, - TableColumn { - name: "stat".to_string(), - data_type: "TEXT".to_string(), - is_nullable: true, - is_primary_key: false, - }, - TableColumn { - name: "banka".to_string(), - data_type: "TEXT".to_string(), - is_nullable: true, - is_primary_key: false, - }, - TableColumn { - name: "ucet".to_string(), - data_type: "TEXT".to_string(), - is_nullable: true, - is_primary_key: false, - }, - TableColumn { - name: "skladm".to_string(), - data_type: "TEXT".to_string(), - is_nullable: true, - is_primary_key: false, - }, - TableColumn { - name: "ico".to_string(), - data_type: "TEXT".to_string(), - is_nullable: true, - is_primary_key: false, - }, - TableColumn { - name: "kontakt".to_string(), - data_type: "TEXT".to_string(), - is_nullable: true, - is_primary_key: false, - }, - TableColumn { - name: "telefon".to_string(), - data_type: "TEXT".to_string(), - is_nullable: true, - is_primary_key: false, - }, - TableColumn { - name: "skladu".to_string(), - data_type: "TEXT".to_string(), - is_nullable: true, - is_primary_key: false, - }, - TableColumn { - name: "fax".to_string(), - data_type: "TEXT".to_string(), - is_nullable: true, - is_primary_key: false, - }, - ]; - - Ok(TableStructureResponse { columns }) -} diff --git a/src/proto/descriptor.bin b/src/proto/descriptor.bin index 5a451104b6cdc4401ced7adffce1990ae9e59bf2..3dc24d74ef020453e2de9fd66fb4a422b9f6d137 100644 GIT binary patch delta 805 zcmYL`L2eU45JkIcdV1P5GbZlI*oh?@V=RIoU?dit0e|!Q1Q)upe2W>=>jd;CqiR6 zs1w1jJR0>flq#O|B|>o3L8kuIAXyS*RXdKdJuzOQKIj;_nqBXrFH;vu$I#WijueJG z?He=5h6h;&*|2C+O*>Ccb!&%6M+T39rJY7Py7n`j!^KPkzf+9@YQe?alrUmgoTnQ6 f!kf3f42=zM`jYP1xMd>9n$@dBkTrKV`D*naXt+0f delta 756 zcmZvaJx;?w5QTSVe`1eq6fYzpkrE(8fcOze6r2K4q^05lK`6b&5s>JpIRU4jqUJJ) zH*0Tb==SrxH$PAQT)r-ezhCIN`O@rzRmxp*#<~nfsUR;3MyoOBOjZSBRG*oRRT}TC zil6bc>NI}V^3Dcau(g_?x4S1?vJ-GZ(?lYi9VRm2-q@q#*bW1ox{U1zDwmC7JCb&8 zauF>6v~!caL?Ya8N1HsUmaSxCO6~jcZ`O&PSM%MBN^VnSno2#w1yM&f!+kc@kh3IKR zW6Bai$a$3r?YLieHk1k)btR2(ij7VB7kOw>5x!zD?0iVO-1rE-l6)tW^vhmagn5Au>}Kby)LK4x0eop=OLs(s8&2rJh6 i=c$H%_04T(gD}vtE6JU~&lABG7FUU&GvVXiEf&8^K__eg diff --git a/src/server/mod.rs b/src/server/mod.rs index 1c7fc0d..37bb42c 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -23,15 +23,6 @@ use crate::proto::multieko2::uctovnictvo::{ uctovnictvo_server::{Uctovnictvo, UctovnictvoServer}, PostUctovnictvoRequest, UctovnictvoResponse, GetUctovnictvoRequest, PutUctovnictvoRequest, }; -use crate::proto::multieko2::table_structure::{ - table_structure_service_server::{TableStructureService, TableStructureServiceServer}, - TableStructureResponse -}; -use crate::proto::multieko2::{ - common::{Empty, CountResponse, PositionRequest}, - table_structure::{TableStructureResponse, TableColumn} -}; - pub struct AdresarService { db_pool: sqlx::PgPool, } @@ -123,7 +114,7 @@ impl Uctovnictvo for UctovnictvoService { async fn get_uctovnictvo_by_position( &self, - request: Request, + request: Request, ) -> Result, Status> { let response = get_uctovnictvo_by_position(&self.db_pool, request.into_inner()).await?; Ok(Response::new(response)) @@ -144,14 +135,18 @@ impl TableStructureService for TableStructureHandler { &self, request: Request, ) -> Result, Status> { - handlers::get_adresar_table_structure(&self.db_pool, request.into_inner()).await + let response = handlers::get_adresar_table_structure(&self.db_pool, request.into_inner()) + .await?; + Ok(Response::new(response)) } async fn get_uctovnictvo_table_structure( &self, request: Request, ) -> Result, Status> { - handlers::get_uctovnictvo_table_structure(&self.db_pool, request.into_inner()).await + let response = + handlers::get_uctovnictvo_table_structure(&self.db_pool, request.into_inner()).await?; + Ok(Response::new(response)) } } diff --git a/src/uctovnictvo/handlers.rs b/src/uctovnictvo/handlers.rs index 4a6e75b..ed289b7 100644 --- a/src/uctovnictvo/handlers.rs +++ b/src/uctovnictvo/handlers.rs @@ -4,11 +4,9 @@ pub mod get_uctovnictvo; pub mod get_uctovnictvo_count; pub mod get_uctovnictvo_by_position; pub mod put_uctovnictvo; -pub mod get_table_structure; pub use post_uctovnictvo::post_uctovnictvo; pub use get_uctovnictvo::get_uctovnictvo; pub use get_uctovnictvo_count::get_uctovnictvo_count; pub use get_uctovnictvo_by_position::get_uctovnictvo_by_position; pub use put_uctovnictvo::put_uctovnictvo; -pub use get_table_structure::get_table_structure; diff --git a/src/uctovnictvo/handlers/get_table_structure.rs b/src/uctovnictvo/handlers/get_table_structure.rs deleted file mode 100644 index d8f7ded..0000000 --- a/src/uctovnictvo/handlers/get_table_structure.rs +++ /dev/null @@ -1,80 +0,0 @@ -// src/uctovnictvo/handlers/get_table_structure.rs -use tonic::Status; -use sqlx::PgPool; -use crate::proto::multieko2::adresar::{TableStructureResponse, TableColumn, Empty}; - -pub async fn get_table_structure( - db_pool: &PgPool, - _request: Empty, -) -> Result { - let columns = vec![ - TableColumn { - name: "adresar_id".to_string(), - data_type: "BIGINT".to_string(), - is_nullable: false, - is_primary_key: false, - }, - TableColumn { - name: "c_dokladu".to_string(), - data_type: "TEXT".to_string(), - is_nullable: false, - is_primary_key: false, - }, - TableColumn { - name: "datum".to_string(), - data_type: "DATE".to_string(), - is_nullable: false, - is_primary_key: false, - }, - TableColumn { - name: "c_faktury".to_string(), - data_type: "TEXT".to_string(), - is_nullable: false, - is_primary_key: false, - }, - TableColumn { - name: "obsah".to_string(), - data_type: "TEXT".to_string(), - is_nullable: true, - is_primary_key: false, - }, - TableColumn { - name: "stredisko".to_string(), - data_type: "TEXT".to_string(), - is_nullable: true, - is_primary_key: false, - }, - TableColumn { - name: "c_uctu".to_string(), - data_type: "TEXT".to_string(), - is_nullable: true, - is_primary_key: false, - }, - TableColumn { - name: "md".to_string(), - data_type: "TEXT".to_string(), - is_nullable: true, - is_primary_key: false, - }, - TableColumn { - name: "identif".to_string(), - data_type: "TEXT".to_string(), - is_nullable: true, - is_primary_key: false, - }, - TableColumn { - name: "poznanka".to_string(), - data_type: "TEXT".to_string(), - is_nullable: true, - is_primary_key: false, - }, - TableColumn { - name: "firma".to_string(), - data_type: "TEXT".to_string(), - is_nullable: false, - is_primary_key: false, - }, - ]; - - Ok(TableStructureResponse { columns }) -} diff --git a/src/uctovnictvo/handlers/get_uctovnictvo_by_position.rs b/src/uctovnictvo/handlers/get_uctovnictvo_by_position.rs index ac08ea1..aabadd1 100644 --- a/src/uctovnictvo/handlers/get_uctovnictvo_by_position.rs +++ b/src/uctovnictvo/handlers/get_uctovnictvo_by_position.rs @@ -1,7 +1,7 @@ // src/uctovnictvo/handlers/get_uctovnictvo_by_position.rs use tonic::Status; use sqlx::PgPool; -use crate::proto::multieko2::adresar::PositionRequest; +use crate::proto::multieko2::common::PositionRequest; use super::get_uctovnictvo; pub async fn get_uctovnictvo_by_position(