This commit is contained in:
parent
910b10de35
commit
b817d36816
6 changed files with 193 additions and 10 deletions
|
|
@ -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
38
src/entities/bal_stats.rs
Normal 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 {}
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
pub mod prelude;
|
||||
|
||||
pub mod bal;
|
||||
pub mod bal_stats;
|
||||
pub mod book;
|
||||
pub mod book_instance;
|
||||
pub mod owner;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Reference in a new issue