Add staff role repository

This commit is contained in:
2025-02-01 03:47:47 +00:00
parent d27871c097
commit 9170506eeb
8 changed files with 340 additions and 0 deletions

View File

@@ -1,7 +1,9 @@
use std::fmt::Display;
use staff_role_repository::StaffRoleRepository;
use user_repository::UserRepository;
pub mod staff_role_repository;
pub mod user_repository;
#[async_trait::async_trait]
@@ -17,6 +19,7 @@ pub trait RepositoryProvider {
pub trait Repository
where
Self: StaffRoleRepository<BackendError = <Self as Repository>::BackendError>,
Self: UserRepository<BackendError = <Self as Repository>::BackendError>,
{
type BackendError: std::error::Error;

View File

@@ -0,0 +1,16 @@
use super::RepositoryError;
#[async_trait::async_trait]
pub trait StaffRoleRepository {
type BackendError: std::error::Error;
async fn is_staff_role(&mut self, id: u64) -> Result<bool, RepositoryError<Self::BackendError>>;
async fn staff_roles(&mut self) -> Result<Vec<u64>, RepositoryError<Self::BackendError>>;
async fn staff_roles_contains(&mut self, ids: &[u64]) -> Result<bool, RepositoryError<Self::BackendError>>;
async fn set_staff_role(&mut self, id: u64) -> Result<(), RepositoryError<Self::BackendError>>;
async fn unset_staff_role(&mut self, id: u64) -> Result<(), RepositoryError<Self::BackendError>>;
}