fixing errors, slowly moving forwards

This commit is contained in:
filipriec
2025-02-21 19:06:01 +01:00
parent e4c14e5a1e
commit 4b10b0b213
9 changed files with 22 additions and 11 deletions

Binary file not shown.

View File

@@ -1,6 +1,9 @@
// src/proto/mod.rs
pub mod multieko2 {
tonic::include_proto!("multieko2");
pub mod uctovnictvo {
tonic::include_proto!("multieko2.uctovnictvo");
}
// Include the file descriptor set
pub const FILE_DESCRIPTOR_SET: &[u8] = include_bytes!("descriptor.bin");

View File

@@ -8,11 +8,14 @@ use crate::uctovnictvo::handlers::post_uctovnictvo;
use crate::proto::multieko2::{
PostAdresarRequest, AdresarResponse, GetAdresarRequest, PutAdresarRequest,
DeleteAdresarRequest, DeleteAdresarResponse, PositionRequest, CountResponse, Empty,
TableStructureResponse,
TableStructureResponse, PostUctovnictvoRequest, UctovnictvoResponse,
adresar_server::{Adresar, AdresarServer},
uctovnictvo_server::{Uctovnictvo, UctovnictvoServer},
FILE_DESCRIPTOR_SET,
};
use crate::proto::multieko2::uctovnictvo::{
uctovnictvo_server::{Uctovnictvo, UctovnictvoServer},
PostUctovnictvoRequest, UctovnictvoResponse
};
pub struct AdresarService {
db_pool: sqlx::PgPool,

View File

@@ -3,15 +3,15 @@ use tonic::Status;
use sqlx::PgPool;
use chrono::NaiveDate;
use crate::uctovnictvo::models::Uctovnictvo;
use crate::proto::multieko2::{PostUctovnictvoRequest, UctovnictvoResponse};
use crate::proto::multieko2::uctovnictvo::{PostUctovnictvoRequest, UctovnictvoResponse};
pub async fn post_uctovnictvo(
db_pool: &PgPool,
request: PostUctovnictvoRequest,
) -> Result<UctovnictvoResponse, Status> {
// Parse the date string into NaiveDate
let datum = NaiveDate::parse_from_str(&request.datum, "%Y-%m-%d")
.map_err(|e| Status::invalid_argument(format!("Invalid date format: {}", e)))?;
let datum = chrono::NaiveDate::parse_from_str(&request.datum, "%Y-%m-%d")
.map_err(|e| Status::invalid_argument(format!("Invalid date: {}", e)))?;
let uctovnictvo = sqlx::query_as!(
Uctovnictvo,

View File

@@ -2,13 +2,13 @@
use chrono::NaiveDate;
use serde::{Deserialize, Serialize};
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, sqlx::FromRow, Serialize, Deserialize)]
pub struct Uctovnictvo {
pub id: i64,
pub deleted: bool,
pub adresar_id: i64,
pub c_dokladu: String,
pub datum: NaiveDate, // Use chrono::NaiveDate for better date handling
pub datum: chrono::NaiveDate,
pub c_faktury: String,
pub obsah: Option<String>,
pub stredisko: Option<String>,