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 5a45110..3dc24d7 100644 Binary files a/src/proto/descriptor.bin and b/src/proto/descriptor.bin differ 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(