使用了jwt作为身份验证和分发

This commit is contained in:
2025-09-26 13:48:18 +08:00
parent 4f0a171366
commit 1c2eb82248
5 changed files with 217 additions and 76 deletions

View File

@@ -2,15 +2,19 @@ use chrono::NaiveDate;
use serde::{Deserialize, Serialize};
use sqlx::FromRow;
// 新增API请求/响应结构体
#[derive(Debug, Deserialize)]
pub struct OpenIdRequest {
pub openid: String,
}
#[derive(Debug, Serialize)]
pub struct UserIdResponse {
// 定义JWT载荷结构体
#[derive(Debug, Serialize, Deserialize)]
pub struct Claims {
// 标准字段:过期时间(必须)
pub exp: i64, // 时间戳(秒)
// 标准字段:签发时间
pub iat: i64,
// 自定义字段用户ID根据业务需求添加
pub user_id: i32,
// 自定义字段openid可选
pub openid: String,
// 自定义字段user_ytpe
pub user_type: i32,
}
#[derive(Debug, Deserialize)]