Files
book_library_server/src/serializers/author.rs
2024-12-26 01:28:32 +01:00

31 lines
762 B
Rust

use chrono::NaiveDate;
use serde::Serialize;
use super::date::naive_date_serializer;
use super::sequence::Sequence;
#[derive(sqlx::FromRow, sqlx::Type, Serialize)]
#[sqlx(type_name = "author_type")]
pub struct Author {
pub id: i32,
pub first_name: String,
pub last_name: String,
pub middle_name: String,
pub annotation_exists: bool,
}
#[derive(sqlx::FromRow, Serialize)]
pub struct AuthorBook {
pub id: i32,
pub title: String,
pub lang: String,
pub file_type: String,
pub year: i32,
pub available_types: Vec<String>,
#[serde(serialize_with = "naive_date_serializer::serialize")]
pub uploaded: NaiveDate,
pub translators: Vec<Author>,
pub sequences: Vec<Sequence>,
pub annotation_exists: bool,
}