2025-05-20 10:45:01 +07:00
|
|
|
use super::GachaItemSchema;
|
2025-04-07 00:50:57 +07:00
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
|
use utoipa::ToSchema;
|
|
|
|
|
use validator::Validate;
|
|
|
|
|
|
|
|
|
|
#[derive(Clone, Debug, Serialize, Deserialize, ToSchema, Validate)]
|
|
|
|
|
pub struct GachaItemRequestDto {
|
|
|
|
|
#[validate(length(min = 1, message = "Item name must not be empty"))]
|
|
|
|
|
pub name: String,
|
|
|
|
|
#[validate(length(min = 1, message = "Image URL must not be empty"))]
|
|
|
|
|
pub image_url: String,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Clone, Debug, Serialize, Deserialize, ToSchema)]
|
|
|
|
|
pub struct GachaItemDto {
|
|
|
|
|
pub id: String,
|
|
|
|
|
pub name: String,
|
|
|
|
|
pub is_deleted: bool,
|
|
|
|
|
pub created_at: Option<String>,
|
|
|
|
|
pub updated_at: Option<String>,
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-20 10:45:01 +07:00
|
|
|
impl GachaItemDto {
|
2025-05-20 16:57:45 +07:00
|
|
|
pub fn from(dto: GachaItemSchema) -> Self {
|
2025-05-20 10:45:01 +07:00
|
|
|
Self {
|
|
|
|
|
id: dto.id.id.to_raw(),
|
|
|
|
|
name: dto.name.clone(),
|
|
|
|
|
is_deleted: dto.is_deleted,
|
|
|
|
|
created_at: dto.created_at.clone(),
|
|
|
|
|
updated_at: dto.updated_at.clone(),
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-04-07 00:50:57 +07:00
|
|
|
}
|