fixing errors, slowly moving forwards
This commit is contained in:
4
Cargo.lock
generated
4
Cargo.lock
generated
@@ -2161,6 +2161,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "6a007b6936676aa9ab40207cde35daab0a04b823be8ae004368c0793b96a61e0"
|
checksum = "6a007b6936676aa9ab40207cde35daab0a04b823be8ae004368c0793b96a61e0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytes",
|
"bytes",
|
||||||
|
"chrono",
|
||||||
"crc",
|
"crc",
|
||||||
"crossbeam-queue",
|
"crossbeam-queue",
|
||||||
"either",
|
"either",
|
||||||
@@ -2239,6 +2240,7 @@ dependencies = [
|
|||||||
"bitflags",
|
"bitflags",
|
||||||
"byteorder",
|
"byteorder",
|
||||||
"bytes",
|
"bytes",
|
||||||
|
"chrono",
|
||||||
"crc",
|
"crc",
|
||||||
"digest",
|
"digest",
|
||||||
"dotenvy",
|
"dotenvy",
|
||||||
@@ -2281,6 +2283,7 @@ dependencies = [
|
|||||||
"base64",
|
"base64",
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"byteorder",
|
"byteorder",
|
||||||
|
"chrono",
|
||||||
"crc",
|
"crc",
|
||||||
"dotenvy",
|
"dotenvy",
|
||||||
"etcetera",
|
"etcetera",
|
||||||
@@ -2316,6 +2319,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "f85ca71d3a5b24e64e1d08dd8fe36c6c95c339a896cc33068148906784620540"
|
checksum = "f85ca71d3a5b24e64e1d08dd8fe36c6c95c339a896cc33068148906784620540"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"atoi",
|
"atoi",
|
||||||
|
"chrono",
|
||||||
"flume",
|
"flume",
|
||||||
"futures-channel",
|
"futures-channel",
|
||||||
"futures-core",
|
"futures-core",
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ version = "0.1.0"
|
|||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
chrono = "0.4.39"
|
chrono = { version = "0.4.39", features = ["serde"] }
|
||||||
clap = { version = "4.5.29", features = ["derive"] }
|
clap = { version = "4.5.29", features = ["derive"] }
|
||||||
console = "0.15.10"
|
console = "0.15.10"
|
||||||
crossterm = "0.28.1"
|
crossterm = "0.28.1"
|
||||||
@@ -15,7 +15,7 @@ ratatui = "0.29.0"
|
|||||||
serde = { version = "1.0.217", features = ["derive"] }
|
serde = { version = "1.0.217", features = ["derive"] }
|
||||||
serde_json = "1.0.138"
|
serde_json = "1.0.138"
|
||||||
serde_with = "3.12.0"
|
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"] }
|
tokio = { version = "1.43.0", features = ["full", "macros"] }
|
||||||
toml = "0.8.20"
|
toml = "0.8.20"
|
||||||
tonic = "0.12.3"
|
tonic = "0.12.3"
|
||||||
|
|||||||
3
build.rs
3
build.rs
@@ -2,8 +2,9 @@
|
|||||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
tonic_build::configure()
|
tonic_build::configure()
|
||||||
.build_server(true)
|
.build_server(true)
|
||||||
|
.file_descriptor_set_path("src/proto/descriptor.bin")
|
||||||
.compile_protos(
|
.compile_protos(
|
||||||
&["proto/api.proto", "proto/uctovnictvo.proto"], // Include both proto files
|
&["proto/api.proto", "proto/uctovnictvo.proto"],
|
||||||
&["proto"],
|
&["proto"],
|
||||||
)?;
|
)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
// proto/uctovnictvo.proto
|
// proto/uctovnictvo.proto
|
||||||
syntax = "proto3";
|
syntax = "proto3";
|
||||||
|
|
||||||
package multieko2;
|
package multieko2.uctovnictvo;
|
||||||
|
|
||||||
service Uctovnictvo {
|
service Uctovnictvo {
|
||||||
rpc PostUctovnictvo (PostUctovnictvoRequest) returns (UctovnictvoResponse);
|
rpc PostUctovnictvo (PostUctovnictvoRequest) returns (UctovnictvoResponse);
|
||||||
|
|||||||
Binary file not shown.
@@ -1,6 +1,9 @@
|
|||||||
// src/proto/mod.rs
|
// src/proto/mod.rs
|
||||||
pub mod multieko2 {
|
pub mod multieko2 {
|
||||||
tonic::include_proto!("multieko2");
|
tonic::include_proto!("multieko2");
|
||||||
|
pub mod uctovnictvo {
|
||||||
|
tonic::include_proto!("multieko2.uctovnictvo");
|
||||||
|
}
|
||||||
|
|
||||||
// Include the file descriptor set
|
// Include the file descriptor set
|
||||||
pub const FILE_DESCRIPTOR_SET: &[u8] = include_bytes!("descriptor.bin");
|
pub const FILE_DESCRIPTOR_SET: &[u8] = include_bytes!("descriptor.bin");
|
||||||
|
|||||||
@@ -8,11 +8,14 @@ use crate::uctovnictvo::handlers::post_uctovnictvo;
|
|||||||
use crate::proto::multieko2::{
|
use crate::proto::multieko2::{
|
||||||
PostAdresarRequest, AdresarResponse, GetAdresarRequest, PutAdresarRequest,
|
PostAdresarRequest, AdresarResponse, GetAdresarRequest, PutAdresarRequest,
|
||||||
DeleteAdresarRequest, DeleteAdresarResponse, PositionRequest, CountResponse, Empty,
|
DeleteAdresarRequest, DeleteAdresarResponse, PositionRequest, CountResponse, Empty,
|
||||||
TableStructureResponse,
|
TableStructureResponse, PostUctovnictvoRequest, UctovnictvoResponse,
|
||||||
adresar_server::{Adresar, AdresarServer},
|
adresar_server::{Adresar, AdresarServer},
|
||||||
uctovnictvo_server::{Uctovnictvo, UctovnictvoServer},
|
|
||||||
FILE_DESCRIPTOR_SET,
|
FILE_DESCRIPTOR_SET,
|
||||||
};
|
};
|
||||||
|
use crate::proto::multieko2::uctovnictvo::{
|
||||||
|
uctovnictvo_server::{Uctovnictvo, UctovnictvoServer},
|
||||||
|
PostUctovnictvoRequest, UctovnictvoResponse
|
||||||
|
};
|
||||||
|
|
||||||
pub struct AdresarService {
|
pub struct AdresarService {
|
||||||
db_pool: sqlx::PgPool,
|
db_pool: sqlx::PgPool,
|
||||||
|
|||||||
@@ -3,15 +3,15 @@ use tonic::Status;
|
|||||||
use sqlx::PgPool;
|
use sqlx::PgPool;
|
||||||
use chrono::NaiveDate;
|
use chrono::NaiveDate;
|
||||||
use crate::uctovnictvo::models::Uctovnictvo;
|
use crate::uctovnictvo::models::Uctovnictvo;
|
||||||
use crate::proto::multieko2::{PostUctovnictvoRequest, UctovnictvoResponse};
|
use crate::proto::multieko2::uctovnictvo::{PostUctovnictvoRequest, UctovnictvoResponse};
|
||||||
|
|
||||||
pub async fn post_uctovnictvo(
|
pub async fn post_uctovnictvo(
|
||||||
db_pool: &PgPool,
|
db_pool: &PgPool,
|
||||||
request: PostUctovnictvoRequest,
|
request: PostUctovnictvoRequest,
|
||||||
) -> Result<UctovnictvoResponse, Status> {
|
) -> Result<UctovnictvoResponse, Status> {
|
||||||
// Parse the date string into NaiveDate
|
// Parse the date string into NaiveDate
|
||||||
let datum = NaiveDate::parse_from_str(&request.datum, "%Y-%m-%d")
|
let datum = chrono::NaiveDate::parse_from_str(&request.datum, "%Y-%m-%d")
|
||||||
.map_err(|e| Status::invalid_argument(format!("Invalid date format: {}", e)))?;
|
.map_err(|e| Status::invalid_argument(format!("Invalid date: {}", e)))?;
|
||||||
|
|
||||||
let uctovnictvo = sqlx::query_as!(
|
let uctovnictvo = sqlx::query_as!(
|
||||||
Uctovnictvo,
|
Uctovnictvo,
|
||||||
|
|||||||
@@ -2,13 +2,13 @@
|
|||||||
use chrono::NaiveDate;
|
use chrono::NaiveDate;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, sqlx::FromRow, Serialize, Deserialize)]
|
||||||
pub struct Uctovnictvo {
|
pub struct Uctovnictvo {
|
||||||
pub id: i64,
|
pub id: i64,
|
||||||
pub deleted: bool,
|
pub deleted: bool,
|
||||||
pub adresar_id: i64,
|
pub adresar_id: i64,
|
||||||
pub c_dokladu: String,
|
pub c_dokladu: String,
|
||||||
pub datum: NaiveDate, // Use chrono::NaiveDate for better date handling
|
pub datum: chrono::NaiveDate,
|
||||||
pub c_faktury: String,
|
pub c_faktury: String,
|
||||||
pub obsah: Option<String>,
|
pub obsah: Option<String>,
|
||||||
pub stredisko: Option<String>,
|
pub stredisko: Option<String>,
|
||||||
|
|||||||
Reference in New Issue
Block a user