From 73ac6d16d31131fc82b0dd5c5e930ff78c4db582 Mon Sep 17 00:00:00 2001 From: filipriec Date: Sat, 22 Feb 2025 17:05:58 +0100 Subject: [PATCH] docs for table structure --- .../docs/response.txt} | 17 +- .../handlers/table_structure.rs | 148 +++++++++++++++++- src/uctovnictvo/docs/get_examples.txt | 57 ------- 3 files changed, 151 insertions(+), 71 deletions(-) rename src/{adresar/docs/get_database_scheme.txt => table_structure/docs/response.txt} (85%) diff --git a/src/adresar/docs/get_database_scheme.txt b/src/table_structure/docs/response.txt similarity index 85% rename from src/adresar/docs/get_database_scheme.txt rename to src/table_structure/docs/response.txt index 79bf73e..7c628c3 100644 --- a/src/adresar/docs/get_database_scheme.txt +++ b/src/table_structure/docs/response.txt @@ -1,12 +1,11 @@ -❯ grpcurl -plaintext localhost:50051 multieko2.Adresar/GetTableStructure - +Adresar response: +❯ grpcurl -plaintext \ + -proto proto/table_structure.proto \ + -import-path proto \ + localhost:50051 \ + multieko2.table_structure.TableStructureService/GetAdresarTableStructure { "columns": [ - { - "name": "id", - "dataType": "BIGSERIAL", - "isPrimaryKey": true - }, { "name": "firma", "dataType": "TEXT" @@ -80,10 +79,6 @@ "name": "fax", "dataType": "TEXT", "isNullable": true - }, - { - "name": "created_at", - "dataType": "TIMESTAMPTZ" } ] } diff --git a/src/table_structure/handlers/table_structure.rs b/src/table_structure/handlers/table_structure.rs index 90431c0..c653e6c 100644 --- a/src/table_structure/handlers/table_structure.rs +++ b/src/table_structure/handlers/table_structure.rs @@ -1,4 +1,4 @@ -// src/table_structure/handlers.rs +// src/table_structure/handlers/table_structure.rs use tonic::Status; use sqlx::PgPool; use crate::proto::multieko2::{ @@ -17,7 +17,90 @@ pub async fn get_adresar_table_structure( is_nullable: false, is_primary_key: false, }, - // ... other columns from original adresar handler + 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 }) } @@ -33,7 +116,66 @@ pub async fn get_uctovnictvo_table_structure( is_nullable: false, is_primary_key: false, }, - // ... other columns from original uctovnictvo handler + 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/docs/get_examples.txt b/src/uctovnictvo/docs/get_examples.txt index 094c2af..d079642 100644 --- a/src/uctovnictvo/docs/get_examples.txt +++ b/src/uctovnictvo/docs/get_examples.txt @@ -39,60 +39,3 @@ "firma": "AAA" } - -❯ grpcurl -plaintext -d '{}' localhost:50051 multieko2.uctovnictvo.Uctovnictvo/GetTableStructure - -{ - "columns": [ - { - "name": "adresar_id", - "dataType": "BIGINT" - }, - { - "name": "c_dokladu", - "dataType": "TEXT" - }, - { - "name": "datum", - "dataType": "DATE" - }, - { - "name": "c_faktury", - "dataType": "TEXT" - }, - { - "name": "obsah", - "dataType": "TEXT", - "isNullable": true - }, - { - "name": "stredisko", - "dataType": "TEXT", - "isNullable": true - }, - { - "name": "c_uctu", - "dataType": "TEXT", - "isNullable": true - }, - { - "name": "md", - "dataType": "TEXT", - "isNullable": true - }, - { - "name": "identif", - "dataType": "TEXT", - "isNullable": true - }, - { - "name": "poznanka", - "dataType": "TEXT", - "isNullable": true - }, - { - "name": "firma", - "dataType": "TEXT" - } - ] -}