2025-05-30 18:00:52 +02:00
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
use bigdecimal::BigDecimal;
|
|
|
|
use chrono::NaiveDateTime;
|
2025-05-30 20:02:17 +02:00
|
|
|
use sqlx::FromRow;
|
2025-05-30 18:00:52 +02:00
|
|
|
|
|
|
|
#[derive(Deserialize)]
|
|
|
|
pub struct RegistrationData {
|
|
|
|
pub email: String,
|
|
|
|
pub haslo: String,
|
|
|
|
pub imie: String,
|
|
|
|
#[serde(rename = "confirmPassword")]
|
|
|
|
pub confirm_password: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Deserialize)]
|
|
|
|
pub struct LoginData {
|
|
|
|
pub email: String,
|
|
|
|
pub haslo: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Serialize)]
|
|
|
|
pub struct LoginResponse {
|
|
|
|
pub token: String,
|
|
|
|
pub imie: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(sqlx::FromRow, Serialize)]
|
|
|
|
pub struct Book {
|
|
|
|
pub id: i32,
|
|
|
|
pub tytul: String,
|
|
|
|
pub autor: String,
|
|
|
|
pub cena: BigDecimal,
|
|
|
|
pub obraz_url: Option<String>,
|
|
|
|
pub opis: Option<String>,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Deserialize)]
|
|
|
|
pub struct CartItem {
|
|
|
|
pub book_id: i32,
|
|
|
|
pub quantity: i32,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Serialize)]
|
|
|
|
pub struct CartItemResponse {
|
|
|
|
pub book_id: i32,
|
|
|
|
pub quantity: i32,
|
|
|
|
pub tytul: String,
|
|
|
|
pub cena: BigDecimal,
|
|
|
|
#[serde(rename = "obraz_url")]
|
|
|
|
pub obraz_url: String,
|
|
|
|
}
|
|
|
|
|
2025-05-30 20:02:17 +02:00
|
|
|
#[derive(Serialize, FromRow)]
|
|
|
|
pub struct OrderItem {
|
|
|
|
pub tytul: String,
|
|
|
|
pub autor: String,
|
|
|
|
pub ilosc: i32,
|
|
|
|
pub cena: BigDecimal,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Serialize)]
|
|
|
|
pub struct OrderWithItems {
|
|
|
|
pub id: i32,
|
|
|
|
pub data_zamowienia: NaiveDateTime,
|
|
|
|
pub suma_totalna: BigDecimal,
|
|
|
|
pub status: Option<String>,
|
|
|
|
pub items: Vec<OrderItem>,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Deserialize)]
|
|
|
|
pub struct CheckoutRequest {
|
|
|
|
pub items: Vec<CartItem>,
|
|
|
|
pub total: f64,
|
|
|
|
}
|
|
|
|
|