使用了logger来进行后端的消息记录

This commit is contained in:
2025-09-30 15:59:15 +08:00
parent 9880124c87
commit 7fa1ae6301
6 changed files with 353 additions and 26 deletions

View File

@@ -28,6 +28,36 @@ pub struct TempTokenClaims {
pub resource_id: i32, // 允许访问的资源ID如天气数据id
}
// 登录成功后的令牌响应结构体
/// 仅包含操作状态和令牌信息
#[derive(Debug, Serialize, Clone)]
pub struct TokenResponse {
/// 操作状态true表示登录成功false表示失败
pub success: bool,
/// 登录成功后生成的JWT令牌客户端后续请求需携带此令牌
pub token: String,
}
impl TokenResponse {
/// 快速创建登录成功的令牌响应
/// - token: 生成的JWT令牌字符串
pub fn new(token: String) -> Self {
Self {
success: true, // 登录成功场景固定为true
token,
}
}
/// 创建登录失败的响应(可选,用于统一错误响应格式)
pub fn failed() -> Self {
Self {
success: false,
token: String::new(), // 失败时令牌为空
}
}
}
#[derive(Debug, Deserialize)]
pub struct WeChatLoginRequest {
pub code: String,