mirror of
https://github.com/yoncodes/BD2PS.git
synced 2026-08-04 22:02:15 +02:00
pushing
This commit is contained in:
25
httpserver/Cargo.toml
Normal file
25
httpserver/Cargo.toml
Normal file
@@ -0,0 +1,25 @@
|
||||
[package]
|
||||
name = "httpserver"
|
||||
edition.workspace = true
|
||||
version.workspace = true
|
||||
|
||||
[dependencies]
|
||||
aes.workspace = true
|
||||
actix-web.workspace = true
|
||||
common.workspace = true
|
||||
tracing.workspace = true
|
||||
sqlx.workspace = true
|
||||
database.workspace = true
|
||||
rustls.workspace = true
|
||||
rustls-pemfile.workspace = true
|
||||
anyhow.workspace = true
|
||||
crypto.workspace = true
|
||||
protocol.workspace = true
|
||||
gameserver.workspace = true
|
||||
serde_json.workspace = true
|
||||
serde.workspace = true
|
||||
data.workspace = true
|
||||
rand.workspace = true
|
||||
base64.workspace = true
|
||||
hex.workspace = true
|
||||
cbc.workspace = true
|
||||
164
httpserver/src/main.rs
Normal file
164
httpserver/src/main.rs
Normal file
@@ -0,0 +1,164 @@
|
||||
use actix_web::middleware::from_fn;
|
||||
use actix_web::{App, HttpServer};
|
||||
use common::{CERT_FILE_PATH, GAME_SERVER_ADDRESS, KEY_FILE_PATH, init_tracing};
|
||||
use database::{DatabaseSettings, connect_to, run_migrations};
|
||||
use middleware::{auth::auth_middleware, logger::Logger};
|
||||
use tracing::{error, info};
|
||||
|
||||
use actix_web::web::Data;
|
||||
use rustls::{
|
||||
ServerConfig,
|
||||
pki_types::{CertificateDer, PrivateKeyDer},
|
||||
};
|
||||
use rustls_pemfile::{certs, pkcs8_private_keys, rsa_private_keys};
|
||||
use std::{fs::File, io::BufReader};
|
||||
|
||||
mod middleware;
|
||||
mod routes;
|
||||
|
||||
#[actix_web::main]
|
||||
async fn main() -> anyhow::Result<()> {
|
||||
{
|
||||
init_tracing();
|
||||
|
||||
let data_path = get_data_path()?;
|
||||
info!("Found data path: {}", data_path.display());
|
||||
|
||||
let settings = DatabaseSettings::default();
|
||||
|
||||
let db = connect_to(&settings).await.map_err(|e| {
|
||||
eprintln!("Database connection error: {:?}", e);
|
||||
std::io::Error::new(std::io::ErrorKind::Other, e)
|
||||
})?;
|
||||
|
||||
run_migrations(&db).await.map_err(|e| {
|
||||
eprintln!("Migration error: {:?}", e);
|
||||
std::io::Error::new(std::io::ErrorKind::Other, e)
|
||||
})?;
|
||||
|
||||
info!("Loading game data...");
|
||||
data::exceldb::init(data_path.to_str().unwrap()).map_err(|e| {
|
||||
error!("Failed to load game data: {:#}", e);
|
||||
e
|
||||
})?;
|
||||
info!("Game data loaded");
|
||||
|
||||
let cert_file = &mut BufReader::new(File::open(&*CERT_FILE_PATH)?);
|
||||
let cert_chain: Vec<CertificateDer> = certs(cert_file).collect::<Result<Vec<_>, _>>()?;
|
||||
|
||||
let mut keys: Vec<PrivateKeyDer> = {
|
||||
let mut key_reader = BufReader::new(File::open(&*KEY_FILE_PATH)?);
|
||||
let pkcs8 = pkcs8_private_keys(&mut key_reader)
|
||||
.collect::<Result<Vec<_>, _>>()?
|
||||
.into_iter()
|
||||
.map(PrivateKeyDer::Pkcs8)
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
if !pkcs8.is_empty() {
|
||||
pkcs8
|
||||
} else {
|
||||
let mut key_reader = BufReader::new(File::open(&*KEY_FILE_PATH)?);
|
||||
rsa_private_keys(&mut key_reader)
|
||||
.collect::<Result<Vec<_>, _>>()?
|
||||
.into_iter()
|
||||
.map(PrivateKeyDer::Pkcs1)
|
||||
.collect()
|
||||
}
|
||||
};
|
||||
|
||||
let mut tls_config = ServerConfig::builder()
|
||||
.with_no_client_auth()
|
||||
.with_single_cert(cert_chain, keys.remove(0))?;
|
||||
tls_config.alpn_protocols = vec![b"h2".to_vec(), b"http/1.1".to_vec()];
|
||||
|
||||
let app_factory = move || {
|
||||
App::new()
|
||||
.wrap(from_fn(Logger))
|
||||
.wrap(from_fn(auth_middleware))
|
||||
.app_data(Data::new(db.clone()))
|
||||
// Basic routes
|
||||
.service(routes::basic::notice_info::notice_info_handler)
|
||||
.service(routes::basic::maintenace_info::maintenance_info_handler)
|
||||
.service(routes::basic::server_info::server_info_handler)
|
||||
.service(routes::basic::state_check_info_json::state_check_info_handle)
|
||||
// User routes
|
||||
.service(routes::user::login_user::login_user_handler)
|
||||
// Default routes
|
||||
.service(routes::default::balance_version_check::balance_check_version_handler)
|
||||
// Batch route (main batch endpoint)
|
||||
.service(routes::default::batch::batch::batch_request_handler)
|
||||
.service(routes::default::batch::batch::mission_info_handler)
|
||||
.service(routes::default::batch::batch::char_info_handler)
|
||||
.service(routes::default::batch::batch::recipe_info_handler)
|
||||
.service(routes::game::login_event::login_event_handler)
|
||||
.service(routes::game::schedule_info::schedule_info_handler)
|
||||
.service(routes::game::event_mission_info::event_mission_info_handler)
|
||||
.service(routes::game::event_reward_history::event_reward_history_handler)
|
||||
.service(routes::game::pack_event_story_info::pack_event_story_info_handler)
|
||||
.service(routes::game::pack_event_battle_info::pack_event_battle_info_handler)
|
||||
.service(routes::game::pictorial_book_info::pictorial_book_info_handler)
|
||||
.service(routes::game::attendance::attendance_info_handler)
|
||||
.service(routes::game::all_char_refresh::all_char_refresh_info_handler)
|
||||
.service(routes::game::save_total_battle_power::save_total_battle_power_handler)
|
||||
.service(routes::game::charge_cost_info::charge_cost_info_handler)
|
||||
.service(routes::basic::localization::localization_handler)
|
||||
.service(routes::basic::loki::loki_handler)
|
||||
.service(routes::game::equip_info::equip_info_handler)
|
||||
.service(routes::game::pack_preview_info::pack_preview_info_handler)
|
||||
.service(routes::game::monster_info::monster_info_handler)
|
||||
.service(routes::game::today_quest_info::today_quest_info_handler)
|
||||
.service(routes::game::waypoint_info::waypoint_info_handler)
|
||||
.service(routes::game::field_deck_info::field_deck_info_handler)
|
||||
.service(routes::game::hunting_ground_info_list::hunting_ground_info_list_handler)
|
||||
.service(routes::game::hunting_ground_info::hunting_ground_info_handler)
|
||||
.service(routes::game::tutorial_clear::tutorial_clear_handler)
|
||||
.service(routes::game::notice_detail_info::notice_detail_info_handler)
|
||||
.service(routes::game::save_user_position::save_user_position_handler)
|
||||
.service(routes::game::waypoint_save::waypoint_save_handler)
|
||||
.service(routes::game::server_now_time::server_now_time_handler)
|
||||
.service(routes::game::field_object_reward::field_object_reward_handler)
|
||||
};
|
||||
|
||||
info!("Starting server on {}", &GAME_SERVER_ADDRESS);
|
||||
|
||||
HttpServer::new(app_factory)
|
||||
.bind((GAME_SERVER_ADDRESS, 8082))? // HTTP
|
||||
.bind_rustls_0_22((GAME_SERVER_ADDRESS, 8443), tls_config)? // HTTPS (Rustls 0.23)
|
||||
.run()
|
||||
.await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
use std::path::PathBuf;
|
||||
|
||||
fn get_data_path() -> anyhow::Result<PathBuf> {
|
||||
// Always use CARGO_MANIFEST_DIR in development
|
||||
let base_dir = if let Ok(manifest_dir) = std::env::var("CARGO_MANIFEST_DIR") {
|
||||
PathBuf::from(manifest_dir)
|
||||
} else {
|
||||
// Fallback: try to find project root by looking for Cargo.toml
|
||||
let mut current = std::env::current_dir()?;
|
||||
loop {
|
||||
if current.join("Cargo.toml").exists() {
|
||||
break;
|
||||
}
|
||||
if !current.pop() {
|
||||
return Err(anyhow::anyhow!("Could not find project root"));
|
||||
}
|
||||
}
|
||||
current
|
||||
};
|
||||
|
||||
let data_path = base_dir.join("data\\tables");
|
||||
|
||||
if !data_path.exists() {
|
||||
return Err(anyhow::anyhow!(
|
||||
"Data directory not found at: {}\nExpected to find it at project root",
|
||||
data_path.display()
|
||||
));
|
||||
}
|
||||
|
||||
Ok(data_path)
|
||||
}
|
||||
148
httpserver/src/middleware/auth.rs
Normal file
148
httpserver/src/middleware/auth.rs
Normal file
@@ -0,0 +1,148 @@
|
||||
use actix_web::{
|
||||
Error, HttpMessage,
|
||||
body::MessageBody,
|
||||
dev::{ServiceRequest, ServiceResponse},
|
||||
error::ErrorUnauthorized,
|
||||
middleware::Next,
|
||||
};
|
||||
use sqlx::SqlitePool;
|
||||
use tracing::{debug, error, info, warn};
|
||||
|
||||
pub async fn auth_middleware(
|
||||
req: ServiceRequest,
|
||||
next: Next<impl MessageBody>,
|
||||
) -> Result<ServiceResponse<impl MessageBody>, Error> {
|
||||
let path = req.path();
|
||||
|
||||
// Skip auth for public endpoints
|
||||
if path.contains("MaintenanceInfo")
|
||||
|| path.contains("ServerInfo")
|
||||
|| path.contains("ServerNowTime")
|
||||
|| path.contains("NoticeInfo")
|
||||
|| path.contains("StateCheckInfoJson")
|
||||
|| path.contains("BalanceVersionCheck")
|
||||
|| path.contains("JoinUser")
|
||||
|| path.contains("LoginUser")
|
||||
|| path.contains("/loki/api/v1/push")
|
||||
{
|
||||
info!("Skipping auth for public endpoint: {}", path);
|
||||
return next.call(req).await;
|
||||
}
|
||||
|
||||
// Read the raw cookie header value
|
||||
let cookie_header = req
|
||||
.headers()
|
||||
.get("cookie")
|
||||
.and_then(|h| h.to_str().ok())
|
||||
.ok_or_else(|| {
|
||||
warn!("Missing cookie header for: {}", path);
|
||||
ErrorUnauthorized("Missing authentication")
|
||||
})?;
|
||||
|
||||
debug!("Cookie header value: {}", cookie_header);
|
||||
|
||||
// The cookie might be in format: "token|owner_index" or "name=token|owner_index"
|
||||
// Or multiple cookies: "cookie1=value1; cookie2=value2"
|
||||
// Try to find the auth token (format: something|number)
|
||||
let auth_value = cookie_header
|
||||
.split(';')
|
||||
.map(|s| s.trim())
|
||||
.find_map(|cookie| {
|
||||
// If it contains '=', extract the value part
|
||||
if let Some((_name, value)) = cookie.split_once('=') {
|
||||
// Check if value matches token|owner_index format
|
||||
if value.matches('|').count() == 1 {
|
||||
return Some(value.to_string());
|
||||
}
|
||||
} else {
|
||||
// No '=', so the whole thing might be the token
|
||||
if cookie.matches('|').count() == 1 {
|
||||
return Some(cookie.to_string());
|
||||
}
|
||||
}
|
||||
None
|
||||
})
|
||||
.ok_or_else(|| {
|
||||
warn!("No valid auth token found in cookies for: {}", path);
|
||||
ErrorUnauthorized("Missing authentication")
|
||||
})?;
|
||||
|
||||
debug!("Extracted auth value: {}", auth_value);
|
||||
|
||||
// Parse token|owner_index
|
||||
let owner_index = parse_and_validate_auth_cookie(&auth_value).map_err(|e| {
|
||||
warn!("Invalid auth token for {}: {}", path, e);
|
||||
ErrorUnauthorized("Invalid authentication")
|
||||
})?;
|
||||
|
||||
// Get database pool and convert to UID
|
||||
let pool = req
|
||||
.app_data::<actix_web::web::Data<SqlitePool>>()
|
||||
.ok_or_else(|| ErrorUnauthorized("Internal error"))?;
|
||||
|
||||
let uid =
|
||||
gameserver::logic::game::account::get_uid_for_owner_index(pool.get_ref(), owner_index)
|
||||
.await
|
||||
.map_err(|e| {
|
||||
error!("Failed to get UID: {}", e);
|
||||
ErrorUnauthorized("Invalid authentication")
|
||||
})?;
|
||||
|
||||
info!(
|
||||
"Authenticated owner_index {} (UID: {}) for {}",
|
||||
owner_index, uid, path
|
||||
);
|
||||
req.extensions_mut().insert(uid);
|
||||
|
||||
next.call(req).await
|
||||
}
|
||||
|
||||
/// Parse and validate the auth cookie
|
||||
/// Format: "access_token|owner_index"
|
||||
/// Example: "LdIv57CNLTBsMLKy1JEgkBUr9A7ztIENBNYcT5d06lMYlRsA3srNPwuZmgy8jaym|15559314"
|
||||
fn parse_and_validate_auth_cookie(cookie_value: &str) -> Result<i64, String> {
|
||||
let parts: Vec<&str> = cookie_value.split('|').collect();
|
||||
|
||||
if parts.len() != 2 {
|
||||
return Err(format!(
|
||||
"Invalid cookie format: expected 2 parts, got {}",
|
||||
parts.len()
|
||||
));
|
||||
}
|
||||
|
||||
let access_token = parts[0];
|
||||
let owner_index_str = parts[1];
|
||||
|
||||
// Validate access token is not empty and has reasonable length (at least 32 chars)
|
||||
if access_token.is_empty() || access_token.len() < 32 {
|
||||
return Err(format!(
|
||||
"Invalid access token length: {}",
|
||||
access_token.len()
|
||||
));
|
||||
}
|
||||
|
||||
// Validate access token contains only alphanumeric characters
|
||||
if !access_token.chars().all(|c| c.is_alphanumeric()) {
|
||||
return Err("Invalid access token characters".to_string());
|
||||
}
|
||||
|
||||
// Parse owner_index
|
||||
let owner_index = owner_index_str
|
||||
.parse::<i64>()
|
||||
.map_err(|e| format!("Invalid owner_index: {}", e))?;
|
||||
|
||||
// Validate owner_index is positive
|
||||
if owner_index <= 0 {
|
||||
return Err(format!(
|
||||
"Invalid owner_index: must be positive, got {}",
|
||||
owner_index
|
||||
));
|
||||
}
|
||||
|
||||
debug!(
|
||||
"Successfully validated auth cookie for owner_index: {}",
|
||||
owner_index
|
||||
);
|
||||
|
||||
Ok(owner_index)
|
||||
}
|
||||
14
httpserver/src/middleware/logger.rs
Normal file
14
httpserver/src/middleware/logger.rs
Normal file
@@ -0,0 +1,14 @@
|
||||
use actix_web::Error;
|
||||
use actix_web::dev::{ServiceRequest, ServiceResponse};
|
||||
use actix_web::middleware::Next;
|
||||
|
||||
#[allow(non_snake_case)]
|
||||
pub async fn Logger<B>(req: ServiceRequest, next: Next<B>) -> Result<ServiceResponse<B>, Error> {
|
||||
let method = req.method().clone();
|
||||
let path = req.path().to_string();
|
||||
tracing::info!("Incoming: {} {}", method, path);
|
||||
let rsp = next.call(req).await?;
|
||||
let status = rsp.status();
|
||||
tracing::info!("{} - {} {}", status, method, path);
|
||||
Ok(rsp)
|
||||
}
|
||||
2
httpserver/src/middleware/mod.rs
Normal file
2
httpserver/src/middleware/mod.rs
Normal file
@@ -0,0 +1,2 @@
|
||||
pub mod auth;
|
||||
pub mod logger;
|
||||
14
httpserver/src/routes/basic/localization.rs
Normal file
14
httpserver/src/routes/basic/localization.rs
Normal file
@@ -0,0 +1,14 @@
|
||||
use actix_web::{post, HttpResponse, Responder};
|
||||
use database::models::game::localization::Localization;
|
||||
use serde_json;
|
||||
|
||||
#[post("/api/gpg/price/localization")]
|
||||
async fn localization_handler() -> impl Responder {
|
||||
// Loads static localization JSON at compile time
|
||||
let data: Localization = serde_json::from_str(include_str!(
|
||||
"../../../../data/starter/localization_info.json"
|
||||
))
|
||||
.expect("Failed to parse localization_info.json");
|
||||
|
||||
HttpResponse::Ok().json(data)
|
||||
}
|
||||
8
httpserver/src/routes/basic/loki.rs
Normal file
8
httpserver/src/routes/basic/loki.rs
Normal file
@@ -0,0 +1,8 @@
|
||||
use actix_web::{post, HttpResponse, Result};
|
||||
|
||||
#[post("loki/api/v1/push")]
|
||||
async fn loki_handler() -> Result<HttpResponse> {
|
||||
let response = String::new();
|
||||
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
15
httpserver/src/routes/basic/maintenace_info.rs
Normal file
15
httpserver/src/routes/basic/maintenace_info.rs
Normal file
@@ -0,0 +1,15 @@
|
||||
use actix_web::{HttpResponse, Result, put};
|
||||
use bd2::proto::proto_net::MaintenanceInfoRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::maintenace_info;
|
||||
|
||||
#[put("MaintenanceInfo")]
|
||||
async fn maintenance_info_handler(body: String) -> Result<HttpResponse> {
|
||||
let req = parse_packet::<MaintenanceInfoRequest>("MaintenanceInfo", &body).map_err(|e| {
|
||||
tracing::warn!("Failed to parse MaintenanceInfo: {}", e);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
|
||||
let response = maintenace_info::handle(req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
6
httpserver/src/routes/basic/mod.rs
Normal file
6
httpserver/src/routes/basic/mod.rs
Normal file
@@ -0,0 +1,6 @@
|
||||
pub mod localization;
|
||||
pub mod loki;
|
||||
pub mod maintenace_info;
|
||||
pub mod notice_info;
|
||||
pub mod server_info;
|
||||
pub mod state_check_info_json;
|
||||
15
httpserver/src/routes/basic/notice_info.rs
Normal file
15
httpserver/src/routes/basic/notice_info.rs
Normal file
@@ -0,0 +1,15 @@
|
||||
use actix_web::{HttpResponse, Result, put};
|
||||
use bd2::proto::proto_net::NoticeInfoRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::notice_info;
|
||||
|
||||
#[put("NoticeInfo")]
|
||||
async fn notice_info_handler(body: String) -> Result<HttpResponse> {
|
||||
let req = parse_packet::<NoticeInfoRequest>("NoticeInfo", &body).map_err(|e| {
|
||||
tracing::warn!("Failed to parse NoticeInfo: {}", e);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
|
||||
let response = notice_info::handle(req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
15
httpserver/src/routes/basic/server_info.rs
Normal file
15
httpserver/src/routes/basic/server_info.rs
Normal file
@@ -0,0 +1,15 @@
|
||||
use actix_web::{HttpResponse, Result, put};
|
||||
use bd2::proto::proto_net::ServerInfoRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::server_info;
|
||||
|
||||
#[put("ServerInfo")]
|
||||
async fn server_info_handler(body: String) -> Result<HttpResponse> {
|
||||
let req = parse_packet::<ServerInfoRequest>("ServerInfo", &body).map_err(|e| {
|
||||
tracing::warn!("Failed to parse ServerInfo: {}", e);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
|
||||
let response = server_info::handle(req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
47
httpserver/src/routes/basic/state_check_info_json.rs
Normal file
47
httpserver/src/routes/basic/state_check_info_json.rs
Normal file
@@ -0,0 +1,47 @@
|
||||
use actix_web::{post, HttpResponse, Result};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tracing::info;
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
struct StateCheckInfoJsonRequest {
|
||||
pub seq: i32,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Debug)]
|
||||
struct StateCheckInfoJsonResponse {
|
||||
pub country: String,
|
||||
#[serde(rename = "errorType")]
|
||||
pub error_type: i32,
|
||||
#[serde(rename = "errorMessage")]
|
||||
pub error_message: String,
|
||||
}
|
||||
|
||||
#[post("/StateCheckInfoJson")]
|
||||
async fn state_check_info_handle(body: String) -> Result<HttpResponse> {
|
||||
// Try to parse the raw body string as JSON
|
||||
let req: StateCheckInfoJsonRequest = match serde_json::from_str(&body) {
|
||||
Ok(r) => {
|
||||
info!("Parsed request successfully: {:?}", r);
|
||||
r
|
||||
}
|
||||
Err(e) => {
|
||||
info!("Failed to parse request: {}", e);
|
||||
let error_response = StateCheckInfoJsonResponse {
|
||||
country: "".into(),
|
||||
error_type: 400,
|
||||
error_message: format!("Invalid JSON: {}", e),
|
||||
};
|
||||
return Ok(HttpResponse::BadRequest().json(error_response));
|
||||
}
|
||||
};
|
||||
|
||||
info!("StateCheckInfoJson Request: seq = {}", req.seq);
|
||||
|
||||
let response = StateCheckInfoJsonResponse {
|
||||
country: "US".to_string(),
|
||||
error_type: 0,
|
||||
error_message: "".to_string(),
|
||||
};
|
||||
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
16
httpserver/src/routes/default/balance_version_check.rs
Normal file
16
httpserver/src/routes/default/balance_version_check.rs
Normal file
@@ -0,0 +1,16 @@
|
||||
use actix_web::{HttpResponse, Result, put};
|
||||
use bd2::proto::proto_net::BalanceVersionCheckRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::balance_version_check;
|
||||
|
||||
#[put("BalanceVersionCheck")]
|
||||
async fn balance_check_version_handler(body: String) -> Result<HttpResponse> {
|
||||
let req =
|
||||
parse_packet::<BalanceVersionCheckRequest>("BalanceVersionCheck", &body).map_err(|e| {
|
||||
tracing::warn!("Failed to parse BalanceCheckVersion: {}", e);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
|
||||
let response = balance_version_check::handle(req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
779
httpserver/src/routes/default/batch/batch.rs
Normal file
779
httpserver/src/routes/default/batch/batch.rs
Normal file
@@ -0,0 +1,779 @@
|
||||
use actix_web::{HttpResponse, Result, put, web};
|
||||
use bd2::proto::proto_net::*;
|
||||
use crypto::aestools::AesTools;
|
||||
use crypto::network::{GameResponse, parse_packet};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use sqlx::SqlitePool;
|
||||
use tracing::{error, info, warn};
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
struct BatchRequestModel {
|
||||
path: String,
|
||||
#[serde(rename = "requestData")]
|
||||
request_data: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
struct BatchResponseItem {
|
||||
path: String,
|
||||
#[serde(rename = "responseData")]
|
||||
response_data: GameResponse,
|
||||
}
|
||||
|
||||
#[put("BatchRequest")]
|
||||
pub async fn batch_request_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: web::Bytes,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
info!("Received batch request");
|
||||
|
||||
let body_str = std::str::from_utf8(&body).map_err(|e| {
|
||||
error!("Failed to convert body to UTF-8: {}", e);
|
||||
actix_web::error::ErrorBadRequest("Invalid UTF-8 in body")
|
||||
})?;
|
||||
|
||||
let decrypted_json = match decrypt_batch_request(body_str) {
|
||||
Ok(json) => json,
|
||||
Err(e) => {
|
||||
warn!("Failed to decrypt batch request: {}", e);
|
||||
return Ok(HttpResponse::BadRequest().json(serde_json::json!({
|
||||
"error": "decryption_failed"
|
||||
})));
|
||||
}
|
||||
};
|
||||
|
||||
let batch_requests: Vec<BatchRequestModel> = match serde_json::from_str(&decrypted_json) {
|
||||
Ok(r) => r,
|
||||
Err(e) => {
|
||||
warn!("Failed to parse batch requests: {}", e);
|
||||
return Ok(HttpResponse::BadRequest().json(serde_json::json!({
|
||||
"error": "invalid_json"
|
||||
})));
|
||||
}
|
||||
};
|
||||
|
||||
let uid = *user_id;
|
||||
let mut responses = Vec::new();
|
||||
|
||||
info!(
|
||||
"Processing {} batch requests for user {}",
|
||||
batch_requests.len(),
|
||||
uid
|
||||
);
|
||||
|
||||
for request in batch_requests {
|
||||
let method_name = request.path.trim_start_matches('/');
|
||||
info!("Processing batch method: {}", method_name);
|
||||
|
||||
let game_response = match method_name {
|
||||
"MailInfo" => {
|
||||
match parse_packet::<MailInfoRequest>("MailInfo", &request.request_data) {
|
||||
Ok(req) => gameserver::logic::game::mail_info::handle(&pool, uid, req).await,
|
||||
Err(e) => {
|
||||
error!("Failed to parse MailInfo: {}", e);
|
||||
GameResponse::error(400)
|
||||
}
|
||||
}
|
||||
}
|
||||
"CashMailInfo" => {
|
||||
match parse_packet::<CashMailInfoRequest>("CashMailInfo", &request.request_data) {
|
||||
Ok(req) => {
|
||||
gameserver::logic::game::cash_mail_info::handle(&pool, uid, req).await
|
||||
}
|
||||
Err(e) => {
|
||||
error!("Failed to parse CashMailInfo: {}", e);
|
||||
GameResponse::error(400)
|
||||
}
|
||||
}
|
||||
}
|
||||
"PackInfo" => {
|
||||
match parse_packet::<PackInfoRequest>("PackInfo", &request.request_data) {
|
||||
Ok(req) => gameserver::logic::game::pack_info::handle(&pool, uid, req).await,
|
||||
Err(e) => {
|
||||
error!("Failed to parse PackInfo: {}", e);
|
||||
GameResponse::error(400)
|
||||
}
|
||||
}
|
||||
}
|
||||
"QuestMaxClearInfo" => {
|
||||
match parse_packet::<QuestMaxClearInfoRequest>(
|
||||
"QuestMaxClearInfo",
|
||||
&request.request_data,
|
||||
) {
|
||||
Ok(req) => {
|
||||
gameserver::logic::game::quest_max_clear_info::handle(&pool, uid, req).await
|
||||
}
|
||||
Err(e) => {
|
||||
error!("Failed to parse QuestMaxClearInfo: {}", e);
|
||||
GameResponse::error(400)
|
||||
}
|
||||
}
|
||||
}
|
||||
"PassInfo" => {
|
||||
match parse_packet::<PassInfoRequest>("PassInfo", &request.request_data) {
|
||||
Ok(req) => gameserver::logic::game::pass_info::handle(&pool, uid, req).await,
|
||||
Err(e) => {
|
||||
error!("Failed to parse PassInfo: {}", e);
|
||||
GameResponse::error(400)
|
||||
}
|
||||
}
|
||||
}
|
||||
"PvpBattleUserInfo" => {
|
||||
match parse_packet::<PvpBattleUserInfoRequest>(
|
||||
"PvpBattleUserInfo",
|
||||
&request.request_data,
|
||||
) {
|
||||
Ok(req) => {
|
||||
gameserver::logic::game::pvp_battle_user_info::handle(&pool, uid, req).await
|
||||
}
|
||||
Err(e) => {
|
||||
error!("Failed to parse PvpBattleUserInfo: {}", e);
|
||||
GameResponse::error(400)
|
||||
}
|
||||
}
|
||||
}
|
||||
"ItemInfo" => {
|
||||
match parse_packet::<ItemInfoRequest>("ItemInfo", &request.request_data) {
|
||||
Ok(req) => gameserver::logic::game::item_info::handle(&pool, uid, req).await,
|
||||
Err(e) => {
|
||||
error!("Failed to parse ItemInfo: {}", e);
|
||||
GameResponse::error(400)
|
||||
}
|
||||
}
|
||||
}
|
||||
"CostumeInfo" => {
|
||||
match parse_packet::<CostumeInfoRequest>("CostumeInfo", &request.request_data) {
|
||||
Ok(req) => gameserver::logic::game::costume_info::handle(&pool, uid, req).await,
|
||||
Err(e) => {
|
||||
error!("Failed to parse CostumeInfo: {}", e);
|
||||
GameResponse::error(400)
|
||||
}
|
||||
}
|
||||
}
|
||||
"RecipeInfo" => {
|
||||
match parse_packet::<RecipeInfoRequest>("RecipeInfo", &request.request_data) {
|
||||
Ok(req) => gameserver::logic::game::recipe_info::handle(&pool, uid, req).await,
|
||||
Err(e) => {
|
||||
error!("Failed to parse RecipeInfo: {}", e);
|
||||
GameResponse::error(400)
|
||||
}
|
||||
}
|
||||
}
|
||||
"CashShopInfo" => {
|
||||
match parse_packet::<CashShopInfoRequest>("CashShopInfo", &request.request_data) {
|
||||
Ok(req) => {
|
||||
gameserver::logic::game::cash_shop_info::handle(&pool, uid, req).await
|
||||
}
|
||||
Err(e) => {
|
||||
error!("Failed to parse CashShopInfo: {}", e);
|
||||
GameResponse::error(400)
|
||||
}
|
||||
}
|
||||
}
|
||||
"TutorialInfo" => {
|
||||
match parse_packet::<TutorialInfoRequest>("TutorialInfo", &request.request_data) {
|
||||
Ok(req) => {
|
||||
gameserver::logic::game::tutorial_info::handle(&pool, uid, req).await
|
||||
}
|
||||
Err(e) => {
|
||||
error!("Failed to parse TutorialInfo: {}", e);
|
||||
GameResponse::error(400)
|
||||
}
|
||||
}
|
||||
}
|
||||
"CharInfo" => {
|
||||
match parse_packet::<CharInfoRequest>("CharInfo", &request.request_data) {
|
||||
Ok(req) => gameserver::logic::game::char_info::handle(&pool, uid, req).await,
|
||||
Err(e) => {
|
||||
error!("Failed to parse CharInfo: {}", e);
|
||||
GameResponse::error(400)
|
||||
}
|
||||
}
|
||||
}
|
||||
"DispatchInfo" => {
|
||||
match parse_packet::<DispatchInfoRequest>("DispatchInfo", &request.request_data) {
|
||||
Ok(req) => {
|
||||
gameserver::logic::game::dispatch_info::handle(&pool, uid, req).await
|
||||
}
|
||||
Err(e) => {
|
||||
error!("Failed to parse DispatchInfo: {}", e);
|
||||
GameResponse::error(400)
|
||||
}
|
||||
}
|
||||
}
|
||||
"TotalWarRewardState" => {
|
||||
match parse_packet::<TotalWarRewardStateRequest>(
|
||||
"TotalWarRewardState",
|
||||
&request.request_data,
|
||||
) {
|
||||
Ok(req) => {
|
||||
gameserver::logic::game::total_war_reward_state::handle(&pool, uid, req)
|
||||
.await
|
||||
}
|
||||
Err(e) => {
|
||||
error!("Failed to parse TotalWarRewardState: {}", e);
|
||||
GameResponse::error(400)
|
||||
}
|
||||
}
|
||||
}
|
||||
"CommunityRewardInfo" => {
|
||||
match parse_packet::<CommunityRewardInfoRequest>(
|
||||
"CommunityRewardInfo",
|
||||
&request.request_data,
|
||||
) {
|
||||
Ok(req) => {
|
||||
gameserver::logic::game::community_reward_info::handle(&pool, uid, req)
|
||||
.await
|
||||
}
|
||||
Err(e) => {
|
||||
error!("Failed to parse CommunityRewardInfo: {}", e);
|
||||
GameResponse::error(400)
|
||||
}
|
||||
}
|
||||
}
|
||||
"EventScheduleInfo" => {
|
||||
match parse_packet::<EventScheduleInfoRequest>(
|
||||
"EventScheduleInfo",
|
||||
&request.request_data,
|
||||
) {
|
||||
Ok(req) => {
|
||||
gameserver::logic::game::event_schedule_info::handle(&pool, uid, req).await
|
||||
}
|
||||
Err(e) => {
|
||||
error!("Failed to parse EventScheduleInfo: {}", e);
|
||||
GameResponse::error(400)
|
||||
}
|
||||
}
|
||||
}
|
||||
"EventExchangeInfo" => {
|
||||
match parse_packet::<EventExchangeInfoRequest>(
|
||||
"EventExchangeInfo",
|
||||
&request.request_data,
|
||||
) {
|
||||
Ok(req) => {
|
||||
gameserver::logic::game::event_exchange_info::handle(&pool, uid, req).await
|
||||
}
|
||||
Err(e) => {
|
||||
error!("Failed to parse EventExchangeInfo: {}", e);
|
||||
GameResponse::error(400)
|
||||
}
|
||||
}
|
||||
}
|
||||
"MonsterHuntScheduleInfo" => {
|
||||
match parse_packet::<MonsterHuntScheduleInfoRequest>(
|
||||
"MonsterHuntScheduleInfo",
|
||||
&request.request_data,
|
||||
) {
|
||||
Ok(req) => {
|
||||
gameserver::logic::game::monster_hunt_schedule_info::handle(&pool, uid, req)
|
||||
.await
|
||||
}
|
||||
Err(e) => {
|
||||
error!("Failed to parse MonsterHuntScheduleInfo: {}", e);
|
||||
GameResponse::error(400)
|
||||
}
|
||||
}
|
||||
}
|
||||
"MonsterHuntDeckInfo" => {
|
||||
match parse_packet::<MonsterHuntDeckInfoRequest>(
|
||||
"MonsterHuntDeckInfo",
|
||||
&request.request_data,
|
||||
) {
|
||||
Ok(req) => {
|
||||
gameserver::logic::game::monster_hunt_deck_info::handle(&pool, uid, req)
|
||||
.await
|
||||
}
|
||||
Err(e) => {
|
||||
error!("Failed to parse MonsterHuntDeckInfo: {}", e);
|
||||
GameResponse::error(400)
|
||||
}
|
||||
}
|
||||
}
|
||||
"CharScoutInfo" => {
|
||||
match parse_packet::<CharScoutInfoRequest>("CharScoutInfo", &request.request_data) {
|
||||
Ok(req) => {
|
||||
gameserver::logic::game::char_scout_info::handle(&pool, uid, req).await
|
||||
}
|
||||
Err(e) => {
|
||||
error!("Failed to parse CharScoutInfo: {}", e);
|
||||
GameResponse::error(400)
|
||||
}
|
||||
}
|
||||
}
|
||||
"AchievementInfo" => {
|
||||
match parse_packet::<AchievementInfoRequest>(
|
||||
"AchievementInfo",
|
||||
&request.request_data,
|
||||
) {
|
||||
Ok(req) => {
|
||||
gameserver::logic::game::achievement_info::handle(&pool, uid, req).await
|
||||
}
|
||||
Err(e) => {
|
||||
error!("Failed to parse AchievementInfo: {}", e);
|
||||
GameResponse::error(400)
|
||||
}
|
||||
}
|
||||
}
|
||||
"CharPartnerInfo" => {
|
||||
match parse_packet::<CharPartnerInfoRequest>(
|
||||
"CharPartnerInfo",
|
||||
&request.request_data,
|
||||
) {
|
||||
Ok(req) => {
|
||||
gameserver::logic::game::char_partner_info::handle(&pool, uid, req).await
|
||||
}
|
||||
Err(e) => {
|
||||
error!("Failed to parse CharPartnerInfo: {}", e);
|
||||
GameResponse::error(400)
|
||||
}
|
||||
}
|
||||
}
|
||||
"PresetInfo" => {
|
||||
match parse_packet::<PresetInfoRequest>("PresetInfo", &request.request_data) {
|
||||
Ok(req) => gameserver::logic::game::preset_info::handle(&pool, uid, req).await,
|
||||
Err(e) => {
|
||||
error!("Failed to parse PresetInfo: {}", e);
|
||||
GameResponse::error(400)
|
||||
}
|
||||
}
|
||||
}
|
||||
"HuntDispatchInfo" => {
|
||||
match parse_packet::<HuntDispatchInfoRequest>(
|
||||
"HuntDispatchInfo",
|
||||
&request.request_data,
|
||||
) {
|
||||
Ok(req) => {
|
||||
gameserver::logic::game::hunt_dispatch_info::handle(&pool, uid, req).await
|
||||
}
|
||||
Err(e) => {
|
||||
error!("Failed to parse HuntDispatchInfo: {}", e);
|
||||
GameResponse::error(400)
|
||||
}
|
||||
}
|
||||
}
|
||||
"MonsterHuntUserInfo" => {
|
||||
match parse_packet::<MonsterHuntUserInfoRequest>(
|
||||
"MonsterHuntUserInfo",
|
||||
&request.request_data,
|
||||
) {
|
||||
Ok(req) => {
|
||||
gameserver::logic::game::monster_hunt_user_info::handle(&pool, uid, req)
|
||||
.await
|
||||
}
|
||||
Err(e) => {
|
||||
error!("Failed to parse MonsterHuntUserInfo: {}", e);
|
||||
GameResponse::error(400)
|
||||
}
|
||||
}
|
||||
}
|
||||
"PersonalInfo" => {
|
||||
match parse_packet::<PersonalInfoRequest>("PersonalInfo", &request.request_data) {
|
||||
Ok(req) => {
|
||||
gameserver::logic::game::personal_info::handle(&pool, uid, req).await
|
||||
}
|
||||
Err(e) => {
|
||||
error!("Failed to parse PersonalInfo: {}", e);
|
||||
GameResponse::error(400)
|
||||
}
|
||||
}
|
||||
}
|
||||
"MyLikeInfo" => {
|
||||
match parse_packet::<MyLikeInfoRequest>("MyLikeInfo", &request.request_data) {
|
||||
Ok(req) => gameserver::logic::game::my_like_info::handle(&pool, uid, req).await,
|
||||
Err(e) => {
|
||||
error!("Failed to parse MyLikeInfo: {}", e);
|
||||
GameResponse::error(400)
|
||||
}
|
||||
}
|
||||
}
|
||||
"FriendInfoList" => {
|
||||
match parse_packet::<FriendInfoListRequest>("FriendInfoList", &request.request_data)
|
||||
{
|
||||
Ok(req) => {
|
||||
gameserver::logic::game::friend_info_list::handle(&pool, uid, req).await
|
||||
}
|
||||
Err(e) => {
|
||||
error!("Failed to parse FriendInfoList: {}", e);
|
||||
GameResponse::error(400)
|
||||
}
|
||||
}
|
||||
}
|
||||
"EventHubInfo" => {
|
||||
match parse_packet::<EventHubInfoRequest>("EventHubInfo", &request.request_data) {
|
||||
Ok(req) => {
|
||||
gameserver::logic::game::event_hub_info::handle(&pool, uid, req).await
|
||||
}
|
||||
Err(e) => {
|
||||
error!("Failed to parse EventHubInfo: {}", e);
|
||||
GameResponse::error(400)
|
||||
}
|
||||
}
|
||||
}
|
||||
"MiniGameHubInfo" => {
|
||||
match parse_packet::<MiniGameHubInfoRequest>(
|
||||
"MiniGameHubInfo",
|
||||
&request.request_data,
|
||||
) {
|
||||
Ok(req) => {
|
||||
gameserver::logic::game::mini_game_hub_info::handle(&pool, uid, req).await
|
||||
}
|
||||
Err(e) => {
|
||||
error!("Failed to parse MiniGameHubInfo: {}", e);
|
||||
GameResponse::error(400)
|
||||
}
|
||||
}
|
||||
}
|
||||
"EquipPresetInfo" => {
|
||||
match parse_packet::<EquipPresetInfoRequest>(
|
||||
"EquipPresetInfo",
|
||||
&request.request_data,
|
||||
) {
|
||||
Ok(req) => {
|
||||
gameserver::logic::game::equip_preset_info::handle(&pool, uid, req).await
|
||||
}
|
||||
Err(e) => {
|
||||
error!("Failed to parse EquipPresetInfo: {}", e);
|
||||
GameResponse::error(400)
|
||||
}
|
||||
}
|
||||
}
|
||||
"MyRoomItemInfo" => {
|
||||
match parse_packet::<MyRoomItemInfoRequest>("MyRoomItemInfo", &request.request_data)
|
||||
{
|
||||
Ok(req) => {
|
||||
gameserver::logic::game::my_room_item_info::handle(&pool, uid, req).await
|
||||
}
|
||||
Err(e) => {
|
||||
error!("Failed to parse MyRoomItemInfo: {}", e);
|
||||
GameResponse::error(400)
|
||||
}
|
||||
}
|
||||
}
|
||||
"SeasonRewardInfo" => {
|
||||
match parse_packet::<SeasonRewardInfoRequest>(
|
||||
"SeasonRewardInfo",
|
||||
&request.request_data,
|
||||
) {
|
||||
Ok(req) => {
|
||||
gameserver::logic::game::season_reward_info::handle(&pool, uid, req).await
|
||||
}
|
||||
Err(e) => {
|
||||
error!("Failed to parse SeasonRewardInfo: {}", e);
|
||||
GameResponse::error(400)
|
||||
}
|
||||
}
|
||||
}
|
||||
"GuildInitInfo" => {
|
||||
match parse_packet::<GuildInitInfoRequest>("GuildInitInfo", &request.request_data) {
|
||||
Ok(req) => {
|
||||
gameserver::logic::game::guild_init_info::handle(&pool, uid, req).await
|
||||
}
|
||||
Err(e) => {
|
||||
error!("Failed to parse GuildInitInfo: {}", e);
|
||||
GameResponse::error(400)
|
||||
}
|
||||
}
|
||||
}
|
||||
"CharAwakeInfo" => {
|
||||
match parse_packet::<CharAwakeInfoRequest>("CharAwakeInfo", &request.request_data) {
|
||||
Ok(req) => {
|
||||
gameserver::logic::game::char_awake_info::handle(&pool, uid, req).await
|
||||
}
|
||||
Err(e) => {
|
||||
error!("Failed to parse CharAwakeInfo: {}", e);
|
||||
GameResponse::error(400)
|
||||
}
|
||||
}
|
||||
}
|
||||
"RootSortIdInfo" => {
|
||||
match parse_packet::<RootSortIdInfoRequest>("RootSortIdInfo", &request.request_data)
|
||||
{
|
||||
Ok(req) => {
|
||||
gameserver::logic::game::root_sort_id_info::handle(&pool, uid, req).await
|
||||
}
|
||||
Err(e) => {
|
||||
error!("Failed to parse RootSortIdInfo: {}", e);
|
||||
GameResponse::error(400)
|
||||
}
|
||||
}
|
||||
}
|
||||
"DatingInfo" => {
|
||||
match parse_packet::<DatingInfoRequest>("DatingInfo", &request.request_data) {
|
||||
Ok(req) => gameserver::logic::game::dating_info::handle(&pool, uid, req).await,
|
||||
Err(e) => {
|
||||
error!("Failed to parse DatingInfo: {}", e);
|
||||
GameResponse::error(400)
|
||||
}
|
||||
}
|
||||
}
|
||||
"GuildRaidSeasonReward" => {
|
||||
match parse_packet::<GuildRaidSeasonRewardRequest>(
|
||||
"GuildRaidSeasonReward",
|
||||
&request.request_data,
|
||||
) {
|
||||
Ok(req) => {
|
||||
gameserver::logic::game::guild_raid_season_reward::handle(&pool, uid, req)
|
||||
.await
|
||||
}
|
||||
Err(e) => {
|
||||
error!("Failed to parse GuildRaidSeasonReward: {}", e);
|
||||
GameResponse::error(400)
|
||||
}
|
||||
}
|
||||
}
|
||||
"EvilCastleTowerInfo" => {
|
||||
match parse_packet::<EvilCastleTowerInfoRequest>(
|
||||
"EvilCastleTowerInfo",
|
||||
&request.request_data,
|
||||
) {
|
||||
Ok(req) => {
|
||||
gameserver::logic::game::evil_castle_tower_info::handle(&pool, uid, req)
|
||||
.await
|
||||
}
|
||||
Err(e) => {
|
||||
error!("Failed to parse EvilCastleTowerInfo: {}", e);
|
||||
GameResponse::error(400)
|
||||
}
|
||||
}
|
||||
}
|
||||
"CafeteriaInfo" => {
|
||||
match parse_packet::<CafeteriaInfoRequest>("CafeteriaInfo", &request.request_data) {
|
||||
Ok(req) => {
|
||||
gameserver::logic::game::cafeteria_info::handle(&pool, uid, req).await
|
||||
}
|
||||
Err(e) => {
|
||||
error!("Failed to parse CafeteriaInfo: {}", e);
|
||||
GameResponse::error(400)
|
||||
}
|
||||
}
|
||||
}
|
||||
"MiniGameDefenseInfo" => {
|
||||
match parse_packet::<MiniGameDefenseInfoRequest>(
|
||||
"MiniGameDefenseInfo",
|
||||
&request.request_data,
|
||||
) {
|
||||
Ok(req) => {
|
||||
gameserver::logic::game::mini_game_defense_info::handle(&pool, uid, req)
|
||||
.await
|
||||
}
|
||||
Err(e) => {
|
||||
error!("Failed to parse MiniGameDefenseInfo: {}", e);
|
||||
GameResponse::error(400)
|
||||
}
|
||||
}
|
||||
}
|
||||
"DeckCostumeSettingInfo" => {
|
||||
match parse_packet::<DeckCostumeSettingInfoRequest>(
|
||||
"DeckCostumeSettingInfo",
|
||||
&request.request_data,
|
||||
) {
|
||||
Ok(req) => {
|
||||
gameserver::logic::game::deck_costume_setting_info::handle(&pool, uid, req)
|
||||
.await
|
||||
}
|
||||
Err(e) => {
|
||||
error!("Failed to parse DeckCostumeSettingInfo: {}", e);
|
||||
GameResponse::error(400)
|
||||
}
|
||||
}
|
||||
}
|
||||
"PrestigeSkinInfo" => {
|
||||
match parse_packet::<PrestigeSkinInfoRequest>(
|
||||
"PrestigeSkinInfo",
|
||||
&request.request_data,
|
||||
) {
|
||||
Ok(req) => {
|
||||
gameserver::logic::game::prestige_skin_info::handle(&pool, uid, req).await
|
||||
}
|
||||
Err(e) => {
|
||||
error!("Failed to parse PrestigeSkinInfo: {}", e);
|
||||
GameResponse::error(400)
|
||||
}
|
||||
}
|
||||
}
|
||||
"EvilCastleDailyRewardState" => {
|
||||
match parse_packet::<EvilCastleDailyRewardStateRequest>(
|
||||
"EvilCastleDailyRewardState",
|
||||
&request.request_data,
|
||||
) {
|
||||
Ok(req) => {
|
||||
gameserver::logic::game::evil_castle_daily_reward_state::handle(
|
||||
&pool, uid, req,
|
||||
)
|
||||
.await
|
||||
}
|
||||
Err(e) => {
|
||||
error!("Failed to parse EvilCastleDailyRewardState: {}", e);
|
||||
GameResponse::error(400)
|
||||
}
|
||||
}
|
||||
}
|
||||
"IdCardPresetInfo" => {
|
||||
match parse_packet::<IdCardPresetInfoRequest>(
|
||||
"IdCardPresetInfo",
|
||||
&request.request_data,
|
||||
) {
|
||||
Ok(req) => {
|
||||
gameserver::logic::game::id_card_preset_info::handle(&pool, uid, req).await
|
||||
}
|
||||
Err(e) => {
|
||||
error!("Failed to parse IdCardPresetInfo: {}", e);
|
||||
GameResponse::error(400)
|
||||
}
|
||||
}
|
||||
}
|
||||
"SkyWayScheduleInfo" => {
|
||||
match parse_packet::<SkyWayScheduleInfoRequest>(
|
||||
"SkyWayScheduleInfo",
|
||||
&request.request_data,
|
||||
) {
|
||||
Ok(req) => {
|
||||
gameserver::logic::game::sky_way_schedule_info::handle(&pool, uid, req)
|
||||
.await
|
||||
}
|
||||
Err(e) => {
|
||||
error!("Failed to parse SkyWayScheduleInfo: {}", e);
|
||||
GameResponse::error(400)
|
||||
}
|
||||
}
|
||||
}
|
||||
"FieldTrapInfo" => {
|
||||
match parse_packet::<FieldTrapInfoRequest>("FieldTrapInfo", &request.request_data) {
|
||||
Ok(req) => {
|
||||
gameserver::logic::game::field_trap_info::handle(&pool, uid, req).await
|
||||
}
|
||||
Err(e) => {
|
||||
error!("Failed to parse FieldTrapInfo: {}", e);
|
||||
GameResponse::error(400)
|
||||
}
|
||||
}
|
||||
}
|
||||
"DeckInfo" => {
|
||||
match parse_packet::<DeckInfoRequest>("DeckInfo", &request.request_data) {
|
||||
Ok(req) => gameserver::logic::game::deck_info::handle(&pool, uid, req).await,
|
||||
Err(e) => {
|
||||
error!("Failed to parse DeckInfo: {}", e);
|
||||
GameResponse::error(400)
|
||||
}
|
||||
}
|
||||
}
|
||||
"FieldObjectInfo" => {
|
||||
match parse_packet::<FieldObjectInfoRequest>(
|
||||
"FieldObjectInfo",
|
||||
&request.request_data,
|
||||
) {
|
||||
Ok(req) => {
|
||||
gameserver::logic::game::field_object_info::handle(&pool, uid, req).await
|
||||
}
|
||||
Err(e) => {
|
||||
error!("Failed to parse FieldObjectInfo: {}", e);
|
||||
GameResponse::error(400)
|
||||
}
|
||||
}
|
||||
}
|
||||
"PackInGameInfo" => {
|
||||
match parse_packet::<PackInGameInfoRequest>("PackInGameInfo", &request.request_data)
|
||||
{
|
||||
Ok(req) => {
|
||||
gameserver::logic::game::pack_in_game_info::handle(&pool, uid, req).await
|
||||
}
|
||||
Err(e) => {
|
||||
error!("Failed to parse PackInGameInfo: {}", e);
|
||||
GameResponse::error(400)
|
||||
}
|
||||
}
|
||||
}
|
||||
"LoginEvent" => {
|
||||
match parse_packet::<LoginEventRequest>("LoginEvent", &request.request_data) {
|
||||
Ok(req) => gameserver::logic::game::login_event::handle(&pool, uid, req).await,
|
||||
Err(e) => {
|
||||
error!("Failed to parse LoginEvent: {}", e);
|
||||
GameResponse::error(400)
|
||||
}
|
||||
}
|
||||
}
|
||||
// ... other routes
|
||||
_ => {
|
||||
warn!("Unknown batch method: {}", method_name);
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
responses.push(BatchResponseItem {
|
||||
path: request.path.clone(),
|
||||
response_data: game_response,
|
||||
});
|
||||
}
|
||||
|
||||
Ok(HttpResponse::Ok().json(responses))
|
||||
}
|
||||
|
||||
fn decrypt_batch_request(body: &str) -> Result<String, String> {
|
||||
let decrypted_bytes = AesTools::aes_decrypt_raw(body, crypto::aestools::DEFAULT_KEY)
|
||||
.map_err(|_| "AES decryption failed".to_string())?;
|
||||
String::from_utf8(decrypted_bytes).map_err(|e| format!("UTF-8 conversion failed: {}", e))
|
||||
}
|
||||
|
||||
// Individual endpoint handlers
|
||||
#[put("MissionInfo")]
|
||||
pub async fn mission_info_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
|
||||
let req = match parse_packet::<MissionInfoRequest>("MissionInfo", &body) {
|
||||
Ok(r) => r,
|
||||
Err(e) => {
|
||||
error!("Failed to parse MissionInfo: {}", e);
|
||||
return Ok(HttpResponse::Ok().json(GameResponse::error(400)));
|
||||
}
|
||||
};
|
||||
|
||||
let response = gameserver::logic::game::mission_info::handle(&pool, uid, req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
|
||||
#[put("CharInfo")]
|
||||
pub async fn char_info_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
|
||||
let req = match parse_packet::<CharInfoRequest>("CharInfo", &body) {
|
||||
Ok(r) => r,
|
||||
Err(e) => {
|
||||
error!("Failed to parse CharInfo: {}", e);
|
||||
return Ok(HttpResponse::Ok().json(GameResponse::error(400)));
|
||||
}
|
||||
};
|
||||
|
||||
let response = gameserver::logic::game::char_info::handle(&pool, uid, req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
|
||||
#[put("RecipeInfo")]
|
||||
pub async fn recipe_info_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
|
||||
let req = match parse_packet::<RecipeInfoRequest>("RecipeInfo", &body) {
|
||||
Ok(r) => r,
|
||||
Err(e) => {
|
||||
error!("Failed to parse RecipeInfo: {}", e);
|
||||
return Ok(HttpResponse::Ok().json(GameResponse::error(400)));
|
||||
}
|
||||
};
|
||||
|
||||
let response = gameserver::logic::game::recipe_info::handle(&pool, uid, req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
|
||||
// ... more handlers
|
||||
1
httpserver/src/routes/default/batch/mod.rs
Normal file
1
httpserver/src/routes/default/batch/mod.rs
Normal file
@@ -0,0 +1 @@
|
||||
pub mod batch;
|
||||
2
httpserver/src/routes/default/mod.rs
Normal file
2
httpserver/src/routes/default/mod.rs
Normal file
@@ -0,0 +1,2 @@
|
||||
pub mod balance_version_check;
|
||||
pub mod batch;
|
||||
20
httpserver/src/routes/game/achievement_clear.rs
Normal file
20
httpserver/src/routes/game/achievement_clear.rs
Normal file
@@ -0,0 +1,20 @@
|
||||
use actix_web::{put, web, HttpResponse, Result };
|
||||
use bd2::proto::proto_net::AchievementClearRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::achievement_clear;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[put("AchievementClear")]
|
||||
async fn achievement_clear_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
let req = parse_packet::<AchievementClearRequest>("AchievementClear", &body).map_err(|e| {
|
||||
tracing::warn!("Failed to parse AchievementClear: {}", e);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
let response = achievement_clear::handle(&pool, uid, req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
20
httpserver/src/routes/game/achievement_info.rs
Normal file
20
httpserver/src/routes/game/achievement_info.rs
Normal file
@@ -0,0 +1,20 @@
|
||||
use actix_web::{put, web, HttpResponse, Result};
|
||||
use bd2::proto::proto_net::AchievementInfoRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::achievement_info;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[put("AchievementInfo")]
|
||||
async fn achievement_info_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
let req = parse_packet::<AchievementInfoRequest>("AchievementInfo", &body).map_err(|e| {
|
||||
tracing::warn!("Failed to parse AchievementInfo: {}", e);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
let response = achievement_info::handle(&pool, uid, req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
21
httpserver/src/routes/game/achievement_update.rs
Normal file
21
httpserver/src/routes/game/achievement_update.rs
Normal file
@@ -0,0 +1,21 @@
|
||||
use actix_web::{put, web, HttpResponse, Result};
|
||||
use bd2::proto::proto_net::AchievementUpdateRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::achievement_update;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[put("AchievementUpdate")]
|
||||
async fn achievement_update_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
let req =
|
||||
parse_packet::<AchievementUpdateRequest>("AchievementUpdate", &body).map_err(|e| {
|
||||
tracing::warn!("Failed to parse AchievementUpdate: {}", e);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
let response = achievement_update::handle(&pool, uid, req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
20
httpserver/src/routes/game/active_map.rs
Normal file
20
httpserver/src/routes/game/active_map.rs
Normal file
@@ -0,0 +1,20 @@
|
||||
use actix_web::{put, web, HttpResponse, Result};
|
||||
use bd2::proto::proto_net::ActiveMapRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::active_map;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[put("ActiveMap")]
|
||||
async fn active_map_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
let req = parse_packet::<ActiveMapRequest>("ActiveMap", &body).map_err(|e| {
|
||||
tracing::warn!("Failed to parse ActiveMap: {}", e);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
let response = active_map::handle(&pool, uid, req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
20
httpserver/src/routes/game/alchemy.rs
Normal file
20
httpserver/src/routes/game/alchemy.rs
Normal file
@@ -0,0 +1,20 @@
|
||||
use actix_web::{put, web, HttpResponse, Result};
|
||||
use bd2::proto::proto_net::AlchemyRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::alchemy;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[put("Alchemy")]
|
||||
async fn alchemy_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
let req = parse_packet::<AlchemyRequest>("Alchemy", &body).map_err(|e| {
|
||||
tracing::warn!("Failed to parse Alchemy: {}", e);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
let response = alchemy::handle(&pool, uid, req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
20
httpserver/src/routes/game/alchemy_batch.rs
Normal file
20
httpserver/src/routes/game/alchemy_batch.rs
Normal file
@@ -0,0 +1,20 @@
|
||||
use actix_web::{put, web, HttpResponse, Result};
|
||||
use bd2::proto::proto_net::AlchemyBatchRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::alchemy_batch;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[put("AlchemyBatch")]
|
||||
async fn alchemy_batch_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
let req = parse_packet::<AlchemyBatchRequest>("AlchemyBatch", &body).map_err(|e| {
|
||||
tracing::warn!("Failed to parse AlchemyBatch: {}", e);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
let response = alchemy_batch::handle(&pool, uid, req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
23
httpserver/src/routes/game/all_char_refresh.rs
Normal file
23
httpserver/src/routes/game/all_char_refresh.rs
Normal file
@@ -0,0 +1,23 @@
|
||||
use actix_web::{put, web, HttpResponse, Result};
|
||||
use bd2::proto::proto_net::AllCharRefreshRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::all_char_refresh;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[put("AllCharRefresh")]
|
||||
async fn all_char_refresh_info_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
|
||||
let req = parse_packet::<AllCharRefreshRequest>("AllCharRefresh", &body).map_err(|e| {
|
||||
tracing::warn!("Failed to parse AllCharRefresh: {}", e);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
|
||||
let response = all_char_refresh::handle(&pool, uid, req).await;
|
||||
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
23
httpserver/src/routes/game/attendance.rs
Normal file
23
httpserver/src/routes/game/attendance.rs
Normal file
@@ -0,0 +1,23 @@
|
||||
use actix_web::{put, web, HttpResponse, Result};
|
||||
use bd2::proto::proto_net::AttendanceRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::attendance;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[put("Attendance")]
|
||||
async fn attendance_info_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
|
||||
let req = parse_packet::<AttendanceRequest>("Attendance", &body).map_err(|e| {
|
||||
tracing::warn!("Failed to parse Attendance: {}", e);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
|
||||
let response = attendance::handle(&pool, uid, req).await;
|
||||
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
21
httpserver/src/routes/game/attendance_info.rs
Normal file
21
httpserver/src/routes/game/attendance_info.rs
Normal file
@@ -0,0 +1,21 @@
|
||||
use actix_web::{HttpResponse, Result, put, web};
|
||||
use bd2::proto::proto_net::AttendanceInfoRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::attendance;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[put("AttendanceInfo")]
|
||||
async fn attendance_info_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
let req = parse_packet::<AttendanceInfoRequest>("AttendanceInfo", &body).map_err(|e| {
|
||||
tracing::warn!("Failed to parse AttendanceInfo: {}", e);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
//let response = attendance_info::handle(&pool, uid, req).await;
|
||||
let response = ""; // need to fix
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
21
httpserver/src/routes/game/balance_version_check.rs
Normal file
21
httpserver/src/routes/game/balance_version_check.rs
Normal file
@@ -0,0 +1,21 @@
|
||||
use actix_web::{HttpResponse, Result, put, web};
|
||||
use bd2::proto::proto_net::BalanceVersionCheckRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::balance_version_check;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[put("BalanceVersionCheck")]
|
||||
async fn balance_version_check_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
let req =
|
||||
parse_packet::<BalanceVersionCheckRequest>("BalanceVersionCheck", &body).map_err(|e| {
|
||||
tracing::warn!("Failed to parse BalanceVersionCheck: {}", e);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
let response = balance_version_check::handle(req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
20
httpserver/src/routes/game/battle_end.rs
Normal file
20
httpserver/src/routes/game/battle_end.rs
Normal file
@@ -0,0 +1,20 @@
|
||||
use actix_web::{put, web, HttpResponse, Result};
|
||||
use bd2::proto::proto_net::BattleEndRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::battle_end;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[put("BattleEnd")]
|
||||
async fn battle_end_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
let req = parse_packet::<BattleEndRequest>("BattleEnd", &body).map_err(|e| {
|
||||
tracing::warn!("Failed to parse BattleEnd: {}", e);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
let response = battle_end::handle(&pool, uid, req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
20
httpserver/src/routes/game/battle_end_test.rs
Normal file
20
httpserver/src/routes/game/battle_end_test.rs
Normal file
@@ -0,0 +1,20 @@
|
||||
use actix_web::{put, web, HttpResponse, Result};
|
||||
use bd2::proto::proto_net::BattleEndTestRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::battle_end_test;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[put("BattleEndTest")]
|
||||
async fn battle_end_test_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
let req = parse_packet::<BattleEndTestRequest>("BattleEndTest", &body).map_err(|e| {
|
||||
tracing::warn!("Failed to parse BattleEndTest: {}", e);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
let response = battle_end_test::handle(&pool, uid, req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
20
httpserver/src/routes/game/battle_enter.rs
Normal file
20
httpserver/src/routes/game/battle_enter.rs
Normal file
@@ -0,0 +1,20 @@
|
||||
use actix_web::{put, web, HttpResponse, Result};
|
||||
use bd2::proto::proto_net::BattleEnterRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::battle_enter;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[put("BattleEnter")]
|
||||
async fn battle_enter_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
let req = parse_packet::<BattleEnterRequest>("BattleEnter", &body).map_err(|e| {
|
||||
tracing::warn!("Failed to parse BattleEnter: {}", e);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
let response = battle_enter::handle(&pool, uid, req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
20
httpserver/src/routes/game/battle_exit.rs
Normal file
20
httpserver/src/routes/game/battle_exit.rs
Normal file
@@ -0,0 +1,20 @@
|
||||
use actix_web::{put, web, HttpResponse, Result};
|
||||
use bd2::proto::proto_net::BattleExitRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::battle_exit;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[put("BattleExit")]
|
||||
async fn battle_exit_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
let req = parse_packet::<BattleExitRequest>("BattleExit", &body).map_err(|e| {
|
||||
tracing::warn!("Failed to parse BattleExit: {}", e);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
let response = battle_exit::handle(&pool, uid, req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
20
httpserver/src/routes/game/battle_give_up.rs
Normal file
20
httpserver/src/routes/game/battle_give_up.rs
Normal file
@@ -0,0 +1,20 @@
|
||||
use actix_web::{put, web, HttpResponse, Result};
|
||||
use bd2::proto::proto_net::BattleGiveUpRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::battle_give_up;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[put("BattleGiveUp")]
|
||||
async fn battle_give_up_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
let req = parse_packet::<BattleGiveUpRequest>("BattleGiveUp", &body).map_err(|e| {
|
||||
tracing::warn!("Failed to parse BattleGiveUp: {}", e);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
let response = battle_give_up::handle(&pool, uid, req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
20
httpserver/src/routes/game/battle_retry.rs
Normal file
20
httpserver/src/routes/game/battle_retry.rs
Normal file
@@ -0,0 +1,20 @@
|
||||
use actix_web::{put, web, HttpResponse, Result};
|
||||
use bd2::proto::proto_net::BattleRetryRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::battle_retry;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[put("BattleRetry")]
|
||||
async fn battle_retry_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
let req = parse_packet::<BattleRetryRequest>("BattleRetry", &body).map_err(|e| {
|
||||
tracing::warn!("Failed to parse BattleRetry: {}", e);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
let response = battle_retry::handle(&pool, uid, req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
21
httpserver/src/routes/game/battle_retry_previous_turn.rs
Normal file
21
httpserver/src/routes/game/battle_retry_previous_turn.rs
Normal file
@@ -0,0 +1,21 @@
|
||||
use actix_web::{put, web, HttpResponse, Result};
|
||||
use bd2::proto::proto_net::BattleRetryPreviousTurnRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::battle_retry_previous_turn;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[put("BattleRetryPreviousTurn")]
|
||||
async fn battle_retry_previous_turn_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
let req = parse_packet::<BattleRetryPreviousTurnRequest>("BattleRetryPreviousTurn", &body)
|
||||
.map_err(|e| {
|
||||
tracing::warn!("Failed to parse BattleRetryPreviousTurn: {}", e);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
let response = battle_retry_previous_turn::handle(&pool, uid, req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
20
httpserver/src/routes/game/battle_start.rs
Normal file
20
httpserver/src/routes/game/battle_start.rs
Normal file
@@ -0,0 +1,20 @@
|
||||
use actix_web::{put, web, HttpResponse, Result};
|
||||
use bd2::proto::proto_net::BattleStartRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::battle_start;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[put("BattleStart")]
|
||||
async fn battle_start_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
let req = parse_packet::<BattleStartRequest>("BattleStart", &body).map_err(|e| {
|
||||
tracing::warn!("Failed to parse BattleStart: {}", e);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
let response = battle_start::handle(&pool, uid, req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
21
httpserver/src/routes/game/battle_verify_state.rs
Normal file
21
httpserver/src/routes/game/battle_verify_state.rs
Normal file
@@ -0,0 +1,21 @@
|
||||
use actix_web::{put, web, HttpResponse, Result};
|
||||
use bd2::proto::proto_net::BattleVerifyStateRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::battle_verify_state;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[put("BattleVerifyState")]
|
||||
async fn battle_verify_state_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
let req =
|
||||
parse_packet::<BattleVerifyStateRequest>("BattleVerifyState", &body).map_err(|e| {
|
||||
tracing::warn!("Failed to parse BattleVerifyState: {}", e);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
let response = battle_verify_state::handle(&pool, uid, req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
21
httpserver/src/routes/game/cafeteria_cumulative_reward.rs
Normal file
21
httpserver/src/routes/game/cafeteria_cumulative_reward.rs
Normal file
@@ -0,0 +1,21 @@
|
||||
use actix_web::{put, web, HttpResponse, Result};
|
||||
use bd2::proto::proto_net::CafeteriaCumulativeRewardRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::cafeteria_cumulative_reward;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[put("CafeteriaCumulativeReward")]
|
||||
async fn cafeteria_cumulative_reward_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
let req = parse_packet::<CafeteriaCumulativeRewardRequest>("CafeteriaCumulativeReward", &body)
|
||||
.map_err(|e| {
|
||||
tracing::warn!("Failed to parse CafeteriaCumulativeReward: {}", e);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
let response = cafeteria_cumulative_reward::handle(&pool, uid, req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
use actix_web::{put, web, HttpResponse, Result};
|
||||
use bd2::proto::proto_net::CafeteriaDailyConnectionCostumeRefreshRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::cafeteria_daily_connection_costume_refresh;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[put("CafeteriaDailyConnectionCostumeRefresh")]
|
||||
async fn cafeteria_daily_connection_costume_refresh_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
let req = parse_packet::<CafeteriaDailyConnectionCostumeRefreshRequest>(
|
||||
"CafeteriaDailyConnectionCostumeRefresh",
|
||||
&body,
|
||||
)
|
||||
.map_err(|e| {
|
||||
tracing::warn!(
|
||||
"Failed to parse CafeteriaDailyConnectionCostumeRefresh: {}",
|
||||
e
|
||||
);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
let response = cafeteria_daily_connection_costume_refresh::handle(&pool, uid, req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
use actix_web::{put, web, HttpResponse, Result};
|
||||
use bd2::proto::proto_net::CafeteriaEventNpcInteractionRewardRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::cafeteria_event_npc_interaction_reward;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[put("CafeteriaEventNpcInteractionReward")]
|
||||
async fn cafeteria_event_npc_interaction_reward_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
let req = parse_packet::<CafeteriaEventNpcInteractionRewardRequest>(
|
||||
"CafeteriaEventNpcInteractionReward",
|
||||
&body,
|
||||
)
|
||||
.map_err(|e| {
|
||||
tracing::warn!("Failed to parse CafeteriaEventNpcInteractionReward: {}", e);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
let response = cafeteria_event_npc_interaction_reward::handle(&pool, uid, req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
20
httpserver/src/routes/game/cafeteria_info.rs
Normal file
20
httpserver/src/routes/game/cafeteria_info.rs
Normal file
@@ -0,0 +1,20 @@
|
||||
use actix_web::{put, web, HttpResponse, Result};
|
||||
use bd2::proto::proto_net::CafeteriaInfoRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::cafeteria_info;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[put("CafeteriaInfo")]
|
||||
async fn cafeteria_info_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
let req = parse_packet::<CafeteriaInfoRequest>("CafeteriaInfo", &body).map_err(|e| {
|
||||
tracing::warn!("Failed to parse CafeteriaInfo: {}", e);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
let response = cafeteria_info::handle(&pool, uid, req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
use actix_web::{put, web, HttpResponse, Result};
|
||||
use bd2::proto::proto_net::CafeteriaIntroductionStoryRewardRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::cafeteria_introduction_story_reward;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[put("CafeteriaIntroductionStoryReward")]
|
||||
async fn cafeteria_introduction_story_reward_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
let req = parse_packet::<CafeteriaIntroductionStoryRewardRequest>(
|
||||
"CafeteriaIntroductionStoryReward",
|
||||
&body,
|
||||
)
|
||||
.map_err(|e| {
|
||||
tracing::warn!("Failed to parse CafeteriaIntroductionStoryReward: {}", e);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
let response = cafeteria_introduction_story_reward::handle(&pool, uid, req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
20
httpserver/src/routes/game/cafeteria_level_up.rs
Normal file
20
httpserver/src/routes/game/cafeteria_level_up.rs
Normal file
@@ -0,0 +1,20 @@
|
||||
use actix_web::{put, web, HttpResponse, Result};
|
||||
use bd2::proto::proto_net::CafeteriaLevelUpRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::cafeteria_level_up;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[put("CafeteriaLevelUp")]
|
||||
async fn cafeteria_level_up_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
let req = parse_packet::<CafeteriaLevelUpRequest>("CafeteriaLevelUp", &body).map_err(|e| {
|
||||
tracing::warn!("Failed to parse CafeteriaLevelUp: {}", e);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
let response = cafeteria_level_up::handle(&pool, uid, req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
21
httpserver/src/routes/game/cafeteria_manage_item_add.rs
Normal file
21
httpserver/src/routes/game/cafeteria_manage_item_add.rs
Normal file
@@ -0,0 +1,21 @@
|
||||
use actix_web::{put, web, HttpResponse, Result};
|
||||
use bd2::proto::proto_net::CafeteriaManageItemAddRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::cafeteria_manage_item_add;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[put("CafeteriaManageItemAdd")]
|
||||
async fn cafeteria_manage_item_add_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
let req = parse_packet::<CafeteriaManageItemAddRequest>("CafeteriaManageItemAdd", &body)
|
||||
.map_err(|e| {
|
||||
tracing::warn!("Failed to parse CafeteriaManageItemAdd: {}", e);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
let response = cafeteria_manage_item_add::handle(&pool, uid, req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
use actix_web::{put, web, HttpResponse, Result};
|
||||
use bd2::proto::proto_net::CafeteriaRareNpcInteractionRewardRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::cafeteria_rare_npc_interaction_reward;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[put("CafeteriaRareNpcInteractionReward")]
|
||||
async fn cafeteria_rare_npc_interaction_reward_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
let req = parse_packet::<CafeteriaRareNpcInteractionRewardRequest>(
|
||||
"CafeteriaRareNpcInteractionReward",
|
||||
&body,
|
||||
)
|
||||
.map_err(|e| {
|
||||
tracing::warn!("Failed to parse CafeteriaRareNpcInteractionReward: {}", e);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
let response = cafeteria_rare_npc_interaction_reward::handle(&pool, uid, req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
use actix_web::{put, web, HttpResponse, Result};
|
||||
use bd2::proto::proto_net::CafeteriaRegularCostumeInteractionAllRewardRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::cafeteria_regular_costume_interaction_all_reward;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[put("CafeteriaRegularCostumeInteractionAllReward")]
|
||||
async fn cafeteria_regular_costume_interaction_all_reward_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
let req = parse_packet::<CafeteriaRegularCostumeInteractionAllRewardRequest>(
|
||||
"CafeteriaRegularCostumeInteractionAllReward",
|
||||
&body,
|
||||
)
|
||||
.map_err(|e| {
|
||||
tracing::warn!(
|
||||
"Failed to parse CafeteriaRegularCostumeInteractionAllReward: {}",
|
||||
e
|
||||
);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
let response = cafeteria_regular_costume_interaction_all_reward::handle(&pool, uid, req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
use actix_web::{put, web, HttpResponse, Result};
|
||||
use bd2::proto::proto_net::CafeteriaRegularCostumeInteractionRewardRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::cafeteria_regular_costume_interaction_reward;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[put("CafeteriaRegularCostumeInteractionReward")]
|
||||
async fn cafeteria_regular_costume_interaction_reward_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
let req = parse_packet::<CafeteriaRegularCostumeInteractionRewardRequest>(
|
||||
"CafeteriaRegularCostumeInteractionReward",
|
||||
&body,
|
||||
)
|
||||
.map_err(|e| {
|
||||
tracing::warn!(
|
||||
"Failed to parse CafeteriaRegularCostumeInteractionReward: {}",
|
||||
e
|
||||
);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
let response = cafeteria_regular_costume_interaction_reward::handle(&pool, uid, req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
use actix_web::{put, web, HttpResponse, Result};
|
||||
use bd2::proto::proto_net::CafeteriaRegularCostumeNoteAllRewardRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::cafeteria_regular_costume_note_all_reward;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[put("CafeteriaRegularCostumeNoteAllReward")]
|
||||
async fn cafeteria_regular_costume_note_all_reward_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
let req = parse_packet::<CafeteriaRegularCostumeNoteAllRewardRequest>(
|
||||
"CafeteriaRegularCostumeNoteAllReward",
|
||||
&body,
|
||||
)
|
||||
.map_err(|e| {
|
||||
tracing::warn!(
|
||||
"Failed to parse CafeteriaRegularCostumeNoteAllReward: {}",
|
||||
e
|
||||
);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
let response = cafeteria_regular_costume_note_all_reward::handle(&pool, uid, req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
use actix_web::{put, web, HttpResponse, Result};
|
||||
use bd2::proto::proto_net::CafeteriaRegularCostumeNoteInfoRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::cafeteria_regular_costume_note_info;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[put("CafeteriaRegularCostumeNoteInfo")]
|
||||
async fn cafeteria_regular_costume_note_info_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
let req = parse_packet::<CafeteriaRegularCostumeNoteInfoRequest>(
|
||||
"CafeteriaRegularCostumeNoteInfo",
|
||||
&body,
|
||||
)
|
||||
.map_err(|e| {
|
||||
tracing::warn!("Failed to parse CafeteriaRegularCostumeNoteInfo: {}", e);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
let response = cafeteria_regular_costume_note_info::handle(&pool, uid, req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
use actix_web::{put, web, HttpResponse, Result};
|
||||
use bd2::proto::proto_net::CafeteriaRegularCostumeNoteRewardRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::cafeteria_regular_costume_note_reward;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[put("CafeteriaRegularCostumeNoteReward")]
|
||||
async fn cafeteria_regular_costume_note_reward_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
let req = parse_packet::<CafeteriaRegularCostumeNoteRewardRequest>(
|
||||
"CafeteriaRegularCostumeNoteReward",
|
||||
&body,
|
||||
)
|
||||
.map_err(|e| {
|
||||
tracing::warn!("Failed to parse CafeteriaRegularCostumeNoteReward: {}", e);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
let response = cafeteria_regular_costume_note_reward::handle(&pool, uid, req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
use actix_web::{put, web, HttpResponse, Result};
|
||||
use bd2::proto::proto_net::CafeteriaRewardReceiptTimeUpdateUsingCheatRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::cafeteria_reward_receipt_time_update_using_cheat;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[put("CafeteriaRewardReceiptTimeUpdateUsingCheat")]
|
||||
async fn cafeteria_reward_receipt_time_update_using_cheat_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
let req = parse_packet::<CafeteriaRewardReceiptTimeUpdateUsingCheatRequest>(
|
||||
"CafeteriaRewardReceiptTimeUpdateUsingCheat",
|
||||
&body,
|
||||
)
|
||||
.map_err(|e| {
|
||||
tracing::warn!(
|
||||
"Failed to parse CafeteriaRewardReceiptTimeUpdateUsingCheat: {}",
|
||||
e
|
||||
);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
let response = cafeteria_reward_receipt_time_update_using_cheat::handle(&pool, uid, req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
21
httpserver/src/routes/game/cafeteria_spawn_reset.rs
Normal file
21
httpserver/src/routes/game/cafeteria_spawn_reset.rs
Normal file
@@ -0,0 +1,21 @@
|
||||
use actix_web::{put, web, HttpResponse, Result};
|
||||
use bd2::proto::proto_net::CafeteriaSpawnResetRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::cafeteria_spawn_reset;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[put("CafeteriaSpawnReset")]
|
||||
async fn cafeteria_spawn_reset_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
let req =
|
||||
parse_packet::<CafeteriaSpawnResetRequest>("CafeteriaSpawnReset", &body).map_err(|e| {
|
||||
tracing::warn!("Failed to parse CafeteriaSpawnReset: {}", e);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
let response = cafeteria_spawn_reset::handle(&pool, uid, req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
21
httpserver/src/routes/game/cafeteria_spawn_reset_cheat.rs
Normal file
21
httpserver/src/routes/game/cafeteria_spawn_reset_cheat.rs
Normal file
@@ -0,0 +1,21 @@
|
||||
use actix_web::{put, web, HttpResponse, Result};
|
||||
use bd2::proto::proto_net::CafeteriaSpawnResetCheatRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::cafeteria_spawn_reset_cheat;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[put("CafeteriaSpawnResetCheat")]
|
||||
async fn cafeteria_spawn_reset_cheat_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
let req = parse_packet::<CafeteriaSpawnResetCheatRequest>("CafeteriaSpawnResetCheat", &body)
|
||||
.map_err(|e| {
|
||||
tracing::warn!("Failed to parse CafeteriaSpawnResetCheat: {}", e);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
let response = cafeteria_spawn_reset_cheat::handle(&pool, uid, req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
20
httpserver/src/routes/game/cancel_leave_user.rs
Normal file
20
httpserver/src/routes/game/cancel_leave_user.rs
Normal file
@@ -0,0 +1,20 @@
|
||||
use actix_web::{put, web, HttpResponse, Result};
|
||||
use bd2::proto::proto_net::CancelLeaveUserRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::cancel_leave_user;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[put("CancelLeaveUser")]
|
||||
async fn cancel_leave_user_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
let req = parse_packet::<CancelLeaveUserRequest>("CancelLeaveUser", &body).map_err(|e| {
|
||||
tracing::warn!("Failed to parse CancelLeaveUser: {}", e);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
let response = cancel_leave_user::handle(&pool, uid, req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
20
httpserver/src/routes/game/cash_mail_info.rs
Normal file
20
httpserver/src/routes/game/cash_mail_info.rs
Normal file
@@ -0,0 +1,20 @@
|
||||
use actix_web::{put, web, HttpResponse, Result};
|
||||
use bd2::proto::proto_net::CashMailInfoRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::cash_mail_info;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[put("CashMailInfo")]
|
||||
async fn cash_mail_info_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
let req = parse_packet::<CashMailInfoRequest>("CashMailInfo", &body).map_err(|e| {
|
||||
tracing::warn!("Failed to parse CashMailInfo: {}", e);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
let response = cash_mail_info::handle(&pool, uid, req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
20
httpserver/src/routes/game/cash_shop_buy.rs
Normal file
20
httpserver/src/routes/game/cash_shop_buy.rs
Normal file
@@ -0,0 +1,20 @@
|
||||
use actix_web::{put, web, HttpResponse, Result};
|
||||
use bd2::proto::proto_net::CashShopBuyRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::cash_shop_buy;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[put("CashShopBuy")]
|
||||
async fn cash_shop_buy_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
let req = parse_packet::<CashShopBuyRequest>("CashShopBuy", &body).map_err(|e| {
|
||||
tracing::warn!("Failed to parse CashShopBuy: {}", e);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
let response = cash_shop_buy::handle(&pool, uid, req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
20
httpserver/src/routes/game/cash_shop_info.rs
Normal file
20
httpserver/src/routes/game/cash_shop_info.rs
Normal file
@@ -0,0 +1,20 @@
|
||||
use actix_web::{put, web, HttpResponse, Result};
|
||||
use bd2::proto::proto_net::CashShopInfoRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::cash_shop_info;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[put("CashShopInfo")]
|
||||
async fn cash_shop_info_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
let req = parse_packet::<CashShopInfoRequest>("CashShopInfo", &body).map_err(|e| {
|
||||
tracing::warn!("Failed to parse CashShopInfo: {}", e);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
let response = cash_shop_info::handle(&pool, uid, req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
21
httpserver/src/routes/game/cash_shop_purchase_count_info.rs
Normal file
21
httpserver/src/routes/game/cash_shop_purchase_count_info.rs
Normal file
@@ -0,0 +1,21 @@
|
||||
use actix_web::{put, web, HttpResponse, Result};
|
||||
use bd2::proto::proto_net::CashShopPurchaseCountInfoRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::cash_shop_purchase_count_info;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[put("CashShopPurchaseCountInfo")]
|
||||
async fn cash_shop_purchase_count_info_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
let req = parse_packet::<CashShopPurchaseCountInfoRequest>("CashShopPurchaseCountInfo", &body)
|
||||
.map_err(|e| {
|
||||
tracing::warn!("Failed to parse CashShopPurchaseCountInfo: {}", e);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
let response = cash_shop_purchase_count_info::handle(&pool, uid, req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
20
httpserver/src/routes/game/char_all_revival.rs
Normal file
20
httpserver/src/routes/game/char_all_revival.rs
Normal file
@@ -0,0 +1,20 @@
|
||||
use actix_web::{put, web, HttpResponse, Result};
|
||||
use bd2::proto::proto_net::CharAllRevivalRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::char_all_revival;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[put("CharAllRevival")]
|
||||
async fn char_all_revival_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
let req = parse_packet::<CharAllRevivalRequest>("CharAllRevival", &body).map_err(|e| {
|
||||
tracing::warn!("Failed to parse CharAllRevival: {}", e);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
let response = char_all_revival::handle(&pool, uid, req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
21
httpserver/src/routes/game/char_auto_revive_set.rs
Normal file
21
httpserver/src/routes/game/char_auto_revive_set.rs
Normal file
@@ -0,0 +1,21 @@
|
||||
use actix_web::{put, web, HttpResponse, Result};
|
||||
use bd2::proto::proto_net::CharAutoReviveSetRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::char_auto_revive_set;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[put("CharAutoReviveSet")]
|
||||
async fn char_auto_revive_set_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
let req =
|
||||
parse_packet::<CharAutoReviveSetRequest>("CharAutoReviveSet", &body).map_err(|e| {
|
||||
tracing::warn!("Failed to parse CharAutoReviveSet: {}", e);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
let response = char_auto_revive_set::handle(&pool, uid, req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
20
httpserver/src/routes/game/char_awake_active.rs
Normal file
20
httpserver/src/routes/game/char_awake_active.rs
Normal file
@@ -0,0 +1,20 @@
|
||||
use actix_web::{put, web, HttpResponse, Result};
|
||||
use bd2::proto::proto_net::CharAwakeActiveRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::char_awake_active;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[put("CharAwakeActive")]
|
||||
async fn char_awake_active_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
let req = parse_packet::<CharAwakeActiveRequest>("CharAwakeActive", &body).map_err(|e| {
|
||||
tracing::warn!("Failed to parse CharAwakeActive: {}", e);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
let response = char_awake_active::handle(&pool, uid, req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
20
httpserver/src/routes/game/char_awake_info.rs
Normal file
20
httpserver/src/routes/game/char_awake_info.rs
Normal file
@@ -0,0 +1,20 @@
|
||||
use actix_web::{put, web, HttpResponse, Result};
|
||||
use bd2::proto::proto_net::CharAwakeInfoRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::char_awake_info;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[put("CharAwakeInfo")]
|
||||
async fn char_awake_info_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
let req = parse_packet::<CharAwakeInfoRequest>("CharAwakeInfo", &body).map_err(|e| {
|
||||
tracing::warn!("Failed to parse CharAwakeInfo: {}", e);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
let response = char_awake_info::handle(&pool, uid, req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
20
httpserver/src/routes/game/char_class_up.rs
Normal file
20
httpserver/src/routes/game/char_class_up.rs
Normal file
@@ -0,0 +1,20 @@
|
||||
use actix_web::{put, web, HttpResponse, Result};
|
||||
use bd2::proto::proto_net::CharClassUpRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::char_class_up;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[put("CharClassUp")]
|
||||
async fn char_class_up_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
let req = parse_packet::<CharClassUpRequest>("CharClassUp", &body).map_err(|e| {
|
||||
tracing::warn!("Failed to parse CharClassUp: {}", e);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
let response = char_class_up::handle(&pool, uid, req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
20
httpserver/src/routes/game/char_expiry.rs
Normal file
20
httpserver/src/routes/game/char_expiry.rs
Normal file
@@ -0,0 +1,20 @@
|
||||
use actix_web::{put, web, HttpResponse, Result};
|
||||
use bd2::proto::proto_net::CharExpiryRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::char_expiry;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[put("CharExpiry")]
|
||||
async fn char_expiry_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
let req = parse_packet::<CharExpiryRequest>("CharExpiry", &body).map_err(|e| {
|
||||
tracing::warn!("Failed to parse CharExpiry: {}", e);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
let response = char_expiry::handle(&pool, uid, req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
20
httpserver/src/routes/game/char_growth.rs
Normal file
20
httpserver/src/routes/game/char_growth.rs
Normal file
@@ -0,0 +1,20 @@
|
||||
use actix_web::{put, web, HttpResponse, Result};
|
||||
use bd2::proto::proto_net::CharGrowthRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::char_growth;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[put("CharGrowth")]
|
||||
async fn char_growth_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
let req = parse_packet::<CharGrowthRequest>("CharGrowth", &body).map_err(|e| {
|
||||
tracing::warn!("Failed to parse CharGrowth: {}", e);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
let response = char_growth::handle(&pool, uid, req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
20
httpserver/src/routes/game/char_healing.rs
Normal file
20
httpserver/src/routes/game/char_healing.rs
Normal file
@@ -0,0 +1,20 @@
|
||||
use actix_web::{put, web, HttpResponse, Result};
|
||||
use bd2::proto::proto_net::CharHealingRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::char_healing;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[put("CharHealing")]
|
||||
async fn char_healing_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
let req = parse_packet::<CharHealingRequest>("CharHealing", &body).map_err(|e| {
|
||||
tracing::warn!("Failed to parse CharHealing: {}", e);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
let response = char_healing::handle(&pool, uid, req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
20
httpserver/src/routes/game/char_immortal.rs
Normal file
20
httpserver/src/routes/game/char_immortal.rs
Normal file
@@ -0,0 +1,20 @@
|
||||
use actix_web::{put, web, HttpResponse, Result};
|
||||
use bd2::proto::proto_net::CharImmortalRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::char_immortal;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[put("CharImmortal")]
|
||||
async fn char_immortal_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
let req = parse_packet::<CharImmortalRequest>("CharImmortal", &body).map_err(|e| {
|
||||
tracing::warn!("Failed to parse CharImmortal: {}", e);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
let response = char_immortal::handle(&pool, uid, req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
21
httpserver/src/routes/game/char_imprint_level_up.rs
Normal file
21
httpserver/src/routes/game/char_imprint_level_up.rs
Normal file
@@ -0,0 +1,21 @@
|
||||
use actix_web::{put, web, HttpResponse, Result};
|
||||
use bd2::proto::proto_net::CharImprintLevelUpRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::char_imprint_level_up;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[put("CharImprintLevelUp")]
|
||||
async fn char_imprint_level_up_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
let req =
|
||||
parse_packet::<CharImprintLevelUpRequest>("CharImprintLevelUp", &body).map_err(|e| {
|
||||
tracing::warn!("Failed to parse CharImprintLevelUp: {}", e);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
let response = char_imprint_level_up::handle(&pool, uid, req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
20
httpserver/src/routes/game/char_info.rs
Normal file
20
httpserver/src/routes/game/char_info.rs
Normal file
@@ -0,0 +1,20 @@
|
||||
use actix_web::{put, web, HttpResponse, Result};
|
||||
use bd2::proto::proto_net::CharInfoRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::char_info;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[put("CharInfo")]
|
||||
async fn char_info_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
let req = parse_packet::<CharInfoRequest>("CharInfo", &body).map_err(|e| {
|
||||
tracing::warn!("Failed to parse CharInfo: {}", e);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
let response = char_info::handle(&pool, uid, req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
20
httpserver/src/routes/game/char_level_up.rs
Normal file
20
httpserver/src/routes/game/char_level_up.rs
Normal file
@@ -0,0 +1,20 @@
|
||||
use actix_web::{put, web, HttpResponse, Result};
|
||||
use bd2::proto::proto_net::CharLevelUpRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::char_level_up;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[put("CharLevelUp")]
|
||||
async fn char_level_up_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
let req = parse_packet::<CharLevelUpRequest>("CharLevelUp", &body).map_err(|e| {
|
||||
tracing::warn!("Failed to parse CharLevelUp: {}", e);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
let response = char_level_up::handle(&pool, uid, req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
20
httpserver/src/routes/game/char_partner_info.rs
Normal file
20
httpserver/src/routes/game/char_partner_info.rs
Normal file
@@ -0,0 +1,20 @@
|
||||
use actix_web::{put, web, HttpResponse, Result};
|
||||
use bd2::proto::proto_net::CharPartnerInfoRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::char_partner_info;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[put("CharPartnerInfo")]
|
||||
async fn char_partner_info_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
let req = parse_packet::<CharPartnerInfoRequest>("CharPartnerInfo", &body).map_err(|e| {
|
||||
tracing::warn!("Failed to parse CharPartnerInfo: {}", e);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
let response = char_partner_info::handle(&pool, uid, req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
21
httpserver/src/routes/game/char_partner_reward.rs
Normal file
21
httpserver/src/routes/game/char_partner_reward.rs
Normal file
@@ -0,0 +1,21 @@
|
||||
use actix_web::{put, web, HttpResponse, Result};
|
||||
use bd2::proto::proto_net::CharPartnerRewardRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::char_partner_reward;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[put("CharPartnerReward")]
|
||||
async fn char_partner_reward_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
let req =
|
||||
parse_packet::<CharPartnerRewardRequest>("CharPartnerReward", &body).map_err(|e| {
|
||||
tracing::warn!("Failed to parse CharPartnerReward: {}", e);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
let response = char_partner_reward::handle(&pool, uid, req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
21
httpserver/src/routes/game/char_partner_story_reward.rs
Normal file
21
httpserver/src/routes/game/char_partner_story_reward.rs
Normal file
@@ -0,0 +1,21 @@
|
||||
use actix_web::{put, web, HttpResponse, Result};
|
||||
use bd2::proto::proto_net::CharPartnerStoryRewardRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::char_partner_story_reward;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[put("CharPartnerStoryReward")]
|
||||
async fn char_partner_story_reward_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
let req = parse_packet::<CharPartnerStoryRewardRequest>("CharPartnerStoryReward", &body)
|
||||
.map_err(|e| {
|
||||
tracing::warn!("Failed to parse CharPartnerStoryReward: {}", e);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
let response = char_partner_story_reward::handle(&pool, uid, req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
20
httpserver/src/routes/game/char_scout_info.rs
Normal file
20
httpserver/src/routes/game/char_scout_info.rs
Normal file
@@ -0,0 +1,20 @@
|
||||
use actix_web::{put, web, HttpResponse, Result};
|
||||
use bd2::proto::proto_net::CharScoutInfoRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::char_scout_info;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[put("CharScoutInfo")]
|
||||
async fn char_scout_info_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
let req = parse_packet::<CharScoutInfoRequest>("CharScoutInfo", &body).map_err(|e| {
|
||||
tracing::warn!("Failed to parse CharScoutInfo: {}", e);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
let response = char_scout_info::handle(&pool, uid, req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
21
httpserver/src/routes/game/char_special_scout_buy.rs
Normal file
21
httpserver/src/routes/game/char_special_scout_buy.rs
Normal file
@@ -0,0 +1,21 @@
|
||||
use actix_web::{put, web, HttpResponse, Result};
|
||||
use bd2::proto::proto_net::CharSpecialScoutBuyRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::char_special_scout_buy;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[put("CharSpecialScoutBuy")]
|
||||
async fn char_special_scout_buy_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
let req =
|
||||
parse_packet::<CharSpecialScoutBuyRequest>("CharSpecialScoutBuy", &body).map_err(|e| {
|
||||
tracing::warn!("Failed to parse CharSpecialScoutBuy: {}", e);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
let response = char_special_scout_buy::handle(&pool, uid, req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
21
httpserver/src/routes/game/char_special_scout_reset.rs
Normal file
21
httpserver/src/routes/game/char_special_scout_reset.rs
Normal file
@@ -0,0 +1,21 @@
|
||||
use actix_web::{put, web, HttpResponse, Result};
|
||||
use bd2::proto::proto_net::CharSpecialScoutResetRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::char_special_scout_reset;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[put("CharSpecialScoutReset")]
|
||||
async fn char_special_scout_reset_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
let req = parse_packet::<CharSpecialScoutResetRequest>("CharSpecialScoutReset", &body)
|
||||
.map_err(|e| {
|
||||
tracing::warn!("Failed to parse CharSpecialScoutReset: {}", e);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
let response = char_special_scout_reset::handle(&pool, uid, req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
23
httpserver/src/routes/game/charge_cost_info.rs
Normal file
23
httpserver/src/routes/game/charge_cost_info.rs
Normal file
@@ -0,0 +1,23 @@
|
||||
use actix_web::{put, web, HttpResponse, Result};
|
||||
use bd2::proto::proto_net::ChargeCostInfoRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::charge_cost_info;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[put("ChargeCostInfo")]
|
||||
async fn charge_cost_info_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
|
||||
let req = parse_packet::<ChargeCostInfoRequest>("ChargeCostInfo", &body).map_err(|e| {
|
||||
tracing::warn!("Failed to parse ChargeCostInfo: {}", e);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
|
||||
let response = charge_cost_info::handle(&pool, uid, req).await;
|
||||
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
21
httpserver/src/routes/game/clear_package_reward.rs
Normal file
21
httpserver/src/routes/game/clear_package_reward.rs
Normal file
@@ -0,0 +1,21 @@
|
||||
use actix_web::{put, web, HttpResponse, Result};
|
||||
use bd2::proto::proto_net::ClearPackageRewardRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::clear_package_reward;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[put("ClearPackageReward")]
|
||||
async fn clear_package_reward_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
let req =
|
||||
parse_packet::<ClearPackageRewardRequest>("ClearPackageReward", &body).map_err(|e| {
|
||||
tracing::warn!("Failed to parse ClearPackageReward: {}", e);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
let response = clear_package_reward::handle(&pool, uid, req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
20
httpserver/src/routes/game/client_custom_log.rs
Normal file
20
httpserver/src/routes/game/client_custom_log.rs
Normal file
@@ -0,0 +1,20 @@
|
||||
use actix_web::{put, web, HttpResponse, Result};
|
||||
use bd2::proto::proto_net::ClientCustomLogRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::client_custom_log;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[put("ClientCustomLog")]
|
||||
async fn client_custom_log_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
let req = parse_packet::<ClientCustomLogRequest>("ClientCustomLog", &body).map_err(|e| {
|
||||
tracing::warn!("Failed to parse ClientCustomLog: {}", e);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
let response = client_custom_log::handle(&pool, uid, req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
20
httpserver/src/routes/game/community_reward.rs
Normal file
20
httpserver/src/routes/game/community_reward.rs
Normal file
@@ -0,0 +1,20 @@
|
||||
use actix_web::{put, web, HttpResponse, Result};
|
||||
use bd2::proto::proto_net::CommunityRewardRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::community_reward;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[put("CommunityReward")]
|
||||
async fn community_reward_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
let req = parse_packet::<CommunityRewardRequest>("CommunityReward", &body).map_err(|e| {
|
||||
tracing::warn!("Failed to parse CommunityReward: {}", e);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
let response = community_reward::handle(&pool, uid, req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
21
httpserver/src/routes/game/community_reward_info.rs
Normal file
21
httpserver/src/routes/game/community_reward_info.rs
Normal file
@@ -0,0 +1,21 @@
|
||||
use actix_web::{put, web, HttpResponse, Result};
|
||||
use bd2::proto::proto_net::CommunityRewardInfoRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::community_reward_info;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[put("CommunityRewardInfo")]
|
||||
async fn community_reward_info_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
let req =
|
||||
parse_packet::<CommunityRewardInfoRequest>("CommunityRewardInfo", &body).map_err(|e| {
|
||||
tracing::warn!("Failed to parse CommunityRewardInfo: {}", e);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
let response = community_reward_info::handle(&pool, uid, req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
20
httpserver/src/routes/game/cooking.rs
Normal file
20
httpserver/src/routes/game/cooking.rs
Normal file
@@ -0,0 +1,20 @@
|
||||
use actix_web::{put, web, HttpResponse, Result};
|
||||
use bd2::proto::proto_net::CookingRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::cooking;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[put("Cooking")]
|
||||
async fn cooking_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
let req = parse_packet::<CookingRequest>("Cooking", &body).map_err(|e| {
|
||||
tracing::warn!("Failed to parse Cooking: {}", e);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
let response = cooking::handle(&pool, uid, req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
20
httpserver/src/routes/game/cooking_research.rs
Normal file
20
httpserver/src/routes/game/cooking_research.rs
Normal file
@@ -0,0 +1,20 @@
|
||||
use actix_web::{put, web, HttpResponse, Result};
|
||||
use bd2::proto::proto_net::CookingResearchRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::cooking_research;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[put("CookingResearch")]
|
||||
async fn cooking_research_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
let req = parse_packet::<CookingResearchRequest>("CookingResearch", &body).map_err(|e| {
|
||||
tracing::warn!("Failed to parse CookingResearch: {}", e);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
let response = cooking_research::handle(&pool, uid, req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
21
httpserver/src/routes/game/costume_all_rounder_upgrade.rs
Normal file
21
httpserver/src/routes/game/costume_all_rounder_upgrade.rs
Normal file
@@ -0,0 +1,21 @@
|
||||
use actix_web::{put, web, HttpResponse, Result};
|
||||
use bd2::proto::proto_net::CostumeAllRounderUpgradeRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::costume_all_rounder_upgrade;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[put("CostumeAllRounderUpgrade")]
|
||||
async fn costume_all_rounder_upgrade_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
let req = parse_packet::<CostumeAllRounderUpgradeRequest>("CostumeAllRounderUpgrade", &body)
|
||||
.map_err(|e| {
|
||||
tracing::warn!("Failed to parse CostumeAllRounderUpgrade: {}", e);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
let response = costume_all_rounder_upgrade::handle(&pool, uid, req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
20
httpserver/src/routes/game/costume_clear.rs
Normal file
20
httpserver/src/routes/game/costume_clear.rs
Normal file
@@ -0,0 +1,20 @@
|
||||
use actix_web::{put, web, HttpResponse, Result};
|
||||
use bd2::proto::proto_net::CostumeClearRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::costume_clear;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[put("CostumeClear")]
|
||||
async fn costume_clear_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
let req = parse_packet::<CostumeClearRequest>("CostumeClear", &body).map_err(|e| {
|
||||
tracing::warn!("Failed to parse CostumeClear: {}", e);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
let response = costume_clear::handle(&pool, uid, req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
20
httpserver/src/routes/game/costume_info.rs
Normal file
20
httpserver/src/routes/game/costume_info.rs
Normal file
@@ -0,0 +1,20 @@
|
||||
use actix_web::{put, web, HttpResponse, Result};
|
||||
use bd2::proto::proto_net::CostumeInfoRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::costume_info;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[put("CostumeInfo")]
|
||||
async fn costume_info_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
let req = parse_packet::<CostumeInfoRequest>("CostumeInfo", &body).map_err(|e| {
|
||||
tracing::warn!("Failed to parse CostumeInfo: {}", e);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
let response = costume_info::handle(&pool, uid, req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
21
httpserver/src/routes/game/costume_node_activation.rs
Normal file
21
httpserver/src/routes/game/costume_node_activation.rs
Normal file
@@ -0,0 +1,21 @@
|
||||
use actix_web::{put, web, HttpResponse, Result};
|
||||
use bd2::proto::proto_net::CostumeNodeActivationRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::costume_node_activation;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[put("CostumeNodeActivation")]
|
||||
async fn costume_node_activation_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
let req = parse_packet::<CostumeNodeActivationRequest>("CostumeNodeActivation", &body)
|
||||
.map_err(|e| {
|
||||
tracing::warn!("Failed to parse CostumeNodeActivation: {}", e);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
let response = costume_node_activation::handle(&pool, uid, req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
21
httpserver/src/routes/game/costume_potential_connect.rs
Normal file
21
httpserver/src/routes/game/costume_potential_connect.rs
Normal file
@@ -0,0 +1,21 @@
|
||||
use actix_web::{put, web, HttpResponse, Result};
|
||||
use bd2::proto::proto_net::CostumePotentialConnectRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::costume_potential_connect;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[put("CostumePotentialConnect")]
|
||||
async fn costume_potential_connect_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
let req = parse_packet::<CostumePotentialConnectRequest>("CostumePotentialConnect", &body)
|
||||
.map_err(|e| {
|
||||
tracing::warn!("Failed to parse CostumePotentialConnect: {}", e);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
let response = costume_potential_connect::handle(&pool, uid, req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
20
httpserver/src/routes/game/costume_upgrade.rs
Normal file
20
httpserver/src/routes/game/costume_upgrade.rs
Normal file
@@ -0,0 +1,20 @@
|
||||
use actix_web::{put, web, HttpResponse, Result};
|
||||
use bd2::proto::proto_net::CostumeUpgradeRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::costume_upgrade;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[put("CostumeUpgrade")]
|
||||
async fn costume_upgrade_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
let req = parse_packet::<CostumeUpgradeRequest>("CostumeUpgrade", &body).map_err(|e| {
|
||||
tracing::warn!("Failed to parse CostumeUpgrade: {}", e);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
let response = costume_upgrade::handle(&pool, uid, req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
20
httpserver/src/routes/game/costume_use.rs
Normal file
20
httpserver/src/routes/game/costume_use.rs
Normal file
@@ -0,0 +1,20 @@
|
||||
use actix_web::{put, web, HttpResponse, Result};
|
||||
use bd2::proto::proto_net::CostumeUseRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::costume_use;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[put("CostumeUse")]
|
||||
async fn costume_use_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
let req = parse_packet::<CostumeUseRequest>("CostumeUse", &body).map_err(|e| {
|
||||
tracing::warn!("Failed to parse CostumeUse: {}", e);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
let response = costume_use::handle(&pool, uid, req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
21
httpserver/src/routes/game/dating_episode_clear.rs
Normal file
21
httpserver/src/routes/game/dating_episode_clear.rs
Normal file
@@ -0,0 +1,21 @@
|
||||
use actix_web::{put, web, HttpResponse, Result};
|
||||
use bd2::proto::proto_net::DatingEpisodeClearRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::dating_episode_clear;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[put("DatingEpisodeClear")]
|
||||
async fn dating_episode_clear_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
let req =
|
||||
parse_packet::<DatingEpisodeClearRequest>("DatingEpisodeClear", &body).map_err(|e| {
|
||||
tracing::warn!("Failed to parse DatingEpisodeClear: {}", e);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
let response = dating_episode_clear::handle(&pool, uid, req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
20
httpserver/src/routes/game/dating_info.rs
Normal file
20
httpserver/src/routes/game/dating_info.rs
Normal file
@@ -0,0 +1,20 @@
|
||||
use actix_web::{put, web, HttpResponse, Result};
|
||||
use bd2::proto::proto_net::DatingInfoRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::dating_info;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[put("DatingInfo")]
|
||||
async fn dating_info_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
let req = parse_packet::<DatingInfoRequest>("DatingInfo", &body).map_err(|e| {
|
||||
tracing::warn!("Failed to parse DatingInfo: {}", e);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
let response = dating_info::handle(&pool, uid, req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
21
httpserver/src/routes/game/dating_message_update.rs
Normal file
21
httpserver/src/routes/game/dating_message_update.rs
Normal file
@@ -0,0 +1,21 @@
|
||||
use actix_web::{put, web, HttpResponse, Result};
|
||||
use bd2::proto::proto_net::DatingMessageUpdateRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::dating_message_update;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[put("DatingMessageUpdate")]
|
||||
async fn dating_message_update_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
let req =
|
||||
parse_packet::<DatingMessageUpdateRequest>("DatingMessageUpdate", &body).map_err(|e| {
|
||||
tracing::warn!("Failed to parse DatingMessageUpdate: {}", e);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
let response = dating_message_update::handle(&pool, uid, req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
21
httpserver/src/routes/game/deck_char_auto_revive.rs
Normal file
21
httpserver/src/routes/game/deck_char_auto_revive.rs
Normal file
@@ -0,0 +1,21 @@
|
||||
use actix_web::{put, web, HttpResponse, Result};
|
||||
use bd2::proto::proto_net::DeckCharAutoReviveRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::deck_char_auto_revive;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[put("DeckCharAutoRevive")]
|
||||
async fn deck_char_auto_revive_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
let req =
|
||||
parse_packet::<DeckCharAutoReviveRequest>("DeckCharAutoRevive", &body).map_err(|e| {
|
||||
tracing::warn!("Failed to parse DeckCharAutoRevive: {}", e);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
let response = deck_char_auto_revive::handle(&pool, uid, req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
21
httpserver/src/routes/game/deck_costume_setting_info.rs
Normal file
21
httpserver/src/routes/game/deck_costume_setting_info.rs
Normal file
@@ -0,0 +1,21 @@
|
||||
use actix_web::{put, web, HttpResponse, Result};
|
||||
use bd2::proto::proto_net::DeckCostumeSettingInfoRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::deck_costume_setting_info;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[put("DeckCostumeSettingInfo")]
|
||||
async fn deck_costume_setting_info_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
let req = parse_packet::<DeckCostumeSettingInfoRequest>("DeckCostumeSettingInfo", &body)
|
||||
.map_err(|e| {
|
||||
tracing::warn!("Failed to parse DeckCostumeSettingInfo: {}", e);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
let response = deck_costume_setting_info::handle(&pool, uid, req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
21
httpserver/src/routes/game/deck_costume_setting_save.rs
Normal file
21
httpserver/src/routes/game/deck_costume_setting_save.rs
Normal file
@@ -0,0 +1,21 @@
|
||||
use actix_web::{put, web, HttpResponse, Result};
|
||||
use bd2::proto::proto_net::DeckCostumeSettingSaveRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::deck_costume_setting_save;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[put("DeckCostumeSettingSave")]
|
||||
async fn deck_costume_setting_save_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
let req = parse_packet::<DeckCostumeSettingSaveRequest>("DeckCostumeSettingSave", &body)
|
||||
.map_err(|e| {
|
||||
tracing::warn!("Failed to parse DeckCostumeSettingSave: {}", e);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
let response = deck_costume_setting_save::handle(&pool, uid, req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
20
httpserver/src/routes/game/deck_info.rs
Normal file
20
httpserver/src/routes/game/deck_info.rs
Normal file
@@ -0,0 +1,20 @@
|
||||
use actix_web::{put, web, HttpResponse, Result};
|
||||
use bd2::proto::proto_net::DeckInfoRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::deck_info;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[put("DeckInfo")]
|
||||
async fn deck_info_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
let req = parse_packet::<DeckInfoRequest>("DeckInfo", &body).map_err(|e| {
|
||||
tracing::warn!("Failed to parse DeckInfo: {}", e);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
let response = deck_info::handle(&pool, uid, req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
20
httpserver/src/routes/game/deck_save.rs
Normal file
20
httpserver/src/routes/game/deck_save.rs
Normal file
@@ -0,0 +1,20 @@
|
||||
use actix_web::{put, web, HttpResponse, Result};
|
||||
use bd2::proto::proto_net::DeckSaveRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::deck_save;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[put("DeckSave")]
|
||||
async fn deck_save_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
let req = parse_packet::<DeckSaveRequest>("DeckSave", &body).map_err(|e| {
|
||||
tracing::warn!("Failed to parse DeckSave: {}", e);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
let response = deck_save::handle(&pool, uid, req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
20
httpserver/src/routes/game/dispatch_info.rs
Normal file
20
httpserver/src/routes/game/dispatch_info.rs
Normal file
@@ -0,0 +1,20 @@
|
||||
use actix_web::{put, web, HttpResponse, Result};
|
||||
use bd2::proto::proto_net::DispatchInfoRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::dispatch_info;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[put("DispatchInfo")]
|
||||
async fn dispatch_info_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
let req = parse_packet::<DispatchInfoRequest>("DispatchInfo", &body).map_err(|e| {
|
||||
tracing::warn!("Failed to parse DispatchInfo: {}", e);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
let response = dispatch_info::handle(&pool, uid, req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
20
httpserver/src/routes/game/dispatch_reward.rs
Normal file
20
httpserver/src/routes/game/dispatch_reward.rs
Normal file
@@ -0,0 +1,20 @@
|
||||
use actix_web::{put, web, HttpResponse, Result};
|
||||
use bd2::proto::proto_net::DispatchRewardRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::dispatch_reward;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[put("DispatchReward")]
|
||||
async fn dispatch_reward_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
let req = parse_packet::<DispatchRewardRequest>("DispatchReward", &body).map_err(|e| {
|
||||
tracing::warn!("Failed to parse DispatchReward: {}", e);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
let response = dispatch_reward::handle(&pool, uid, req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
20
httpserver/src/routes/game/eat_food.rs
Normal file
20
httpserver/src/routes/game/eat_food.rs
Normal file
@@ -0,0 +1,20 @@
|
||||
use actix_web::{put, web, HttpResponse, Result};
|
||||
use bd2::proto::proto_net::EatFoodRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::eat_food;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[put("EatFood")]
|
||||
async fn eat_food_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
let req = parse_packet::<EatFoodRequest>("EatFood", &body).map_err(|e| {
|
||||
tracing::warn!("Failed to parse EatFood: {}", e);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
let response = eat_food::handle(&pool, uid, req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
20
httpserver/src/routes/game/eat_food_auto.rs
Normal file
20
httpserver/src/routes/game/eat_food_auto.rs
Normal file
@@ -0,0 +1,20 @@
|
||||
use actix_web::{put, web, HttpResponse, Result};
|
||||
use bd2::proto::proto_net::EatFoodAutoRequest;
|
||||
use crypto::network::parse_packet;
|
||||
use gameserver::logic::game::eat_food_auto;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[put("EatFoodAuto")]
|
||||
async fn eat_food_auto_handler(
|
||||
pool: web::Data<SqlitePool>,
|
||||
body: String,
|
||||
user_id: web::ReqData<i64>,
|
||||
) -> Result<HttpResponse> {
|
||||
let uid = *user_id;
|
||||
let req = parse_packet::<EatFoodAutoRequest>("EatFoodAuto", &body).map_err(|e| {
|
||||
tracing::warn!("Failed to parse EatFoodAuto: {}", e);
|
||||
actix_web::error::ErrorBadRequest("Invalid packet")
|
||||
})?;
|
||||
let response = eat_food_auto::handle(&pool, uid, req).await;
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user