将WeatherData移到models.rs中
This commit is contained in:
137
src/models.rs
137
src/models.rs
@@ -1,7 +1,101 @@
|
||||
use chrono::NaiveDate;
|
||||
use serde::{Serialize};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use sqlx::FromRow; // 处理日期类型
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
pub struct WeatherData {
|
||||
#[serde(rename = "areaType")]
|
||||
pub area_type: String,
|
||||
|
||||
#[serde(rename = "assignmentnumber")]
|
||||
pub assignment_number: String,
|
||||
|
||||
#[serde(rename = "atmosphericStability")]
|
||||
pub atmospheric_stability: String,
|
||||
|
||||
#[serde(rename = "averageWindDirection")]
|
||||
pub average_wind_direction: f64,
|
||||
|
||||
#[serde(rename = "averageWindSpeed")]
|
||||
pub average_wind_speed: f64,
|
||||
|
||||
#[serde(rename = "calculatedwindspeed")]
|
||||
pub calculated_wind_speed: f64,
|
||||
|
||||
#[serde(rename = "cloudIndex")]
|
||||
pub cloud_index: String,
|
||||
|
||||
#[serde(rename = "convertedWindSpeed")]
|
||||
pub converted_wind_speed: f64,
|
||||
|
||||
pub date: NaiveDate,
|
||||
|
||||
#[serde(rename = "daySinceJanFirst")]
|
||||
pub day_since_jan_first: i32,
|
||||
|
||||
#[serde(rename = "hasMeasuredWindSpeed")]
|
||||
pub has_measured_wind_speed: bool,
|
||||
|
||||
pub hours: i32,
|
||||
|
||||
#[serde(rename = "inspectiontype")]
|
||||
pub inspection_type: String,
|
||||
|
||||
pub latitude: f64,
|
||||
pub longitude: f64,
|
||||
|
||||
#[serde(rename = "lowCloudiness")]
|
||||
pub low_cloudiness: String,
|
||||
|
||||
#[serde(rename = "measuredWindSpeed")]
|
||||
pub measured_wind_speed: f64,
|
||||
|
||||
#[serde(rename = "measurementHeight")]
|
||||
pub measurement_height: f64,
|
||||
|
||||
pub min: i32,
|
||||
pub openid: String,
|
||||
|
||||
#[serde(rename = "overallCloudiness")]
|
||||
pub overall_cloudiness: String,
|
||||
|
||||
#[serde(rename = "overallSuitability")]
|
||||
pub overall_suitability: String,
|
||||
|
||||
#[serde(rename = "pointWindSpeed")]
|
||||
pub point_wind_speed: f64,
|
||||
|
||||
#[serde(rename = "solarDeclination")]
|
||||
pub solar_declination: f64,
|
||||
|
||||
#[serde(rename = "solarRadiationLevel")]
|
||||
pub solar_radiation_level: f64,
|
||||
|
||||
#[serde(rename = "suitabilityDegree")]
|
||||
pub suitability_degree: String,
|
||||
|
||||
#[serde(rename = "sunAltitude")]
|
||||
pub sun_altitude: f64,
|
||||
|
||||
pub theta: f64,
|
||||
pub title: String,
|
||||
|
||||
#[serde(rename = "windDirection")]
|
||||
pub wind_direction: Vec<f64>,
|
||||
|
||||
#[serde(rename = "windDirectionStandardDeviation")]
|
||||
pub wind_direction_standard_deviation: f64,
|
||||
|
||||
#[serde(rename = "windDirectionSuitability")]
|
||||
pub wind_direction_suitability: String,
|
||||
|
||||
#[serde(rename = "windSpeed")]
|
||||
pub wind_speed: Vec<f64>,
|
||||
|
||||
#[serde(rename = "windSpeedSuitability")]
|
||||
pub wind_speed_suitability: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, FromRow)]
|
||||
pub struct User {
|
||||
pub id: i32,
|
||||
@@ -19,44 +113,3 @@ pub struct User {
|
||||
#[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