添加weatherdata表的struct
This commit is contained in:
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -387,6 +387,7 @@ dependencies = [
|
|||||||
"iana-time-zone",
|
"iana-time-zone",
|
||||||
"js-sys",
|
"js-sys",
|
||||||
"num-traits",
|
"num-traits",
|
||||||
|
"serde",
|
||||||
"wasm-bindgen",
|
"wasm-bindgen",
|
||||||
"windows-link 0.1.3",
|
"windows-link 0.1.3",
|
||||||
]
|
]
|
||||||
@@ -1813,6 +1814,7 @@ dependencies = [
|
|||||||
"dotenvy",
|
"dotenvy",
|
||||||
"reqwest",
|
"reqwest",
|
||||||
"serde",
|
"serde",
|
||||||
|
"serde_json",
|
||||||
"sqlx",
|
"sqlx",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
@@ -5,8 +5,9 @@ edition = "2024"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
actix-web = "4.11.0"
|
actix-web = "4.11.0"
|
||||||
chrono = "0.4.41"
|
chrono = {version = "0.4.41", features=["serde"]}
|
||||||
dotenvy = "0.15.7"
|
dotenvy = "0.15.7"
|
||||||
reqwest = { version = "0.12.23", features=["json"]}
|
reqwest = { version = "0.12.23", features=["json"]}
|
||||||
serde = { version = "1.0.219", features = ["derive"] }
|
serde = { version = "1.0.219", features = ["derive"] }
|
||||||
|
serde_json = "1.0.143"
|
||||||
sqlx = { version = "0.8.6", features = ["runtime-tokio-rustls", "postgres", "chrono", "uuid"] }
|
sqlx = { version = "0.8.6", features = ["runtime-tokio-rustls", "postgres", "chrono", "uuid"] }
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
|
use chrono::NaiveDate;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use sqlx::FromRow;
|
use sqlx::FromRow; // 处理日期类型
|
||||||
|
|
||||||
#[derive(Debug, Serialize, FromRow)]
|
#[derive(Debug, Serialize, FromRow)]
|
||||||
pub struct User {
|
pub struct User {
|
||||||
@@ -17,4 +18,45 @@ pub struct User {
|
|||||||
#[serde(rename = "desc")]
|
#[serde(rename = "desc")]
|
||||||
#[sqlx(rename = "desc")]
|
#[sqlx(rename = "desc")]
|
||||||
pub description: Option<String>,
|
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