File size: 1,319 Bytes
c6d0d85
6858ec5
 
c6d0d85
1eb186a
f102c60
c6d0d85
249b27c
 
f102c60
c6d0d85
249b27c
 
1eb186a
 
 
 
 
 
 
 
c6d0d85
 
 
 
 
 
 
 
 
 
 
6858ec5
 
 
 
 
 
 
 
 
 
c6d0d85
 
 
 
6858ec5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
use sea_orm::entity::prelude::*;
use serde::{ Deserialize, Serialize };
use chrono::{ DateTime, FixedOffset };

#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Deserialize, Serialize)]
#[sea_orm(table_name = "kb2_doc")]
pub struct Model {
    #[sea_orm(primary_key, auto_increment = true)]
    pub id: i64,
    #[sea_orm(index)]
    pub kb_id: i64,
    #[sea_orm(index)]
    pub did: i64,
    #[serde(skip_deserializing)]
    pub kb_progress: f32,
    #[serde(skip_deserializing)]
    pub kb_progress_msg: String,
    #[serde(skip_deserializing)]
    pub updated_at: DateTime<FixedOffset>,
    #[serde(skip_deserializing)]
    pub is_deleted: bool,
}

#[derive(Debug, Clone, Copy, EnumIter)]
pub enum Relation {
    DocInfo,
    KbInfo,
}

impl RelationTrait for Relation {
    fn def(&self) -> RelationDef {
        match self {
            Self::DocInfo =>
                Entity::belongs_to(super::doc_info::Entity)
                    .from(Column::Did)
                    .to(super::doc_info::Column::Did)
                    .into(),
            Self::KbInfo =>
                Entity::belongs_to(super::kb_info::Entity)
                    .from(Column::KbId)
                    .to(super::kb_info::Column::KbId)
                    .into(),
        }
    }
}

impl ActiveModelBehavior for ActiveModel {}