34
src/entity/dialog_2_kb.rs
Normal file
34
src/entity/dialog_2_kb.rs
Normal file
@@ -0,0 +1,34 @@
|
||||
use sea_orm::entity::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, Deserialize, Serialize)]
|
||||
#[sea_orm(table_name = "dialog_2_kb")]
|
||||
pub struct Model {
|
||||
#[sea_orm(primary_key, auto_increment = false)]
|
||||
pub dialog_id: i64,
|
||||
#[sea_orm(primary_key, auto_increment = false)]
|
||||
pub kb_id: i64,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, EnumIter)]
|
||||
pub enum Relation {
|
||||
DialogInfo,
|
||||
KbInfo,
|
||||
}
|
||||
|
||||
impl RelationTrait for Relation {
|
||||
fn def(&self) -> RelationDef {
|
||||
match self {
|
||||
Self::DialogInfo => Entity::belongs_to(super::dialog_info::Entity)
|
||||
.from(Column::DialogId)
|
||||
.to(super::dialog_info::Column::DialogId)
|
||||
.into(),
|
||||
Self::KbInfo => Entity::belongs_to(super::kb_info::Entity)
|
||||
.from(Column::KbId)
|
||||
.to(super::kb_info::Column::KbId)
|
||||
.into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ActiveModelBehavior for ActiveModel {}
|
||||
33
src/entity/dialog_info.rs
Normal file
33
src/entity/dialog_info.rs
Normal file
@@ -0,0 +1,33 @@
|
||||
use sea_orm::entity::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, Deserialize, Serialize)]
|
||||
#[sea_orm(table_name = "dialog_info")]
|
||||
pub struct Model {
|
||||
#[sea_orm(primary_key, auto_increment = false)]
|
||||
pub dialog_id: i64,
|
||||
#[sea_orm(primary_key, auto_increment = false)]
|
||||
pub uid: i64,
|
||||
pub dialog_name: String,
|
||||
pub history: String,
|
||||
|
||||
pub created_at: DateTimeWithTimeZone,
|
||||
pub updated_at: DateTimeWithTimeZone,
|
||||
#[sea_orm(soft_delete_column)]
|
||||
pub is_deleted: bool,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||
pub enum Relation {}
|
||||
|
||||
impl Related<super::kb_info::Entity> for Entity {
|
||||
fn to() -> RelationDef {
|
||||
super::dialog_2_kb::Relation::KbInfo.def()
|
||||
}
|
||||
|
||||
fn via() -> Option<RelationDef> {
|
||||
Some(super::dialog_2_kb::Relation::DialogInfo.def().rev())
|
||||
}
|
||||
}
|
||||
|
||||
impl ActiveModelBehavior for ActiveModel {}
|
||||
34
src/entity/doc_2_doc.rs
Normal file
34
src/entity/doc_2_doc.rs
Normal file
@@ -0,0 +1,34 @@
|
||||
use sea_orm::entity::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, Deserialize, Serialize)]
|
||||
#[sea_orm(table_name = "doc_2_doc")]
|
||||
pub struct Model {
|
||||
#[sea_orm(primary_key, auto_increment = false)]
|
||||
pub parent_id: i64,
|
||||
#[sea_orm(primary_key, auto_increment = false)]
|
||||
pub did: i64,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, EnumIter)]
|
||||
pub enum Relation {
|
||||
Parent,
|
||||
Child
|
||||
}
|
||||
|
||||
impl RelationTrait for Relation {
|
||||
fn def(&self) -> RelationDef {
|
||||
match self {
|
||||
Self::Parent => Entity::belongs_to(super::doc_info::Entity)
|
||||
.from(Column::ParentId)
|
||||
.to(super::doc_info::Column::Did)
|
||||
.into(),
|
||||
Self::Child => Entity::belongs_to(super::doc_info::Entity)
|
||||
.from(Column::Did)
|
||||
.to(super::doc_info::Column::Did)
|
||||
.into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ActiveModelBehavior for ActiveModel {}
|
||||
56
src/entity/doc_info.rs
Normal file
56
src/entity/doc_info.rs
Normal file
@@ -0,0 +1,56 @@
|
||||
use sea_orm::entity::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Deserialize, Serialize)]
|
||||
#[sea_orm(table_name = "doc_info")]
|
||||
pub struct Model {
|
||||
#[sea_orm(primary_key, auto_increment = false)]
|
||||
pub did: i64,
|
||||
#[sea_orm(primary_key, auto_increment = false)]
|
||||
pub uid: i64,
|
||||
pub doc_name: String,
|
||||
pub size: i64,
|
||||
#[sea_orm(column_name = "type")]
|
||||
pub r#type: String,
|
||||
pub kb_progress: f64,
|
||||
|
||||
pub created_at: DateTimeWithTimeZone,
|
||||
pub updated_at: DateTimeWithTimeZone,
|
||||
#[sea_orm(soft_delete_column)]
|
||||
pub is_deleted: bool,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||
pub enum Relation {}
|
||||
|
||||
impl Related<super::tag_info::Entity> for Entity {
|
||||
fn to() -> RelationDef {
|
||||
super::tag_2_doc::Relation::Tag.def()
|
||||
}
|
||||
|
||||
fn via() -> Option<RelationDef> {
|
||||
Some(super::tag_2_doc::Relation::DocInfo.def().rev())
|
||||
}
|
||||
}
|
||||
|
||||
impl Related<super::kb_info::Entity> for Entity {
|
||||
fn to() -> RelationDef {
|
||||
super::kb_2_doc::Relation::KbInfo.def()
|
||||
}
|
||||
|
||||
fn via() -> Option<RelationDef> {
|
||||
Some(super::kb_2_doc::Relation::DocInfo.def().rev())
|
||||
}
|
||||
}
|
||||
|
||||
impl Related<Entity> for Entity {
|
||||
fn to() -> RelationDef {
|
||||
super::doc_2_doc::Relation::Parent.def()
|
||||
}
|
||||
|
||||
fn via() -> Option<RelationDef> {
|
||||
Some(super::doc_2_doc::Relation::Child.def().rev())
|
||||
}
|
||||
}
|
||||
|
||||
impl ActiveModelBehavior for ActiveModel {}
|
||||
34
src/entity/kb_2_doc.rs
Normal file
34
src/entity/kb_2_doc.rs
Normal file
@@ -0,0 +1,34 @@
|
||||
use sea_orm::entity::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, Deserialize, Serialize)]
|
||||
#[sea_orm(table_name = "kb_2_doc")]
|
||||
pub struct Model {
|
||||
#[sea_orm(primary_key, auto_increment = false)]
|
||||
pub kb_id: i64,
|
||||
#[sea_orm(primary_key, auto_increment = false)]
|
||||
pub uid: i64,
|
||||
}
|
||||
|
||||
#[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::Uid)
|
||||
.to(super::doc_info::Column::Uid)
|
||||
.into(),
|
||||
Self::KbInfo => Entity::belongs_to(super::kb_info::Entity)
|
||||
.from(Column::KbId)
|
||||
.to(super::kb_info::Column::KbId)
|
||||
.into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ActiveModelBehavior for ActiveModel {}
|
||||
43
src/entity/kb_info.rs
Normal file
43
src/entity/kb_info.rs
Normal file
@@ -0,0 +1,43 @@
|
||||
use sea_orm::entity::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, Deserialize, Serialize)]
|
||||
#[sea_orm(table_name = "kb_info")]
|
||||
pub struct Model {
|
||||
#[sea_orm(primary_key, auto_increment = false)]
|
||||
pub kb_id: i64,
|
||||
#[sea_orm(primary_key, auto_increment = false)]
|
||||
pub uid: i64,
|
||||
pub kn_name: String,
|
||||
pub icon: i64,
|
||||
|
||||
pub created_at: DateTimeWithTimeZone,
|
||||
pub updated_at: DateTimeWithTimeZone,
|
||||
#[sea_orm(soft_delete_column)]
|
||||
pub is_deleted: bool,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||
pub enum Relation {}
|
||||
|
||||
impl Related<super::doc_info::Entity> for Entity {
|
||||
fn to() -> RelationDef {
|
||||
super::kb_2_doc::Relation::DocInfo.def()
|
||||
}
|
||||
|
||||
fn via() -> Option<RelationDef> {
|
||||
Some(super::kb_2_doc::Relation::KbInfo.def().rev())
|
||||
}
|
||||
}
|
||||
|
||||
impl Related<super::dialog_info::Entity> for Entity {
|
||||
fn to() -> RelationDef {
|
||||
super::dialog_2_kb::Relation::DialogInfo.def()
|
||||
}
|
||||
|
||||
fn via() -> Option<RelationDef> {
|
||||
Some(super::dialog_2_kb::Relation::KbInfo.def().rev())
|
||||
}
|
||||
}
|
||||
|
||||
impl ActiveModelBehavior for ActiveModel {}
|
||||
9
src/entity/mod.rs
Normal file
9
src/entity/mod.rs
Normal file
@@ -0,0 +1,9 @@
|
||||
mod user_info;
|
||||
mod tag_info;
|
||||
mod tag_2_doc;
|
||||
mod kb_2_doc;
|
||||
mod dialog_2_kb;
|
||||
mod doc_2_doc;
|
||||
mod kb_info;
|
||||
mod doc_info;
|
||||
mod dialog_info;
|
||||
34
src/entity/tag_2_doc.rs
Normal file
34
src/entity/tag_2_doc.rs
Normal file
@@ -0,0 +1,34 @@
|
||||
use sea_orm::entity::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, Deserialize, Serialize)]
|
||||
#[sea_orm(table_name = "tag_2_doc")]
|
||||
pub struct Model {
|
||||
#[sea_orm(primary_key, auto_increment = false)]
|
||||
pub tag_id: i64,
|
||||
#[sea_orm(primary_key, auto_increment = false)]
|
||||
pub uid: i64,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, EnumIter)]
|
||||
pub enum Relation {
|
||||
DocInfo,
|
||||
Tag,
|
||||
}
|
||||
|
||||
impl RelationTrait for Relation {
|
||||
fn def(&self) -> sea_orm::RelationDef {
|
||||
match self {
|
||||
Self::DocInfo => Entity::belongs_to(super::doc_info::Entity)
|
||||
.from(Column::Uid)
|
||||
.to(super::doc_info::Column::Uid)
|
||||
.into(),
|
||||
Self::Tag => Entity::belongs_to(super::tag_info::Entity)
|
||||
.from(Column::TagId)
|
||||
.to(super::tag_info::Column::Uid)
|
||||
.into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ActiveModelBehavior for ActiveModel {}
|
||||
35
src/entity/tag_info.rs
Normal file
35
src/entity/tag_info.rs
Normal file
@@ -0,0 +1,35 @@
|
||||
use sea_orm::entity::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, Deserialize, Serialize)]
|
||||
#[sea_orm(table_name = "tag_info")]
|
||||
pub struct Model {
|
||||
#[sea_orm(primary_key)]
|
||||
#[serde(skip_deserializing)]
|
||||
pub uid: i64,
|
||||
pub tag_name: String,
|
||||
pub regx: String,
|
||||
pub color: i64,
|
||||
pub icon: i64,
|
||||
pub dir: String,
|
||||
|
||||
pub created_at: DateTimeWithTimeZone,
|
||||
pub updated_at: DateTimeWithTimeZone,
|
||||
#[sea_orm(soft_delete_column)]
|
||||
pub is_deleted: bool,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||
pub enum Relation {}
|
||||
|
||||
impl Related<super::doc_info::Entity> for Entity {
|
||||
fn to() -> RelationDef {
|
||||
super::tag_2_doc::Relation::DocInfo.def()
|
||||
}
|
||||
|
||||
fn via() -> Option<RelationDef> {
|
||||
Some(super::tag_2_doc::Relation::Tag.def().rev())
|
||||
}
|
||||
}
|
||||
|
||||
impl ActiveModelBehavior for ActiveModel {}
|
||||
26
src/entity/user_info.rs
Normal file
26
src/entity/user_info.rs
Normal file
@@ -0,0 +1,26 @@
|
||||
use sea_orm::entity::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, Deserialize, Serialize)]
|
||||
#[sea_orm(table_name = "user_info")]
|
||||
pub struct Model {
|
||||
#[sea_orm(primary_key)]
|
||||
#[serde(skip_deserializing)]
|
||||
pub uid: i64,
|
||||
pub email: String,
|
||||
pub nickname: String,
|
||||
pub avatar_url: String,
|
||||
pub color_schema: String,
|
||||
pub list_style: String,
|
||||
pub language: String,
|
||||
|
||||
pub created_at: DateTimeWithTimeZone,
|
||||
pub updated_at: DateTimeWithTimeZone,
|
||||
#[sea_orm(soft_delete_column)]
|
||||
pub is_deleted: bool,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||
pub enum Relation {}
|
||||
|
||||
impl ActiveModelBehavior for ActiveModel {}
|
||||
Reference in New Issue
Block a user