2025-02-07 22:26:32 +07:00
|
|
|
use serde::{Deserialize, Serialize};
|
2025-03-19 19:33:56 +07:00
|
|
|
use surrealdb::{engine::remote::ws::Client, Surreal};
|
2025-02-07 22:26:32 +07:00
|
|
|
use utoipa::{IntoParams, ToSchema};
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
|
|
|
|
|
pub struct MessageResponseDto {
|
2025-02-16 01:09:55 +07:00
|
|
|
pub message: String,
|
|
|
|
|
pub version: String,
|
2025-02-07 22:26:32 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema, IntoParams)]
|
|
|
|
|
pub struct MetaRequestDto {
|
2025-02-16 01:09:55 +07:00
|
|
|
pub page: Option<u64>,
|
|
|
|
|
pub per_page: Option<u64>,
|
|
|
|
|
pub search: Option<String>,
|
|
|
|
|
pub sort_by: Option<String>,
|
|
|
|
|
pub order: Option<String>,
|
|
|
|
|
pub filter: Option<String>,
|
|
|
|
|
pub filter_by: Option<String>,
|
2025-02-07 22:26:32 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema, IntoParams)]
|
|
|
|
|
pub struct MetaResponseDto {
|
2025-02-16 01:09:55 +07:00
|
|
|
pub page: Option<u64>,
|
|
|
|
|
pub per_page: Option<u64>,
|
|
|
|
|
pub total: Option<u64>,
|
2025-02-07 22:26:32 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Clone, Debug, Serialize, Deserialize, ToSchema)]
|
|
|
|
|
pub struct ResponseSuccessDto<T: Serialize> {
|
2025-02-16 01:09:55 +07:00
|
|
|
pub data: T,
|
2025-02-07 22:26:32 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Clone, Debug, Serialize, Deserialize, ToSchema)]
|
|
|
|
|
pub struct ResponseListSuccessDto<T: Serialize> {
|
2025-02-16 01:09:55 +07:00
|
|
|
pub data: T,
|
|
|
|
|
pub meta: Option<MetaResponseDto>,
|
2025-02-07 22:26:32 +07:00
|
|
|
}
|
2025-02-25 02:00:19 +07:00
|
|
|
|
|
|
|
|
pub type SurrealClient = Surreal<Client>;
|
|
|
|
|
pub type RedisClient = redis::Client;
|
|
|
|
|
|
|
|
|
|
#[derive(Clone)]
|
|
|
|
|
pub struct AppState {
|
|
|
|
|
pub surrealdb: SurrealClient,
|
|
|
|
|
pub redisdb: RedisClient,
|
|
|
|
|
}
|