mirror of
https://github.com/shiroyashik/doggy-watch.git
synced 2025-12-06 12:31:13 +03:00
Prototype
This commit is contained in:
commit
2844bb9149
19 changed files with 5483 additions and 0 deletions
7
entity/Cargo.toml
Normal file
7
entity/Cargo.toml
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
[package]
|
||||
name = "entity"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
sea-orm = { version = "1.1", features = ["macros", "sqlx-sqlite", "runtime-tokio-rustls", "sqlx-postgres", "with-uuid", "with-chrono"] }
|
||||
33
entity/src/actions.rs
Normal file
33
entity/src/actions.rs
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.2
|
||||
|
||||
use sea_orm::entity::prelude::*;
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
|
||||
#[sea_orm(table_name = "actions")]
|
||||
pub struct Model {
|
||||
#[sea_orm(primary_key)]
|
||||
pub id: i32,
|
||||
pub uid: String,
|
||||
pub vid: i32,
|
||||
pub created_at: DateTime,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||
pub enum Relation {
|
||||
#[sea_orm(
|
||||
belongs_to = "super::videos::Entity",
|
||||
from = "Column::Vid",
|
||||
to = "super::videos::Column::Id",
|
||||
on_update = "NoAction",
|
||||
on_delete = "Cascade"
|
||||
)]
|
||||
Videos,
|
||||
}
|
||||
|
||||
impl Related<super::videos::Entity> for Entity {
|
||||
fn to() -> RelationDef {
|
||||
Relation::Videos.def()
|
||||
}
|
||||
}
|
||||
|
||||
impl ActiveModelBehavior for ActiveModel {}
|
||||
8
entity/src/lib.rs
Normal file
8
entity/src/lib.rs
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.2
|
||||
|
||||
pub mod prelude;
|
||||
|
||||
pub mod actions;
|
||||
pub mod moderators;
|
||||
pub mod sea_orm_active_enums;
|
||||
pub mod videos;
|
||||
16
entity/src/moderators.rs
Normal file
16
entity/src/moderators.rs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.2
|
||||
|
||||
use sea_orm::entity::prelude::*;
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
|
||||
#[sea_orm(table_name = "moderators")]
|
||||
pub struct Model {
|
||||
#[sea_orm(primary_key, auto_increment = false)]
|
||||
pub uid: String,
|
||||
pub created_at: DateTime,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||
pub enum Relation {}
|
||||
|
||||
impl ActiveModelBehavior for ActiveModel {}
|
||||
5
entity/src/prelude.rs
Normal file
5
entity/src/prelude.rs
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.2
|
||||
|
||||
pub use super::actions::Entity as Actions;
|
||||
pub use super::moderators::Entity as Moderators;
|
||||
pub use super::videos::Entity as Videos;
|
||||
14
entity/src/sea_orm_active_enums.rs
Normal file
14
entity/src/sea_orm_active_enums.rs
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.2
|
||||
|
||||
use sea_orm::entity::prelude::*;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)]
|
||||
#[sea_orm(rs_type = "String", db_type = "Enum", enum_name = "status")]
|
||||
pub enum Status {
|
||||
#[sea_orm(string_value = "Banned")]
|
||||
Banned,
|
||||
#[sea_orm(string_value = "Pending")]
|
||||
Pending,
|
||||
#[sea_orm(string_value = "Viewed")]
|
||||
Viewed,
|
||||
}
|
||||
31
entity/src/videos.rs
Normal file
31
entity/src/videos.rs
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.2
|
||||
|
||||
use super::sea_orm_active_enums::Status;
|
||||
use sea_orm::entity::prelude::*;
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
|
||||
#[sea_orm(table_name = "videos")]
|
||||
pub struct Model {
|
||||
#[sea_orm(primary_key)]
|
||||
pub id: i32,
|
||||
pub title: String,
|
||||
#[sea_orm(unique)]
|
||||
pub yt_id: String,
|
||||
pub created_at: DateTime,
|
||||
pub status: Status,
|
||||
pub updated_at: Option<DateTime>,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||
pub enum Relation {
|
||||
#[sea_orm(has_many = "super::actions::Entity")]
|
||||
Actions,
|
||||
}
|
||||
|
||||
impl Related<super::actions::Entity> for Entity {
|
||||
fn to() -> RelationDef {
|
||||
Relation::Actions.def()
|
||||
}
|
||||
}
|
||||
|
||||
impl ActiveModelBehavior for ActiveModel {}
|
||||
Loading…
Add table
Add a link
Reference in a new issue