redesigned proto files
This commit is contained in:
2
build.rs
2
build.rs
@@ -4,7 +4,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
.build_server(true)
|
||||
.file_descriptor_set_path("src/proto/descriptor.bin")
|
||||
.compile_protos(
|
||||
&["proto/api.proto", "proto/uctovnictvo.proto"],
|
||||
&["proto/adresar.proto", "proto/uctovnictvo.proto"],
|
||||
&["proto"],
|
||||
)?;
|
||||
Ok(())
|
||||
|
||||
@@ -1,25 +1,24 @@
|
||||
// proto/api.proto
|
||||
// proto/adresar.proto
|
||||
syntax = "proto3";
|
||||
|
||||
package multieko2;
|
||||
package multieko2.adresar;
|
||||
|
||||
service Adresar {
|
||||
rpc PostAdresar (PostAdresarRequest) returns (AdresarResponse);
|
||||
rpc GetAdresar (GetAdresarRequest) returns (AdresarResponse);
|
||||
rpc PutAdresar (PutAdresarRequest) returns (AdresarResponse);
|
||||
rpc DeleteAdresar (DeleteAdresarRequest) returns (DeleteAdresarResponse);
|
||||
rpc GetAdresarCount (Empty) returns (CountResponse); // New endpoint
|
||||
rpc GetAdresarByPosition (PositionRequest) returns (AdresarResponse); // New endpoint
|
||||
rpc GetTableStructure (Empty) returns (TableStructureResponse); // New endpoint for table structure
|
||||
rpc GetAdresarCount (Empty) returns (CountResponse);
|
||||
rpc GetAdresarByPosition (PositionRequest) returns (AdresarResponse);
|
||||
rpc GetTableStructure (Empty) returns (TableStructureResponse);
|
||||
}
|
||||
|
||||
// Existing messages
|
||||
message GetAdresarRequest {
|
||||
int64 id = 1; // The ID of the Adresar entry to retrieve
|
||||
int64 id = 1;
|
||||
}
|
||||
|
||||
message DeleteAdresarRequest {
|
||||
int64 id = 1; // The ID of the Adresar entry to delete
|
||||
int64 id = 1;
|
||||
}
|
||||
|
||||
message PostAdresarRequest {
|
||||
@@ -79,28 +78,26 @@ message PutAdresarRequest {
|
||||
}
|
||||
|
||||
message DeleteAdresarResponse {
|
||||
bool success = 1; // Indicates whether the deletion was successful
|
||||
bool success = 1;
|
||||
}
|
||||
|
||||
// New messages for the additional endpoints
|
||||
message Empty {} // Empty request for count
|
||||
message Empty {}
|
||||
|
||||
message CountResponse {
|
||||
int64 count = 1; // Response with the count of items
|
||||
int64 count = 1;
|
||||
}
|
||||
|
||||
message PositionRequest {
|
||||
int64 position = 1; // Request with the position of the item to retrieve
|
||||
int64 position = 1;
|
||||
}
|
||||
|
||||
// New messages for the table structure endpoint
|
||||
message TableStructureResponse {
|
||||
repeated TableColumn columns = 1; // List of columns in the table
|
||||
repeated TableColumn columns = 1;
|
||||
}
|
||||
|
||||
message TableColumn {
|
||||
string name = 1; // Name of the column
|
||||
string data_type = 2; // Data type of the column (e.g., TEXT, INT, etc.)
|
||||
bool is_nullable = 3; // Whether the column allows NULL values
|
||||
bool is_primary_key = 4; // Whether the column is a primary key
|
||||
string name = 1;
|
||||
string data_type = 2;
|
||||
bool is_nullable = 3;
|
||||
bool is_primary_key = 4;
|
||||
}
|
||||
@@ -3,6 +3,8 @@ syntax = "proto3";
|
||||
|
||||
package multieko2.uctovnictvo;
|
||||
|
||||
import "adresar.proto";
|
||||
|
||||
service Uctovnictvo {
|
||||
rpc PostUctovnictvo (PostUctovnictvoRequest) returns (UctovnictvoResponse);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// src/adresar/handlers/delete_adresar.rs
|
||||
use tonic::Status;
|
||||
use sqlx::PgPool;
|
||||
use crate::proto::multieko2::{DeleteAdresarRequest, DeleteAdresarResponse};
|
||||
use crate::proto::multieko2::adresar::{DeleteAdresarRequest, DeleteAdresarResponse};
|
||||
|
||||
pub async fn delete_adresar(
|
||||
db_pool: &PgPool,
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
use tonic::Status;
|
||||
use sqlx::PgPool;
|
||||
use crate::adresar::models::Adresar;
|
||||
use crate::proto::multieko2::{GetAdresarRequest, AdresarResponse};
|
||||
use crate::proto::multieko2::adresar::{GetAdresarRequest, AdresarResponse};
|
||||
|
||||
pub async fn get_adresar(
|
||||
db_pool: &PgPool,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// src/adresar/handlers/get_adresar_by_position.rs
|
||||
use tonic::{Status};
|
||||
use sqlx::PgPool;
|
||||
use crate::proto::multieko2::{PositionRequest, AdresarResponse, GetAdresarRequest};
|
||||
use crate::proto::multieko2::adresar::{PositionRequest, AdresarResponse, GetAdresarRequest};
|
||||
use super::get_adresar;
|
||||
|
||||
pub async fn get_adresar_by_position(
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// src/adresar/handlers/get_adresar_count.rs
|
||||
use tonic::Status;
|
||||
use sqlx::PgPool;
|
||||
use crate::proto::multieko2::{CountResponse, Empty};
|
||||
use crate::proto::multieko2::adresar::{CountResponse, Empty};
|
||||
|
||||
pub async fn get_adresar_count(
|
||||
db_pool: &PgPool,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// src/adresar/handlers/get_table_structure.rs
|
||||
use tonic::Status;
|
||||
use sqlx::PgPool;
|
||||
use crate::proto::multieko2::{TableStructureResponse, TableColumn, Empty};
|
||||
use crate::proto::multieko2::adresar::{TableStructureResponse, TableColumn, Empty};
|
||||
|
||||
pub async fn get_table_structure(
|
||||
db_pool: &PgPool,
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
use tonic::Status;
|
||||
use sqlx::PgPool;
|
||||
use crate::adresar::models::Adresar;
|
||||
use crate::proto::multieko2::{PostAdresarRequest, AdresarResponse};
|
||||
use crate::proto::multieko2::adresar::{PostAdresarRequest, AdresarResponse};
|
||||
|
||||
pub async fn post_adresar(
|
||||
db_pool: &PgPool,
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
use tonic::Status;
|
||||
use sqlx::PgPool;
|
||||
use crate::adresar::models::Adresar;
|
||||
use crate::proto::multieko2::{PutAdresarRequest, AdresarResponse};
|
||||
use crate::proto::multieko2::adresar::{PutAdresarRequest, AdresarResponse};
|
||||
|
||||
pub async fn put_adresar(
|
||||
db_pool: &PgPool,
|
||||
|
||||
Binary file not shown.
@@ -1,10 +1,14 @@
|
||||
// src/proto/mod.rs
|
||||
pub mod multieko2 {
|
||||
tonic::include_proto!("multieko2");
|
||||
|
||||
pub mod adresar {
|
||||
tonic::include_proto!("multieko2.adresar");
|
||||
}
|
||||
|
||||
pub mod uctovnictvo {
|
||||
tonic::include_proto!("multieko2.uctovnictvo");
|
||||
}
|
||||
|
||||
// Include the file descriptor set
|
||||
pub const FILE_DESCRIPTOR_SET: &[u8] = include_bytes!("descriptor.bin");
|
||||
}
|
||||
|
||||
@@ -6,11 +6,13 @@ use crate::adresar::handlers::{
|
||||
};
|
||||
use crate::uctovnictvo::handlers::post_uctovnictvo;
|
||||
use crate::proto::multieko2::{
|
||||
FILE_DESCRIPTOR_SET,
|
||||
};
|
||||
use crate::proto::multieko2::adresar::{
|
||||
adresar_server::{Adresar, AdresarServer},
|
||||
PostAdresarRequest, AdresarResponse, GetAdresarRequest, PutAdresarRequest,
|
||||
DeleteAdresarRequest, DeleteAdresarResponse, PositionRequest, CountResponse, Empty,
|
||||
TableStructureResponse,
|
||||
adresar_server::{Adresar, AdresarServer},
|
||||
FILE_DESCRIPTOR_SET,
|
||||
};
|
||||
use crate::proto::multieko2::uctovnictvo::{
|
||||
uctovnictvo_server::{Uctovnictvo, UctovnictvoServer},
|
||||
|
||||
Reference in New Issue
Block a user