grpc endpoint showing database schema for the frontend, now working
This commit is contained in:
@@ -6,6 +6,7 @@ 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;
|
||||
@@ -13,3 +14,4 @@ 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;
|
||||
|
||||
116
src/adresar/handlers/get_table_structure.rs
Normal file
116
src/adresar/handlers/get_table_structure.rs
Normal file
@@ -0,0 +1,116 @@
|
||||
// src/adresar/handlers/get_table_structure.rs
|
||||
use tonic::Status;
|
||||
use sqlx::PgPool;
|
||||
use crate::proto::multieko2::{TableStructureResponse, TableColumn, Empty};
|
||||
|
||||
pub async fn get_table_structure(
|
||||
db_pool: &PgPool,
|
||||
_request: Empty,
|
||||
) -> Result<TableStructureResponse, Status> {
|
||||
let columns = vec![
|
||||
TableColumn {
|
||||
name: "id".to_string(),
|
||||
data_type: "BIGSERIAL".to_string(), // Updated field name
|
||||
is_nullable: false,
|
||||
is_primary_key: true,
|
||||
},
|
||||
TableColumn {
|
||||
name: "firma".to_string(),
|
||||
data_type: "TEXT".to_string(), // Updated field name
|
||||
is_nullable: false,
|
||||
is_primary_key: false,
|
||||
},
|
||||
TableColumn {
|
||||
name: "kz".to_string(),
|
||||
data_type: "TEXT".to_string(), // Updated field name
|
||||
is_nullable: true,
|
||||
is_primary_key: false,
|
||||
},
|
||||
TableColumn {
|
||||
name: "drc".to_string(),
|
||||
data_type: "TEXT".to_string(), // Updated field name
|
||||
is_nullable: true,
|
||||
is_primary_key: false,
|
||||
},
|
||||
TableColumn {
|
||||
name: "ulica".to_string(),
|
||||
data_type: "TEXT".to_string(), // Updated field name
|
||||
is_nullable: true,
|
||||
is_primary_key: false,
|
||||
},
|
||||
TableColumn {
|
||||
name: "psc".to_string(),
|
||||
data_type: "TEXT".to_string(), // Updated field name
|
||||
is_nullable: true,
|
||||
is_primary_key: false,
|
||||
},
|
||||
TableColumn {
|
||||
name: "mesto".to_string(),
|
||||
data_type: "TEXT".to_string(), // Updated field name
|
||||
is_nullable: true,
|
||||
is_primary_key: false,
|
||||
},
|
||||
TableColumn {
|
||||
name: "stat".to_string(),
|
||||
data_type: "TEXT".to_string(), // Updated field name
|
||||
is_nullable: true,
|
||||
is_primary_key: false,
|
||||
},
|
||||
TableColumn {
|
||||
name: "banka".to_string(),
|
||||
data_type: "TEXT".to_string(), // Updated field name
|
||||
is_nullable: true,
|
||||
is_primary_key: false,
|
||||
},
|
||||
TableColumn {
|
||||
name: "ucet".to_string(),
|
||||
data_type: "TEXT".to_string(), // Updated field name
|
||||
is_nullable: true,
|
||||
is_primary_key: false,
|
||||
},
|
||||
TableColumn {
|
||||
name: "skladm".to_string(),
|
||||
data_type: "TEXT".to_string(), // Updated field name
|
||||
is_nullable: true,
|
||||
is_primary_key: false,
|
||||
},
|
||||
TableColumn {
|
||||
name: "ico".to_string(),
|
||||
data_type: "TEXT".to_string(), // Updated field name
|
||||
is_nullable: true,
|
||||
is_primary_key: false,
|
||||
},
|
||||
TableColumn {
|
||||
name: "kontakt".to_string(),
|
||||
data_type: "TEXT".to_string(), // Updated field name
|
||||
is_nullable: true,
|
||||
is_primary_key: false,
|
||||
},
|
||||
TableColumn {
|
||||
name: "telefon".to_string(),
|
||||
data_type: "TEXT".to_string(), // Updated field name
|
||||
is_nullable: true,
|
||||
is_primary_key: false,
|
||||
},
|
||||
TableColumn {
|
||||
name: "skladu".to_string(),
|
||||
data_type: "TEXT".to_string(), // Updated field name
|
||||
is_nullable: true,
|
||||
is_primary_key: false,
|
||||
},
|
||||
TableColumn {
|
||||
name: "fax".to_string(),
|
||||
data_type: "TEXT".to_string(), // Updated field name
|
||||
is_nullable: true,
|
||||
is_primary_key: false,
|
||||
},
|
||||
TableColumn {
|
||||
name: "created_at".to_string(),
|
||||
data_type: "TIMESTAMPTZ".to_string(), // Updated field name
|
||||
is_nullable: false,
|
||||
is_primary_key: false,
|
||||
},
|
||||
];
|
||||
|
||||
Ok(TableStructureResponse { columns })
|
||||
}
|
||||
Reference in New Issue
Block a user