postgress

This commit is contained in:
MythEclipse
2025-12-01 00:20:42 +07:00
parent 6fe495eed1
commit b429b3a9c7
325 changed files with 35728 additions and 50259 deletions
@@ -1,15 +1,23 @@
use crate::make_thing;
use imphnen_iam::get_iso_date;
use imphnen_libs::ResourceEnum;
use serde::{Deserialize, Serialize};
use surrealdb::{Uuid, sql::Thing};
use uuid::Uuid;
use serde_json::Value;
use crate::v1::gacha_items::gacha_items_dto::GachaItemRequestDto;
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct GachaItemSchema {
pub id: Thing,
pub id: String,
pub item_code: String,
pub name: String,
pub description: String,
pub rarity: String,
pub type_: String,
pub category: String,
pub value: i32,
pub weight: f64,
pub stock: i32,
pub is_limited: bool,
pub metadata: Option<Value>,
pub image_url: String,
pub is_deleted: bool,
pub created_at: Option<String>,
@@ -19,15 +27,22 @@ pub struct GachaItemSchema {
impl Default for GachaItemSchema {
fn default() -> Self {
GachaItemSchema {
id: make_thing(
&ResourceEnum::GachaItems.to_string(),
&Uuid::new_v4().to_string(),
),
id: Uuid::new_v4().to_string(),
item_code: String::new(),
name: String::new(),
description: String::new(),
rarity: String::new(),
type_: String::new(),
category: String::new(),
value: 0,
weight: 0.0,
stock: 0,
is_limited: false,
metadata: None,
image_url: String::new(),
is_deleted: false,
created_at: Some(get_iso_date()),
updated_at: Some(get_iso_date()),
created_at: None,
updated_at: None,
}
}
}
@@ -35,13 +50,22 @@ impl Default for GachaItemSchema {
impl GachaItemSchema {
pub fn from(dto: GachaItemRequestDto) -> Self {
Self {
id: make_thing(
&ResourceEnum::GachaItems.to_string(),
&Uuid::new_v4().to_string(),
),
id: Uuid::new_v4().to_string(),
item_code: dto.item_code,
name: dto.name,
description: dto.description,
rarity: dto.rarity,
type_: dto.type_,
category: dto.category,
value: dto.value,
weight: dto.weight,
stock: dto.stock,
is_limited: dto.is_limited,
metadata: dto.metadata,
image_url: dto.image_url,
..Default::default()
is_deleted: false,
created_at: None,
updated_at: None,
}
}