fix: renew entity models
This commit is contained in:
parent
61f0f52d42
commit
4d36c7f4ed
|
@ -8,7 +8,6 @@ pub mod ad;
|
||||||
pub mod announcement;
|
pub mod announcement;
|
||||||
pub mod announcement_read;
|
pub mod announcement_read;
|
||||||
pub mod antenna;
|
pub mod antenna;
|
||||||
pub mod antenna_note;
|
|
||||||
pub mod app;
|
pub mod app;
|
||||||
pub mod attestation_challenge;
|
pub mod attestation_challenge;
|
||||||
pub mod auth_session;
|
pub mod auth_session;
|
||||||
|
|
|
@ -15,6 +15,10 @@ pub struct Model {
|
||||||
pub image_url: Option<String>,
|
pub image_url: Option<String>,
|
||||||
#[sea_orm(column_name = "updatedAt")]
|
#[sea_orm(column_name = "updatedAt")]
|
||||||
pub updated_at: Option<DateTimeWithTimeZone>,
|
pub updated_at: Option<DateTimeWithTimeZone>,
|
||||||
|
#[sea_orm(column_name = "showPopup")]
|
||||||
|
pub show_popup: bool,
|
||||||
|
#[sea_orm(column_name = "isGoodNews")]
|
||||||
|
pub is_good_news: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||||
|
|
|
@ -37,8 +37,6 @@ pub struct Model {
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||||
pub enum Relation {
|
pub enum Relation {
|
||||||
#[sea_orm(has_many = "super::antenna_note::Entity")]
|
|
||||||
AntennaNote,
|
|
||||||
#[sea_orm(
|
#[sea_orm(
|
||||||
belongs_to = "super::user::Entity",
|
belongs_to = "super::user::Entity",
|
||||||
from = "Column::UserId",
|
from = "Column::UserId",
|
||||||
|
@ -65,12 +63,6 @@ pub enum Relation {
|
||||||
UserList,
|
UserList,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Related<super::antenna_note::Entity> for Entity {
|
|
||||||
fn to() -> RelationDef {
|
|
||||||
Relation::AntennaNote.def()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Related<super::user::Entity> for Entity {
|
impl Related<super::user::Entity> for Entity {
|
||||||
fn to() -> RelationDef {
|
fn to() -> RelationDef {
|
||||||
Relation::User.def()
|
Relation::User.def()
|
||||||
|
|
|
@ -189,6 +189,10 @@ pub struct Model {
|
||||||
pub silenced_hosts: StringVec,
|
pub silenced_hosts: StringVec,
|
||||||
#[sea_orm(column_name = "experimentalFeatures", column_type = "JsonBinary")]
|
#[sea_orm(column_name = "experimentalFeatures", column_type = "JsonBinary")]
|
||||||
pub experimental_features: Json,
|
pub experimental_features: Json,
|
||||||
|
#[sea_orm(column_name = "enableServerMachineStats")]
|
||||||
|
pub enable_server_machine_stats: bool,
|
||||||
|
#[sea_orm(column_name = "enableIdenticonGeneration")]
|
||||||
|
pub enable_identicon_generation: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||||
|
|
|
@ -67,8 +67,6 @@ pub struct Model {
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||||
pub enum Relation {
|
pub enum Relation {
|
||||||
#[sea_orm(has_many = "super::antenna_note::Entity")]
|
|
||||||
AntennaNote,
|
|
||||||
#[sea_orm(
|
#[sea_orm(
|
||||||
belongs_to = "super::channel::Entity",
|
belongs_to = "super::channel::Entity",
|
||||||
from = "Column::ChannelId",
|
from = "Column::ChannelId",
|
||||||
|
@ -131,12 +129,6 @@ pub enum Relation {
|
||||||
UserNotePining,
|
UserNotePining,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Related<super::antenna_note::Entity> for Entity {
|
|
||||||
fn to() -> RelationDef {
|
|
||||||
Relation::AntennaNote.def()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Related<super::channel::Entity> for Entity {
|
impl Related<super::channel::Entity> for Entity {
|
||||||
fn to() -> RelationDef {
|
fn to() -> RelationDef {
|
||||||
Relation::Channel.def()
|
Relation::Channel.def()
|
||||||
|
|
|
@ -6,7 +6,6 @@ pub use super::ad::Entity as Ad;
|
||||||
pub use super::announcement::Entity as Announcement;
|
pub use super::announcement::Entity as Announcement;
|
||||||
pub use super::announcement_read::Entity as AnnouncementRead;
|
pub use super::announcement_read::Entity as AnnouncementRead;
|
||||||
pub use super::antenna::Entity as Antenna;
|
pub use super::antenna::Entity as Antenna;
|
||||||
pub use super::antenna_note::Entity as AntennaNote;
|
|
||||||
pub use super::app::Entity as App;
|
pub use super::app::Entity as App;
|
||||||
pub use super::attestation_challenge::Entity as AttestationChallenge;
|
pub use super::attestation_challenge::Entity as AttestationChallenge;
|
||||||
pub use super::auth_session::Entity as AuthSession;
|
pub use super::auth_session::Entity as AuthSession;
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use cfg_if::cfg_if;
|
use cfg_if::cfg_if;
|
||||||
use sea_orm::{ColumnTrait, EntityTrait, QueryFilter};
|
use sea_orm::EntityTrait;
|
||||||
|
|
||||||
use crate::database;
|
use crate::database;
|
||||||
use crate::model::entity::{antenna, antenna_note, user_group_joining};
|
use crate::model::entity::{antenna, user_group_joining};
|
||||||
use crate::model::error::Error;
|
use crate::model::error::Error;
|
||||||
use crate::model::schema::Antenna;
|
use crate::model::schema::Antenna;
|
||||||
|
|
||||||
|
@ -14,12 +14,6 @@ use super::Repository;
|
||||||
impl Repository<Antenna> for antenna::Model {
|
impl Repository<Antenna> for antenna::Model {
|
||||||
async fn pack(self) -> Result<Antenna, Error> {
|
async fn pack(self) -> Result<Antenna, Error> {
|
||||||
let db = database::get_database()?;
|
let db = database::get_database()?;
|
||||||
let has_unread_note = antenna_note::Entity::find()
|
|
||||||
.filter(antenna_note::Column::AntennaId.eq(self.id.to_owned()))
|
|
||||||
.filter(antenna_note::Column::Read.eq(false))
|
|
||||||
.one(db)
|
|
||||||
.await?
|
|
||||||
.is_some();
|
|
||||||
let user_group_joining = match self.user_group_joining_id {
|
let user_group_joining = match self.user_group_joining_id {
|
||||||
None => None,
|
None => None,
|
||||||
Some(id) => user_group_joining::Entity::find_by_id(id).one(db).await?,
|
Some(id) => user_group_joining::Entity::find_by_id(id).one(db).await?,
|
||||||
|
@ -52,7 +46,7 @@ impl Repository<Antenna> for antenna::Model {
|
||||||
notify: self.notify,
|
notify: self.notify,
|
||||||
with_replies: self.with_replies,
|
with_replies: self.with_replies,
|
||||||
with_file: self.with_file,
|
with_file: self.with_file,
|
||||||
has_unread_note,
|
has_unread_note: false,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue