修改了错误的数据库方法
This commit is contained in:
@@ -126,7 +126,7 @@ pub async fn get_weather_details(pool: &PgPool, weather_id: i32) -> Result<Weath
|
|||||||
let query = r#"
|
let query = r#"
|
||||||
SELECT
|
SELECT
|
||||||
wd.id, wd.title, wd.date, wd.hour, wd.min,
|
wd.id, wd.title, wd.date, wd.hour, wd.min,
|
||||||
wd.longitude::float8 as longitude, wd.latitude::float8 as latitude,
|
wd.longitude, wd.latitude,
|
||||||
wd.daysincejanfirst, wd.theta, wd.solardeclination,
|
wd.daysincejanfirst, wd.theta, wd.solardeclination,
|
||||||
wd.sunaltitude, wd.overallcloudiness, wd.lowcloudiness,
|
wd.sunaltitude, wd.overallcloudiness, wd.lowcloudiness,
|
||||||
wd.cloudindex, wd.solarradiationlevel, wd.hasmeasuredwindspeed,
|
wd.cloudindex, wd.solarradiationlevel, wd.hasmeasuredwindspeed,
|
||||||
|
|||||||
@@ -244,9 +244,9 @@ async fn get_weather_details(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 修改main.rs中的get_weather函数
|
// 修改main.rs中的get_weather_brief函数
|
||||||
#[get("/weather")]
|
#[get("/weather")]
|
||||||
async fn get_weather(
|
async fn get_weather_brief(
|
||||||
query: web::Query<serde_json::Value>,
|
query: web::Query<serde_json::Value>,
|
||||||
pool: web::Data<PgPool>,
|
pool: web::Data<PgPool>,
|
||||||
claims: web::ReqData<Claims>,
|
claims: web::ReqData<Claims>,
|
||||||
@@ -368,7 +368,7 @@ fn create_server_config(
|
|||||||
.wrap(from_fn(jwt_middleware)) // 关键修改:用 from_fn 包装
|
.wrap(from_fn(jwt_middleware)) // 关键修改:用 from_fn 包装
|
||||||
.service(post_weather_data)
|
.service(post_weather_data)
|
||||||
.service(get_weather_details) // 新增
|
.service(get_weather_details) // 新增
|
||||||
.service(get_weather) // 新增
|
.service(get_weather_brief) // 新增
|
||||||
.service(delete_weather), // 新增
|
.service(delete_weather), // 新增
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -151,8 +151,8 @@ pub struct WeatherData {
|
|||||||
#[sqlx(rename = "inspectiontype")]
|
#[sqlx(rename = "inspectiontype")]
|
||||||
pub inspection_type: Option<String>,
|
pub inspection_type: Option<String>,
|
||||||
|
|
||||||
pub latitude: f64,
|
pub latitude: String,
|
||||||
pub longitude: f64,
|
pub longitude: String,
|
||||||
|
|
||||||
#[serde(rename = "lowCloudiness")]
|
#[serde(rename = "lowCloudiness")]
|
||||||
#[sqlx(rename = "lowcloudiness")]
|
#[sqlx(rename = "lowcloudiness")]
|
||||||
|
|||||||
Reference in New Issue
Block a user