backend/service/blossoms.rs
1//! Service layer for blossoms.
2
3use uuid::Uuid;
4
5use crate::{
6 config::data::SharedPool,
7 error::ServiceError,
8 model::{dto::GainedBlossomsDto, entity::GainedBlossoms},
9};
10
11/// The user gains the specified Blossom.
12///
13/// # Errors
14/// If the connection to the database could not be established.
15pub async fn gain(
16 gained_blossom: GainedBlossomsDto,
17 user_id: Uuid,
18 pool: &SharedPool,
19) -> Result<GainedBlossomsDto, ServiceError> {
20 let mut conn = pool.get().await?;
21 let result = GainedBlossoms::create(gained_blossom, user_id, &mut conn).await?;
22 Ok(result)
23}