Refactor and enhance SurrealDB integration and resource management
- Updated `lib.rs` to selectively expose specific entities and services for better clarity. - Improved SurrealDB client initialization with detailed logging in `surrealdb/mod.rs`. - Enhanced resource definitions in `resource.rs` with additional utility methods for better resource management. - Refactored user data retrieval logic in `auth_middleware/mod.rs` for improved readability and efficiency. - Cleaned up middleware exports in `lib.rs` for clearer API surface. - Added detailed comments and documentation throughout the SurrealDB module for better maintainability. - Updated tests to ensure compatibility with new changes and improved structure. - Introduced new permissions module structure in `imphnen-utils` for future enhancements.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
use crate::{
|
||||
AppState, GachaRollItemDto, GachaRollRequestDto, GachaRollService,
|
||||
MessageResponseDto, ResponseSuccessDto,
|
||||
};
|
||||
use crate::AppState;
|
||||
use imphnen_entities::{MessageResponseDto, ResponseSuccessDto};
|
||||
use crate::v1::gacha_rolls::gacha_rolls_dto::{GachaRollItemDto, GachaRollRequestDto};
|
||||
use crate::v1::gacha_rolls::gacha_rolls_service::GachaRollService;
|
||||
use axum::{
|
||||
Extension, Json, extract::Path, http::HeaderMap, response::IntoResponse,
|
||||
};
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
use crate::{GachaItemDto, GachaItemSchema};
|
||||
use crate::v1::gacha_items::GachaItemDto;
|
||||
use crate::v1::gacha_items::gacha_items_schema::GachaItemSchema;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use surrealdb::sql::Thing;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
use super::GachaRollQueryDto;
|
||||
use super::GachaRollSchema;
|
||||
use crate::{AppState, DetailQueryBuilder, ResourceEnum, get_id, make_thing};
|
||||
use crate::v1::gacha_rolls::gacha_rolls_dto::GachaRollQueryDto;
|
||||
use crate::v1::gacha_rolls::gacha_rolls_schema::GachaRollSchema;
|
||||
use crate::AppState;
|
||||
use imphnen_libs::ResourceEnum;
|
||||
use imphnen_utils::DetailQueryBuilder;
|
||||
use crate::{get_id, make_thing};
|
||||
use anyhow::{Result, bail};
|
||||
|
||||
use rand::prelude::*;
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
use crate::{ResourceEnum, make_thing};
|
||||
use crate::make_thing;
|
||||
use imphnen_iam::get_iso_date;
|
||||
use imphnen_libs::ResourceEnum;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use surrealdb::{Uuid, sql::Thing};
|
||||
|
||||
use super::GachaRollRequestDto;
|
||||
use crate::v1::gacha_rolls::gacha_rolls_dto::GachaRollRequestDto;
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
pub struct GachaRollSchema {
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
use crate::{
|
||||
AppState, GachaClaimRepository, GachaClaimSchema, GachaRollItemDto,
|
||||
GachaRollRepository, GachaRollRequestDto, GachaRollSchema, ResponseSuccessDto,
|
||||
common_response, success_response, validate_request,
|
||||
};
|
||||
use crate::AppState;
|
||||
use imphnen_entities::ResponseSuccessDto;
|
||||
use imphnen_utils::{common_response, success_response, validate_request};
|
||||
use crate::v1::gacha_claims::gacha_claims_repository::GachaClaimRepository;
|
||||
use crate::v1::gacha_claims::gacha_claims_schema::GachaClaimSchema;
|
||||
use crate::v1::gacha_rolls::gacha_rolls_dto::{GachaRollItemDto, GachaRollRequestDto};
|
||||
use crate::v1::gacha_rolls::gacha_rolls_repository::GachaRollRepository;
|
||||
use crate::v1::gacha_rolls::gacha_rolls_schema::GachaRollSchema;
|
||||
use axum::http::{HeaderMap, StatusCode};
|
||||
use axum::response::Response;
|
||||
use imphnen_iam::{UsersRepository, extract_email};
|
||||
use imphnen_iam::UsersRepository;
|
||||
use imphnen_utils::extract_email;
|
||||
|
||||
pub struct GachaRollService;
|
||||
|
||||
|
||||
@@ -1,22 +1,26 @@
|
||||
use axum::{
|
||||
Router,
|
||||
routing::{get, post},
|
||||
};
|
||||
|
||||
pub mod gacha_rolls_controller;
|
||||
pub mod gacha_rolls_dto;
|
||||
pub mod gacha_rolls_repository;
|
||||
pub mod gacha_rolls_schema;
|
||||
pub mod gacha_rolls_service;
|
||||
|
||||
use axum::{
|
||||
Router,
|
||||
routing::{get, post},
|
||||
// Export only public API functions and types
|
||||
pub use gacha_rolls_controller::{
|
||||
post_create_gacha_roll,
|
||||
post_execute_gacha_roll,
|
||||
get_detail_gacha_roll,
|
||||
};
|
||||
pub use gacha_rolls_controller::*;
|
||||
pub use gacha_rolls_dto::*;
|
||||
pub use gacha_rolls_repository::*;
|
||||
pub use gacha_rolls_schema::*;
|
||||
pub use gacha_rolls_service::*;
|
||||
pub use gacha_rolls_dto::GachaRollItemDto;
|
||||
|
||||
/// Creates router for gacha rolls endpoints
|
||||
pub fn gacha_roll_router() -> Router {
|
||||
Router::new()
|
||||
.route("/create", post(post_create_gacha_roll))
|
||||
.route("/execute", post(post_execute_gacha_roll))
|
||||
.route("/detail/{id}", get(get_detail_gacha_roll))
|
||||
Router::new()
|
||||
.route("/create", post(post_create_gacha_roll))
|
||||
.route("/execute", post(post_execute_gacha_roll))
|
||||
.route("/detail/{id}", get(get_detail_gacha_roll))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user