diff --git a/proto/uctovnictvo.proto b/proto/uctovnictvo.proto index 24a2485..0209b15 100644 --- a/proto/uctovnictvo.proto +++ b/proto/uctovnictvo.proto @@ -11,6 +11,7 @@ service Uctovnictvo { rpc GetUctovnictvoCount (multieko2.adresar.Empty) returns (multieko2.adresar.CountResponse); rpc GetUctovnictvoByPosition (multieko2.adresar.PositionRequest) returns (UctovnictvoResponse); rpc PutUctovnictvo (PutUctovnictvoRequest) returns (UctovnictvoResponse); + rpc GetTableStructure (multieko2.adresar.Empty) returns (multieko2.adresar.TableStructureResponse); } message PostUctovnictvoRequest { diff --git a/src/proto/descriptor.bin b/src/proto/descriptor.bin index bc29de1..84b6f96 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 468c057..d3170ca 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -4,7 +4,10 @@ use tonic_reflection::server::Builder as ReflectionBuilder; use crate::adresar::handlers::{ post_adresar, get_adresar, put_adresar, delete_adresar, get_adresar_count, get_adresar_by_position, get_table_structure }; -use crate::uctovnictvo::handlers::{post_uctovnictvo, get_uctovnictvo, get_uctovnictvo_count, get_uctovnictvo_by_position, put_uctovnictvo,}; +use crate::uctovnictvo::handlers::{ + post_uctovnictvo, get_uctovnictvo, get_uctovnictvo_count, get_uctovnictvo_by_position, + put_uctovnictvo, get_table_structure as get_uctovnictvo_table_structure, +}; use crate::proto::multieko2::{ FILE_DESCRIPTOR_SET, }; @@ -128,6 +131,14 @@ impl Uctovnictvo for UctovnictvoService { let response = put_uctovnictvo(&self.db_pool, request.into_inner()).await?; Ok(Response::new(response)) } + + async fn get_table_structure( + &self, + request: Request, + ) -> Result, Status> { + let response = get_uctovnictvo_table_structure(&self.db_pool, request.into_inner()).await?; + Ok(Response::new(response)) + } } pub async fn run_server(db_pool: sqlx::PgPool) -> Result<(), Box> { diff --git a/src/uctovnictvo/handlers.rs b/src/uctovnictvo/handlers.rs index ed289b7..4a6e75b 100644 --- a/src/uctovnictvo/handlers.rs +++ b/src/uctovnictvo/handlers.rs @@ -4,9 +4,11 @@ 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 new file mode 100644 index 0000000..d8f7ded --- /dev/null +++ b/src/uctovnictvo/handlers/get_table_structure.rs @@ -0,0 +1,80 @@ +// 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 }) +}