feat: 添加用户信息存储功能

- 添加 avatar_url 和 nickname 字段到 users 表
- 修改 get_user_by_id 查询包含新字段
- 添加 save_user_profile API
- 优化 deploy.sh 默认使用 release 模式
This commit is contained in:
2026-03-26 14:28:46 +08:00
parent fcf358f990
commit 6d2824589c
6 changed files with 162 additions and 276 deletions

View File

@@ -40,22 +40,12 @@ pub struct TokenResponse {
}
impl TokenResponse {
/// 快速创建登录成功的令牌响应
/// - token: 生成的JWT令牌字符串
pub fn new(token: String) -> Self {
Self {
success: true, // 登录成功场景固定为true
success: true,
token,
}
}
/// 创建登录失败的响应(可选,用于统一错误响应格式)
pub fn failed() -> Self {
Self {
success: false,
token: String::new(), // 失败时令牌为空
}
}
}
#[derive(Debug, Deserialize)]
@@ -294,6 +284,12 @@ pub struct User {
pub is_admin: bool,
#[sqlx(rename = "paid_expires_at")]
pub paid_expires_at: Option<chrono::DateTime<chrono::Utc>>,
#[serde(rename = "avatarUrl")]
#[sqlx(rename = "avatar_url")]
pub avatar_url: Option<String>,
#[serde(rename = "nickname")]
#[sqlx(rename = "nickname")]
pub nickname: Option<String>,
}
// 管理员更新用户付费状态的请求体