From 76031f956a5940e67fd693a7cdbc8fbf5df681bd Mon Sep 17 00:00:00 2001 From: vben Date: Thu, 1 Oct 2026 18:38:10 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cargo.lock | 1 + Cargo.toml | 1 + src/modules/auth/captcha/model.rs | 25 +++++++++++++++++- src/modules/auth/captcha/router.rs | 41 ++++++++++++++++++++++-------- 4 files changed, 56 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d3f3961..a815432 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4316,6 +4316,7 @@ dependencies = [ "rust-embed", "sea-orm", "serde", + "serde_json", "thiserror 2.0.21", "tokio", "tower-http", diff --git a/Cargo.toml b/Cargo.toml index a2297d9..1010142 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,6 +17,7 @@ tracing = { version = "0.1.41", features = ["async-await"] } tracing-subscriber = { version = "0.3.19", features = ["env-filter", "chrono"] } config = { version = "0.15.11", features = ["yaml"] } serde = { version = "1.0.219", features = ["derive"] } +serde_json = "1.0" anyhow = "1.0.98" sea-orm = { version = "2.0.4", features = ["schema-sync", "entity-registry","with-chrono", "debug-print", "sqlx-postgres","sqlx-mysql", "with-rust_decimal", "runtime-tokio"] } num_cpus = "1.16.0" diff --git a/src/modules/auth/captcha/model.rs b/src/modules/auth/captcha/model.rs index 4cf614e..bedb3e8 100644 --- a/src/modules/auth/captcha/model.rs +++ b/src/modules/auth/captcha/model.rs @@ -33,4 +33,27 @@ pub struct LoginVo { //用户 openid pub openid: String, -} \ No newline at end of file +} + +#[derive(Serialize, Deserialize)] +pub struct UserVo { + pub useid: String, + pub usena: String, + pub nicna: String, + pub usety: Option, + pub orgid: String, + pub orgna: String, + pub tenid: Option, + pub email: Option, + pub monum: String, + pub gender: String, + pub avatar: Option, + pub avtag: Option, + pub loip: Option, + pub lotim: Option, + pub notes: Option, + pub crtim: Option, + pub roids: Option, + pub poids: Option, + pub rolid: Option, +} diff --git a/src/modules/auth/captcha/router.rs b/src/modules/auth/captcha/router.rs index ebc7e23..f90b690 100644 --- a/src/modules/auth/captcha/router.rs +++ b/src/modules/auth/captcha/router.rs @@ -1,7 +1,9 @@ +use std::collections::HashMap; +use serde_json::{Value, json}; use crate::app::AppState; use crate::app::error::{ApiResult}; use crate::app::response::ApiResponse; -use crate::modules::auth::captcha::model::{AuthCaptchaVo, LoginVo}; +use crate::modules::auth::captcha::model::{AuthCaptchaVo, LoginVo, UserVo}; use axum::{Router, debug_handler, routing}; pub fn create_auth_router() -> Router { @@ -43,15 +45,32 @@ pub async fn login() -> ApiResult> { } #[debug_handler] -pub async fn user() -> ApiResult> { - let vo = LoginVo { - access_token: "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJsb2dpblR5cGUiOiJsb2dpbiIsImxvZ2luSWQiOiJzeXNfdXNlcjp1MSIsInJuU3RyIjoiZ1RxUHRRZmZLYm4xcmdzSzZkWTc2Qzh4cFoxV01KZUkiLCJjbGllbnRpZCI6ImU1Y2Q3ZTQ4OTFiZjk1ZDFkMTkyMDZjZTI0YTdiMzJlIiwidXNlcklkIjoidTEiLCJ1c2VyTmFtZSI6ImFkbWluIiwib3JnaWQiOiJvMTAwMCIsIm9yZ25hIjoiWFjnp5HmioAifQ.a5eDnQTXcQ5D34_FaOFsJZB_yYwRkRAKwstwhqLjpVc".to_string(), - refresh_token: "".to_string(), - expire_in: 604800, - refresh_expire_in: 604800, - client_id: "".to_string(), - scope: "".to_string(), - openid: "".to_string(), +pub async fn user() -> ApiResult>> { + let vo = UserVo { + useid: "u1".to_string(), + usena: "admin".to_string(), + nicna: "管理员".to_string(), + usety: None, + orgid: "o1000".to_string(), + orgna: "XX科技".to_string(), + tenid: None, + email: None, + monum: "13812345678".to_string(), + gender: "1".to_string(), + // avatar: Some("https://unpkg.com/@vbenjs/static-source@0.1.7/source/avatar-v1.webp".to_string()), + avatar: Some("/api/tool/oss/show?id=2015240095127236608".to_string()), + avtag: None, + loip: None, + lotim: None, + notes: None, + crtim: None, + roids: None, + poids: None, + rolid: None, }; - Ok(ApiResponse::ok("ok", Some(vo))) + let mut map: HashMap = HashMap::new(); + map.insert("user".to_string(), json!(vo)); + map.insert("perms".to_string(), json!(["*:*:*"])); + map.insert("roles".to_string(), json!(["superadmin"])); + Ok(ApiResponse::ok("操纵成功", Some(map))) }