152 lines
3.5 KiB
Rust
152 lines
3.5 KiB
Rust
use chrono::NaiveDate;
|
||
use serde::{Deserialize, Serialize};
|
||
use sqlx::FromRow;
|
||
|
||
// 新增:API请求/响应结构体
|
||
#[derive(Debug, Deserialize)]
|
||
pub struct OpenIdRequest {
|
||
pub openid: String,
|
||
}
|
||
|
||
#[derive(Debug, Serialize)]
|
||
pub struct UserIdResponse {
|
||
pub user_id: i32,
|
||
}
|
||
|
||
#[derive(Debug, Deserialize)]
|
||
pub struct WeChatLoginRequest {
|
||
pub code: String,
|
||
}
|
||
|
||
#[derive(Debug, Deserialize)]
|
||
pub struct WeChatApiResponse {
|
||
pub openid: Option<String>,
|
||
pub errcode: Option<i32>,
|
||
pub errmsg: Option<String>,
|
||
}
|
||
|
||
#[derive(Debug, Serialize)]
|
||
pub struct OpenIdResponse {
|
||
pub openid: String,
|
||
}
|
||
|
||
#[derive(Debug, Serialize)]
|
||
pub struct ErrorResponse {
|
||
pub error: String,
|
||
pub errcode: Option<i32>,
|
||
pub errmsg: Option<String>,
|
||
}
|
||
|
||
// 天气数据结构体(已有)
|
||
#[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,
|
||
#[serde(rename = "name")]
|
||
#[sqlx(rename = "name")]
|
||
pub name: String,
|
||
#[sqlx(rename = "openid")]
|
||
pub openid: Option<String>,
|
||
#[sqlx(rename = "phone")]
|
||
pub phone: Option<String>,
|
||
#[serde(rename = "type")]
|
||
#[sqlx(rename = "type")]
|
||
pub user_type: i32,
|
||
#[serde(rename = "desc")]
|
||
#[sqlx(rename = "desc")]
|
||
pub description: Option<String>,
|
||
}
|