feat: book return and bal stats
Some checks are pending
/ test (push) Waiting to run

This commit is contained in:
Ninjdai 2025-08-15 13:14:11 +02:00
parent 910b10de35
commit b817d36816
6 changed files with 193 additions and 10 deletions

View file

@ -34,6 +34,8 @@ where C: ConnectionTrait {
pub enum Relation {
#[sea_orm(has_many = "super::book_instance::Entity")]
BookInstance,
#[sea_orm(has_one = "super::bal_stats::Entity")]
BalStats,
}
impl Related<super::book_instance::Entity> for Entity {

38
src/entities/bal_stats.rs Normal file
View file

@ -0,0 +1,38 @@
use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Serialize, Deserialize, utoipa::ToSchema)]
#[sea_orm(table_name = "BALStats")]
#[schema(title="BalStats", as=entities::BALStats)]
pub struct Model {
#[sea_orm(primary_key, auto_increment = true)]
#[serde(skip_serializing)]
id: u32,
pub bal_id: u32,
pub total_owned_sold_books: u32,
pub total_sold_books: u32,
pub total_owned_collected_money: f32,
pub total_collected_money: f32,
pub total_different_owners: u32,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::bal::Entity",
from = "Column::BalId",
to = "super::bal::Column::Id"
)]
Bal,
}
impl Related<super::bal::Entity> for Entity {
fn to() -> RelationDef {
Relation::Bal.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

View file

@ -1,6 +1,7 @@
pub mod prelude;
pub mod bal;
pub mod bal_stats;
pub mod book;
pub mod book_instance;
pub mod owner;

View file

@ -1,5 +1,6 @@
pub use super::bal::Entity as Bal;
pub use super::bal_stats::Entity as BalStats;
pub use super::book::Entity as Book;
pub use super::book_instance::Entity as BookInstance;
pub use super::owner::Entity as Owner;