feat: bal and user permission checks
This commit is contained in:
parent
e3f954679a
commit
e078bffc25
13 changed files with 207 additions and 19 deletions
|
|
@ -11,9 +11,20 @@ pub struct Model {
|
|||
pub sold_price: Option<i32>,
|
||||
pub status: BookStatus,
|
||||
pub book_id: u32,
|
||||
pub owner_id: u32
|
||||
pub owner_id: u32,
|
||||
pub bal_id: u32
|
||||
}
|
||||
|
||||
impl Entity {
|
||||
pub async fn get_by_id<C>(db_conn: &C, id: u32) -> Option<Model>
|
||||
where C: ConnectionTrait,
|
||||
{
|
||||
match Self::find_by_id(id).one(db_conn).await {
|
||||
Ok(res) => res,
|
||||
Err(_) => None
|
||||
}
|
||||
}
|
||||
}
|
||||
// Missing: Bal
|
||||
|
||||
#[derive(EnumIter, DeriveActiveEnum, PartialEq, Eq ,Deserialize, Serialize, Clone, Copy, Debug, utoipa::ToSchema)]
|
||||
#[sea_orm(rs_type = "String", db_type = "String(StringLen::N(1))")]
|
||||
|
|
@ -40,6 +51,12 @@ pub enum Relation {
|
|||
to = "super::owner::Column::Id"
|
||||
)]
|
||||
Owner,
|
||||
#[sea_orm(
|
||||
belongs_to = "super::bal::Entity",
|
||||
from = "Column::BalId",
|
||||
to = "super::bal::Column::Id"
|
||||
)]
|
||||
Bal,
|
||||
}
|
||||
|
||||
impl Related<super::book::Entity> for Entity {
|
||||
|
|
@ -54,4 +71,10 @@ impl Related<super::owner::Entity> for Entity {
|
|||
}
|
||||
}
|
||||
|
||||
impl Related<super::bal::Entity> for Entity {
|
||||
fn to() -> RelationDef {
|
||||
Relation::Bal.def()
|
||||
}
|
||||
}
|
||||
|
||||
impl ActiveModelBehavior for ActiveModel {}
|
||||
|
|
|
|||
Reference in a new issue