From 924f7d093f1560f269feddd12415d55e4a53e4d1 Mon Sep 17 00:00:00 2001 From: filipriec Date: Sat, 22 Feb 2025 00:16:39 +0100 Subject: [PATCH] uctovnictvo table structure --- proto/uctovnictvo.proto | 1 + src/proto/descriptor.bin | Bin 10168 -> 10313 bytes src/server/mod.rs | 13 ++- src/uctovnictvo/handlers.rs | 2 + .../handlers/get_table_structure.rs | 80 ++++++++++++++++++ 5 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 src/uctovnictvo/handlers/get_table_structure.rs 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 bc29de1315582f7bd15a74a577407a0254ba3d82..84b6f967a0d59e796290f5f8f32bf5413ba3af85 100644 GIT binary patch delta 2194 zcmX|?yKWOf6oz*$w%5Ca*kiBPm*7i$i;dzqz8l5qkm#VN14WcUh<+a;4Lyh&DGfXV z1uaj(L-3#V+0*fJ=9_N<~^Nr=EQyoo&-4x3dwI|Nh7ruSu#k6yC4X(^_(qvXA1u|)&o=W z+X1$-p7xw6+jIj8*t~3uv;ie7ECk26 z^6;l~msDiA#_~#7VpwB&rBdYXr&y^IuqH5ceKDF!7Q*SEG5|x zTqJc^S(Cb4nzBpLm##@&4p>d<^3KGz#yjSL#Zs3C7Ki0*1}v^dxLiWtzTiyVI-V84 z)rBj7tA{7q3|zfb=8xh#)37m*d|(a1d|-_*+tLTth-!=#ooUMDk|MaKa7A#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7*i0}oZ^pu+2W-Z|Dh>0_ZHr%(#5=d?>34-5xN|lZ6}a;_;U|ZA zb2%NEHS8Qz}Kt#-a)Ck{?Htu`A)o*cERd zEyS((O;G_`35H_L2B8CNEf@*AW`oe9$&?k+Wb8)b$k>f=Wb8)bNZ5_UVQ?#PBD}PV|T)lu{(()V|NmVzsfzosm_Gm3r523Sy=Rd?O9k&!d|hk zD3Er=Sc($d6&s5R+!Y(E$=GW)76rI#i6ddJSy=RdU9+%SL)e4dB?)^FjD$U~uoz6i z9oSe+#vbK#Wb9EmGWIB!Nx~jkSmW(YaCZ`xUigNEH6-jU3yT8F-LiS8Fn9}LWBQ9l SiS=%)wGYKFU+=%&@BRag>uJ{j 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 }) +}