Init
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
use crate::repositories::category::CategoryRepository;
|
||||
use crate::repositories::channel::ChannelRepository;
|
||||
use crate::repositories::group::GroupRepository;
|
||||
use crate::repositories::message::MessageRepository;
|
||||
use crate::repositories::server::ServerRepository;
|
||||
use crate::repositories::user::UserRepository;
|
||||
use event_bus::EventBus;
|
||||
use sea_orm::DatabaseConnection;
|
||||
use std::sync::Arc;
|
||||
|
||||
mod category;
|
||||
mod channel;
|
||||
mod group;
|
||||
mod message;
|
||||
mod server;
|
||||
pub mod types;
|
||||
mod user;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct RepositoryContext {
|
||||
db: DatabaseConnection,
|
||||
events: Arc<EventBus>,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Repositories {
|
||||
pub server: ServerRepository,
|
||||
pub category: CategoryRepository,
|
||||
pub channel: ChannelRepository,
|
||||
pub group: GroupRepository,
|
||||
pub message: MessageRepository,
|
||||
pub user: UserRepository,
|
||||
}
|
||||
|
||||
impl Repositories {
|
||||
pub fn new(db: &DatabaseConnection, events: Arc<EventBus>) -> Self {
|
||||
let context = Arc::new(RepositoryContext {
|
||||
db: db.clone(),
|
||||
events,
|
||||
});
|
||||
|
||||
Self {
|
||||
server: ServerRepository {
|
||||
context: context.clone(),
|
||||
},
|
||||
category: CategoryRepository {
|
||||
context: context.clone(),
|
||||
},
|
||||
channel: ChannelRepository {
|
||||
context: context.clone(),
|
||||
},
|
||||
group: GroupRepository {
|
||||
context: context.clone(),
|
||||
},
|
||||
message: MessageRepository {
|
||||
context: context.clone(),
|
||||
},
|
||||
user: UserRepository {
|
||||
context: context.clone(),
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user