pub struct AchievementUseCases { /* private fields */ }Expand description
Use cases for achievement operations
Orchestrates business logic for achievement CRUD, awarding achievements to users, and calculating user achievement statistics.
Implementations§
Source§impl AchievementUseCases
impl AchievementUseCases
pub fn new( achievement_repo: Arc<dyn AchievementRepository>, user_achievement_repo: Arc<dyn UserAchievementRepository>, user_repo: Arc<dyn UserRepository>, ) -> Self
Sourcepub async fn create_achievement(
&self,
dto: CreateAchievementDto,
) -> Result<AchievementResponseDto, String>
pub async fn create_achievement( &self, dto: CreateAchievementDto, ) -> Result<AchievementResponseDto, String>
Sourcepub async fn get_achievement(
&self,
achievement_id: Uuid,
) -> Result<AchievementResponseDto, String>
pub async fn get_achievement( &self, achievement_id: Uuid, ) -> Result<AchievementResponseDto, String>
Get achievement by ID
Sourcepub async fn list_achievements(
&self,
organization_id: Uuid,
) -> Result<Vec<AchievementResponseDto>, String>
pub async fn list_achievements( &self, organization_id: Uuid, ) -> Result<Vec<AchievementResponseDto>, String>
List all achievements for an organization
Sourcepub async fn list_achievements_by_category(
&self,
organization_id: Uuid,
category: AchievementCategory,
) -> Result<Vec<AchievementResponseDto>, String>
pub async fn list_achievements_by_category( &self, organization_id: Uuid, category: AchievementCategory, ) -> Result<Vec<AchievementResponseDto>, String>
List achievements by category
Sourcepub async fn list_visible_achievements(
&self,
organization_id: Uuid,
user_id: Uuid,
) -> Result<Vec<AchievementResponseDto>, String>
pub async fn list_visible_achievements( &self, organization_id: Uuid, user_id: Uuid, ) -> Result<Vec<AchievementResponseDto>, String>
List visible achievements for a user (non-secret or already earned)
Sourcepub async fn update_achievement(
&self,
achievement_id: Uuid,
dto: UpdateAchievementDto,
) -> Result<AchievementResponseDto, String>
pub async fn update_achievement( &self, achievement_id: Uuid, dto: UpdateAchievementDto, ) -> Result<AchievementResponseDto, String>
Update achievement (admin only)
Sourcepub async fn delete_achievement(
&self,
achievement_id: Uuid,
) -> Result<(), String>
pub async fn delete_achievement( &self, achievement_id: Uuid, ) -> Result<(), String>
Delete achievement (admin only)
Sourcepub async fn award_achievement(
&self,
user_id: Uuid,
achievement_id: Uuid,
progress_data: Option<String>,
) -> Result<UserAchievementResponseDto, String>
pub async fn award_achievement( &self, user_id: Uuid, achievement_id: Uuid, progress_data: Option<String>, ) -> Result<UserAchievementResponseDto, String>
Award achievement to user
For repeatable achievements, increments times_earned counter. For non-repeatable, returns error if already earned.
Sourcepub async fn get_user_achievements(
&self,
user_id: Uuid,
) -> Result<Vec<UserAchievementResponseDto>, String>
pub async fn get_user_achievements( &self, user_id: Uuid, ) -> Result<Vec<UserAchievementResponseDto>, String>
Get all achievements earned by a user (enriched with achievement data)
Sourcepub async fn get_recent_achievements(
&self,
user_id: Uuid,
limit: i64,
) -> Result<Vec<UserAchievementResponseDto>, String>
pub async fn get_recent_achievements( &self, user_id: Uuid, limit: i64, ) -> Result<Vec<UserAchievementResponseDto>, String>
Get recent achievements for a user (last N)
Auto Trait Implementations§
impl Freeze for AchievementUseCases
impl !RefUnwindSafe for AchievementUseCases
impl Send for AchievementUseCases
impl Sync for AchievementUseCases
impl Unpin for AchievementUseCases
impl !UnwindSafe for AchievementUseCases
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> Chain<T> for T
impl<T> Chain<T> for T
§impl<T> Fake for T
impl<T> Fake for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreCreates a shared type from an unshared type.