feat: gacha roll
This commit is contained in:
@@ -4,11 +4,11 @@ use axum::{http::HeaderMap, response::IntoResponse, Extension, Json};
|
||||
|
||||
#[utoipa::path(
|
||||
post,
|
||||
path = "/v1/gacha/create/claims",
|
||||
path = "/v1/gacha/create/claim",
|
||||
request_body = GachaCreateClaimRequestDto,
|
||||
responses(
|
||||
(status = 200, description = "Create gacha claims successful", body = MessageResponseDto),
|
||||
(status = 401, description = "Create gacha claims failed", body = MessageResponseDto)
|
||||
(status = 200, description = "Create gacha claim successful", body = MessageResponseDto),
|
||||
(status = 401, description = "Create gacha claim failed", body = MessageResponseDto)
|
||||
),
|
||||
tag = "Gacha"
|
||||
)]
|
||||
|
||||
@@ -5,6 +5,7 @@ use crate::v1::UsersItemDto;
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, ToSchema)]
|
||||
pub struct GachaCreateClaimRequestDto {
|
||||
pub item_name: String,
|
||||
pub transaction_number: String,
|
||||
}
|
||||
|
||||
|
||||
@@ -61,6 +61,11 @@ impl<'a> GachaRepository<'a> {
|
||||
let user_thing =
|
||||
Thing::from((ResourceEnum::Users.to_string(), Id::String(user.email)));
|
||||
|
||||
let item_thing = Thing::from((
|
||||
ResourceEnum::GachaItems.to_string(),
|
||||
Id::String(data.item_name.clone()),
|
||||
));
|
||||
|
||||
let record: Option<GachaClaimSchema> = db
|
||||
.create((
|
||||
ResourceEnum::GachaClaims.to_string(),
|
||||
@@ -68,6 +73,7 @@ impl<'a> GachaRepository<'a> {
|
||||
))
|
||||
.content(GachaClaimSchema {
|
||||
transaction_number: data.transaction_number.clone(),
|
||||
item: item_thing,
|
||||
user: user_thing,
|
||||
})
|
||||
.await?;
|
||||
|
||||
@@ -4,6 +4,7 @@ use surrealdb::sql::Thing;
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
pub struct GachaClaimSchema {
|
||||
pub transaction_number: String,
|
||||
pub item: Thing,
|
||||
pub user: Thing,
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user