refactor: Replace make_thing with make_thing_from_enum for consistency and clarity across multiple modules

This commit is contained in:
MythEclipse
2025-09-22 09:10:20 +07:00
parent acccae9f7c
commit 6da1b2a7e7
14 changed files with 101 additions and 148 deletions
@@ -34,10 +34,10 @@ impl GachaItemDto {
pub fn from(dto: GachaItemSchema) -> Self {
Self {
id: dto.id.id.to_raw(),
name: dto.name.clone(),
name: dto.name,
is_deleted: dto.is_deleted,
created_at: dto.created_at.clone(),
updated_at: dto.updated_at.clone(),
created_at: dto.created_at,
updated_at: dto.updated_at,
}
}
}
@@ -28,7 +28,7 @@ impl<'a> GachaItemRepository<'a> {
let now = Instant::now();
let surreal_query = format!(
"SELECT * FROM {} WHERE is_deleted = false AND name LIKE ?",
ResourceEnum::GachaItems.to_string()
ResourceEnum::GachaItems
);
info!(query = %surreal_query, "Executing SurrealDB query");
let raw_result: ResponseListSuccessDto<Vec<GachaItemSchema>> =
@@ -63,7 +63,7 @@ impl<'a> GachaItemRepository<'a> {
pub async fn query_gacha_item_by_id(&self, id: String) -> Result<GachaItemSchema> {
let now = Instant::now();
let db = &self.state.surrealdb_ws;
let surreal_query = format!("SELECT * FROM {} WHERE id = '{}'", ResourceEnum::GachaItems.to_string(), id);
let surreal_query = format!("SELECT * FROM {} WHERE id = '{}'", ResourceEnum::GachaItems, id);
info!(query = %surreal_query, "Executing SurrealDB query");
let result: Option<GachaItemSchema> = db
.select((ResourceEnum::GachaItems.to_string(), id.clone()))
@@ -87,7 +87,7 @@ impl<'a> GachaItemRepository<'a> {
) -> Result<String> {
let now = Instant::now();
let db = &self.state.surrealdb_ws;
let surreal_query = format!("CREATE {} CONTENT ...", ResourceEnum::GachaItems.to_string());
let surreal_query = format!("CREATE {} CONTENT ...", ResourceEnum::GachaItems);
info!(query = %surreal_query, "Executing SurrealDB query");
let record: Option<GachaItemSchema> = db
.create(ResourceEnum::GachaItems.to_string())