feat: initial API and docs
This commit is contained in:
parent
79be4eb543
commit
5d709d658b
16 changed files with 3169 additions and 342 deletions
27
src/entities/owner.rs
Normal file
27
src/entities/owner.rs
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
use sea_orm::entity::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Deserialize, Serialize, utoipa::ToSchema)]
|
||||
#[sea_orm(table_name = "Owners")]
|
||||
#[schema(title="Owner", as=entities::Owner)]
|
||||
pub struct Model {
|
||||
#[sea_orm(primary_key, auto_increment = true)]
|
||||
pub id: u32,
|
||||
pub first_name: String,
|
||||
pub last_name: String,
|
||||
pub contact: String
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||
pub enum Relation {
|
||||
#[sea_orm(has_many = "super::book_instance::Entity")]
|
||||
BookInstance
|
||||
}
|
||||
|
||||
impl Related<super::book_instance::Entity> for Entity {
|
||||
fn to() -> RelationDef {
|
||||
Relation::BookInstance.def()
|
||||
}
|
||||
}
|
||||
|
||||
impl ActiveModelBehavior for ActiveModel {}
|
||||
Reference in a new issue