添加weatherdata表的struct
This commit is contained in:
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -387,6 +387,7 @@ dependencies = [
|
||||
"iana-time-zone",
|
||||
"js-sys",
|
||||
"num-traits",
|
||||
"serde",
|
||||
"wasm-bindgen",
|
||||
"windows-link 0.1.3",
|
||||
]
|
||||
@@ -1813,6 +1814,7 @@ dependencies = [
|
||||
"dotenvy",
|
||||
"reqwest",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"sqlx",
|
||||
]
|
||||
|
||||
|
||||
@@ -5,8 +5,9 @@ edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
actix-web = "4.11.0"
|
||||
chrono = "0.4.41"
|
||||
chrono = {version = "0.4.41", features=["serde"]}
|
||||
dotenvy = "0.15.7"
|
||||
reqwest = { version = "0.12.23", features=["json"]}
|
||||
serde = { version = "1.0.219", features = ["derive"] }
|
||||
serde_json = "1.0.143"
|
||||
sqlx = { version = "0.8.6", features = ["runtime-tokio-rustls", "postgres", "chrono", "uuid"] }
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
use chrono::NaiveDate;
|
||||
use serde::Serialize;
|
||||
use sqlx::FromRow;
|
||||
use sqlx::FromRow; // 处理日期类型
|
||||
|
||||
#[derive(Debug, Serialize, FromRow)]
|
||||
pub struct User {
|
||||
@@ -17,4 +18,45 @@ pub struct User {
|
||||
#[serde(rename = "desc")]
|
||||
#[sqlx(rename = "desc")]
|
||||
pub description: Option<String>,
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, FromRow)]
|
||||
pub struct WeatherData {
|
||||
pub id: i32,
|
||||
pub user_id: i32,
|
||||
pub title: Option<String>,
|
||||
#[serde(rename = "date")]
|
||||
#[sqlx(rename = "date")]
|
||||
pub record_date: Option<NaiveDate>, // 避免与关键字冲突
|
||||
pub hour: Option<i32>,
|
||||
pub min: Option<i32>,
|
||||
pub longitude: Option<String>,
|
||||
pub latitude: Option<String>,
|
||||
pub daysincejanfirst: Option<i32>,
|
||||
pub theta: Option<f64>,
|
||||
pub solardeclination: Option<f64>,
|
||||
pub sunaltitude: Option<f64>,
|
||||
pub overallcloudiness: Option<String>,
|
||||
pub lowcloudiness: Option<String>,
|
||||
pub cloudindex: Option<String>,
|
||||
pub solarradiationlevel: Option<i32>,
|
||||
pub hasmeasuredwindspeed: Option<bool>,
|
||||
pub measuredwindspeed: Option<f64>,
|
||||
pub convertedwindspeed: Option<i32>,
|
||||
pub measurementheight: Option<f64>,
|
||||
pub areatype: Option<String>,
|
||||
pub pointwindspeed: Option<f64>,
|
||||
pub atmosphericstability: Option<String>,
|
||||
pub suitabilitydegree: Option<String>,
|
||||
pub winddirection: Option<serde_json::Value>, // JSONB类型
|
||||
pub averagewinddirection: Option<f64>,
|
||||
pub winddirectionstandarddeviation: Option<f64>,
|
||||
pub windspeed: Option<serde_json::Value>, // JSONB类型
|
||||
pub averagewindspeed: Option<f64>,
|
||||
pub windspeedsuitability: Option<String>,
|
||||
pub winddirectionsuitability: Option<String>,
|
||||
pub overallsuitability: Option<String>,
|
||||
pub inspectiontype: Option<String>,
|
||||
pub assignmentnumber: Option<String>,
|
||||
pub calculatedwindspeed: Option<f64>,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user