* init

* bot framework done

* here and ready for orm

* might use sea-orm

* orm done

* use teloxide

* ready to go?

* 需要完成命令部分

* 需要完成:list_handler()

* 查询用户名应当以@开头

* use rustls to avoid segfault?

* postgresql ready

* inline query done

* list_handler

* flattern code

* test needed

* ready to build

* some bugs

* almost done

* ready to take off

Co-authored-by: senset <dummy@dummy.d>
This commit is contained in:
senseab
2022-06-28 18:11:47 +08:00
committed by GitHub
parent fe53f1abd3
commit 56635e0e1b
28 changed files with 4723 additions and 0 deletions

12
entity/Cargo.toml Normal file
View File

@@ -0,0 +1,12 @@
[package]
name = "models"
version = "0.1.0"
edition = "2021"
publish = false
[lib]
name = "models"
path = "src/lib.rs"
[dependencies.sea-orm]
version = "^0.8.0"

View File

@@ -0,0 +1,4 @@
pub mod prelude;
pub mod record;
pub mod user;

View File

@@ -0,0 +1,8 @@
pub use super::record::{
ActiveModel as RecordActiveModel, Column as RecordColumn, Entity as Record,
Model as RecordModel, PrimaryKey as RecordPrimaryKey, Relation as RecordRelation,
};
pub use super::user::{
ActiveModel as UserActiveModel, Column as UserColumn, Entity as User, Model as UserModel,
PrimaryKey as UserPrimaryKey, Relation as UserRelation,
};

View File

@@ -0,0 +1,35 @@
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
#[sea_orm(table_name = "records")]
pub struct Model {
/// internal ID
#[sea_orm(primary_key)]
pub id: i64,
/// relation user id
#[sea_orm(indexed)]
pub user_id: i64,
/// records
#[sea_orm(indexed, column_type = "Text", unique)]
pub message: String,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::user::Entity",
from = "Column::UserId",
to = "super::user::Column::Id"
)]
User,
}
impl Related<super::user::Entity> for Entity {
fn to() -> RelationDef {
Relation::User.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

View File

@@ -0,0 +1,35 @@
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
#[sea_orm(table_name = "users")]
pub struct Model {
/// internal ID
#[sea_orm(primary_key)]
pub id: i64,
/// Telegram user ID
#[sea_orm(unique)]
pub tg_uid: i64,
/// Telegram user name
#[sea_orm(nullable)]
pub username: Option<String>,
/// use notify
#[sea_orm(default_value = true)]
pub notify: bool,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(has_many = "super::record::Entity")]
Record,
}
impl Related<super::record::Entity> for Entity {
fn to() -> RelationDef {
Relation::Record.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

2
entity/src/lib.rs Normal file
View File

@@ -0,0 +1,2 @@
mod entities;
pub use entities::*;