backend/controller/
blossoms.rs1use actix_web::{post, web::Json, HttpResponse, Result};
4
5use crate::config::data::SharedPool;
6use crate::{config::auth::user_info::UserInfo, model::dto::GainedBlossomsDto, service};
7
8#[utoipa::path(
13 context_path = "/api/blossoms",
14 request_body = BlossomsGainedDto,
15 responses(
16 (status = 201, description = "The user gains a Blossom", body = BlossomsGainedDto)
17 ),
18 security(
19 ("oauth2" = [])
20 )
21)]
22#[post("")]
23pub async fn gain(
24 gained_blossom_json: Json<GainedBlossomsDto>,
25 user_info: UserInfo,
26 pool: SharedPool,
27) -> Result<HttpResponse> {
28 let response = service::blossoms::gain(gained_blossom_json.0, user_info.id, &pool).await?;
29 Ok(HttpResponse::Created().json(response))
30}