79 lines
2.3 KiB
Rust
79 lines
2.3 KiB
Rust
pub type AnyResult<T> = anyhow::Result<T>;
|
|
|
|
use crate::repositories::category::CategoryRepository;
|
|
use crate::repositories::channel::ChannelRepository;
|
|
use crate::repositories::computed_permission::ComputedPermissionRepository;
|
|
use crate::repositories::message::MessageRepository;
|
|
use crate::repositories::role::RoleRepository;
|
|
use crate::repositories::server::ServerRepository;
|
|
use crate::repositories::server_item_order::ServerItemOrderRepository;
|
|
use crate::repositories::server_tree::ServerTreeRepository;
|
|
use crate::repositories::user::UserRepository;
|
|
use sea_orm::DatabaseConnection;
|
|
use std::sync::Arc;
|
|
|
|
mod category;
|
|
mod channel;
|
|
mod computed_permission;
|
|
mod message;
|
|
mod role;
|
|
mod server;
|
|
mod server_item_order;
|
|
mod server_tree;
|
|
pub mod types;
|
|
mod user;
|
|
|
|
#[derive(Clone, Debug)]
|
|
pub struct RepositoryContext {
|
|
pub db: DatabaseConnection,
|
|
}
|
|
|
|
#[derive(Clone, Debug)]
|
|
pub struct Repositories {
|
|
pub server: ServerRepository,
|
|
pub category: CategoryRepository,
|
|
pub channel: ChannelRepository,
|
|
pub role: RoleRepository,
|
|
pub message: MessageRepository,
|
|
pub user: UserRepository,
|
|
pub computed_permission: ComputedPermissionRepository,
|
|
pub server_item_order: ServerItemOrderRepository,
|
|
pub server_tree: ServerTreeRepository,
|
|
}
|
|
|
|
impl Repositories {
|
|
pub fn new(db: DatabaseConnection) -> Self {
|
|
let context = Arc::new(RepositoryContext { db });
|
|
|
|
Self {
|
|
server: ServerRepository {
|
|
context: context.clone(),
|
|
},
|
|
category: CategoryRepository {
|
|
context: context.clone(),
|
|
},
|
|
channel: ChannelRepository {
|
|
context: context.clone(),
|
|
},
|
|
role: RoleRepository {
|
|
context: context.clone(),
|
|
},
|
|
message: MessageRepository {
|
|
context: context.clone(),
|
|
},
|
|
user: UserRepository {
|
|
context: context.clone(),
|
|
},
|
|
computed_permission: ComputedPermissionRepository {
|
|
context: context.clone(),
|
|
},
|
|
server_item_order: ServerItemOrderRepository {
|
|
context: context.clone(),
|
|
},
|
|
server_tree: ServerTreeRepository {
|
|
context: context.clone(),
|
|
},
|
|
}
|
|
}
|
|
}
|