支付系统核心:配额限制与用户付费状态管理

- 添加 tokio 依赖用于异步测试
- 启用 User 结构体,添加 is_paid/is_admin/paid_expires_at 字段
- 添加 UpdatePaymentRequest 请求体
- insert_weather_data 集成配额检查逻辑
- 新增 get_user_by_id、count_user_weather_data、update_user_payment_status
- 添加 payment_fields 数据库迁移脚本
This commit is contained in:
2026-03-25 13:17:36 +08:00
parent 63b6d5df8f
commit 484146aba9
5 changed files with 117 additions and 19 deletions

View File

@@ -272,8 +272,7 @@ pub struct WeatherData {
pub wind_speed_suitability: String,
}
/*
#[derive(Debug, Serialize, FromRow)]
#[derive(Debug, Serialize, Deserialize, FromRow)]
pub struct User {
pub id: i32,
#[serde(rename = "name")]
@@ -289,5 +288,17 @@ pub struct User {
#[serde(rename = "desc")]
#[sqlx(rename = "desc")]
pub description: Option<String>,
#[sqlx(rename = "is_paid")]
pub is_paid: bool,
#[sqlx(rename = "is_admin")]
pub is_admin: bool,
#[sqlx(rename = "paid_expires_at")]
pub paid_expires_at: Option<chrono::DateTime<chrono::Utc>>,
}
// 管理员更新用户付费状态的请求体
#[derive(Debug, Deserialize)]
pub struct UpdatePaymentRequest {
pub is_paid: bool,
pub paid_expires_at: Option<String>, // ISO 8601 格式
}
*/