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

4
Cargo.lock generated
View File

@@ -2161,6 +2161,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6a007b6936676aa9ab40207cde35daab0a04b823be8ae004368c0793b96a61e0"
dependencies = [
"bytes",
"chrono",
"crc",
"crossbeam-queue",
"either",
@@ -2239,6 +2240,7 @@ dependencies = [
"bitflags",
"byteorder",
"bytes",
"chrono",
"crc",
"digest",
"dotenvy",
@@ -2281,6 +2283,7 @@ dependencies = [
"base64",
"bitflags",
"byteorder",
"chrono",
"crc",
"dotenvy",
"etcetera",
@@ -2316,6 +2319,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f85ca71d3a5b24e64e1d08dd8fe36c6c95c339a896cc33068148906784620540"
dependencies = [
"atoi",
"chrono",
"flume",
"futures-channel",
"futures-core",

View File

@@ -4,7 +4,7 @@ version = "0.1.0"
edition = "2021"
[dependencies]
chrono = "0.4.39"
chrono = { version = "0.4.39", features = ["serde"] }
clap = { version = "4.5.29", features = ["derive"] }
console = "0.15.10"
crossterm = "0.28.1"
@@ -15,7 +15,7 @@ ratatui = "0.29.0"
serde = { version = "1.0.217", features = ["derive"] }
serde_json = "1.0.138"
serde_with = "3.12.0"
sqlx = { version = "0.8.3", features = ["postgres", "runtime-tokio", "runtime-tokio-native-tls", "time"] }
sqlx = { version = "0.8.3", features = ["chrono", "postgres", "runtime-tokio", "runtime-tokio-native-tls", "time"] }
tokio = { version = "1.43.0", features = ["full", "macros"] }
toml = "0.8.20"
tonic = "0.12.3"

View File

@@ -2,8 +2,9 @@
fn main() -> Result<(), Box<dyn std::error::Error>> {
tonic_build::configure()
.build_server(true)
.file_descriptor_set_path("src/proto/descriptor.bin")
.compile_protos(
&["proto/api.proto", "proto/uctovnictvo.proto"], // Include both proto files
&["proto/api.proto", "proto/uctovnictvo.proto"],
&["proto"],
)?;
Ok(())

View File

@@ -1,7 +1,7 @@
// proto/uctovnictvo.proto
syntax = "proto3";
package multieko2;
package multieko2.uctovnictvo;
service Uctovnictvo {
rpc PostUctovnictvo (PostUctovnictvoRequest) returns (UctovnictvoResponse);

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>,