使用了jwt作为身份验证和分发
This commit is contained in:
@@ -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)]
|
||||
|
||||
Reference in New Issue
Block a user