more changes to the structure of the project

This commit is contained in:
filipriec
2025-02-22 13:41:42 +01:00
parent 449f1bd14e
commit c9da24e464
9 changed files with 10 additions and 201 deletions

View File

@@ -1,3 +1,4 @@
// proto/common.proto
syntax = "proto3"; syntax = "proto3";
package multieko2.common; package multieko2.common;

View File

@@ -1,3 +1,4 @@
// proto/table_structure.proto
syntax = "proto3"; syntax = "proto3";
package multieko2.table_structure; package multieko2.table_structure;

View File

@@ -6,7 +6,6 @@ pub mod put_adresar;
pub mod delete_adresar; pub mod delete_adresar;
pub mod get_adresar_count; pub mod get_adresar_count;
pub mod get_adresar_by_position; pub mod get_adresar_by_position;
pub mod get_table_structure;
pub use post_adresar::post_adresar; pub use post_adresar::post_adresar;
pub use get_adresar::get_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 delete_adresar::delete_adresar;
pub use get_adresar_count::get_adresar_count; pub use get_adresar_count::get_adresar_count;
pub use get_adresar_by_position::get_adresar_by_position; pub use get_adresar_by_position::get_adresar_by_position;
pub use get_table_structure::get_table_structure;

View File

@@ -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<TableStructureResponse, Status> {
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 })
}

Binary file not shown.

View File

@@ -23,15 +23,6 @@ use crate::proto::multieko2::uctovnictvo::{
uctovnictvo_server::{Uctovnictvo, UctovnictvoServer}, uctovnictvo_server::{Uctovnictvo, UctovnictvoServer},
PostUctovnictvoRequest, UctovnictvoResponse, GetUctovnictvoRequest, PutUctovnictvoRequest, 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 { pub struct AdresarService {
db_pool: sqlx::PgPool, db_pool: sqlx::PgPool,
} }
@@ -123,7 +114,7 @@ impl Uctovnictvo for UctovnictvoService {
async fn get_uctovnictvo_by_position( async fn get_uctovnictvo_by_position(
&self, &self,
request: Request<crate::proto::multieko2::adresar::PositionRequest>, request: Request<PositionRequest>,
) -> Result<Response<UctovnictvoResponse>, Status> { ) -> Result<Response<UctovnictvoResponse>, Status> {
let response = get_uctovnictvo_by_position(&self.db_pool, request.into_inner()).await?; let response = get_uctovnictvo_by_position(&self.db_pool, request.into_inner()).await?;
Ok(Response::new(response)) Ok(Response::new(response))
@@ -144,14 +135,18 @@ impl TableStructureService for TableStructureHandler {
&self, &self,
request: Request<crate::proto::multieko2::common::Empty>, request: Request<crate::proto::multieko2::common::Empty>,
) -> Result<Response<TableStructureResponse>, Status> { ) -> Result<Response<TableStructureResponse>, 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( async fn get_uctovnictvo_table_structure(
&self, &self,
request: Request<crate::proto::multieko2::common::Empty>, request: Request<crate::proto::multieko2::common::Empty>,
) -> Result<Response<TableStructureResponse>, Status> { ) -> Result<Response<TableStructureResponse>, 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))
} }
} }

View File

@@ -4,11 +4,9 @@ pub mod get_uctovnictvo;
pub mod get_uctovnictvo_count; pub mod get_uctovnictvo_count;
pub mod get_uctovnictvo_by_position; pub mod get_uctovnictvo_by_position;
pub mod put_uctovnictvo; pub mod put_uctovnictvo;
pub mod get_table_structure;
pub use post_uctovnictvo::post_uctovnictvo; pub use post_uctovnictvo::post_uctovnictvo;
pub use get_uctovnictvo::get_uctovnictvo; pub use get_uctovnictvo::get_uctovnictvo;
pub use get_uctovnictvo_count::get_uctovnictvo_count; pub use get_uctovnictvo_count::get_uctovnictvo_count;
pub use get_uctovnictvo_by_position::get_uctovnictvo_by_position; pub use get_uctovnictvo_by_position::get_uctovnictvo_by_position;
pub use put_uctovnictvo::put_uctovnictvo; pub use put_uctovnictvo::put_uctovnictvo;
pub use get_table_structure::get_table_structure;

View File

@@ -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<TableStructureResponse, Status> {
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 })
}

View File

@@ -1,7 +1,7 @@
// src/uctovnictvo/handlers/get_uctovnictvo_by_position.rs // src/uctovnictvo/handlers/get_uctovnictvo_by_position.rs
use tonic::Status; use tonic::Status;
use sqlx::PgPool; use sqlx::PgPool;
use crate::proto::multieko2::adresar::PositionRequest; use crate::proto::multieko2::common::PositionRequest;
use super::get_uctovnictvo; use super::get_uctovnictvo;
pub async fn get_uctovnictvo_by_position( pub async fn get_uctovnictvo_by_position(