在数据库中添加了Version字段,并修改前端,不再使用指定的Version
This commit is contained in:
@@ -32,10 +32,10 @@ pub async fn insert_weather_data(pool: &PgPool, weather_data: &WeatherData) -> R
|
||||
atmosphericstability, suitabilitydegree, winddirection, averagewinddirection,
|
||||
winddirectionstandarddeviation, windspeed, averagewindspeed, windspeedsuitability,
|
||||
winddirectionsuitability, overallsuitability, inspectiontype, assignmentnumber,
|
||||
calculatedwindspeed, hasspotcheckwindspeed
|
||||
calculatedwindspeed, hasspotcheckwindspeed, version
|
||||
) VALUES (
|
||||
$1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19,
|
||||
$20, $21, $22, $23, $24, $25, $26, $27, $28, $29, $30, $31, $32, $33, $34, $35
|
||||
$20, $21, $22, $23, $24, $25, $26, $27, $28, $29, $30, $31, $32, $33, $34, $35, $36
|
||||
) RETURNING id
|
||||
"#;
|
||||
|
||||
@@ -82,6 +82,7 @@ pub async fn insert_weather_data(pool: &PgPool, weather_data: &WeatherData) -> R
|
||||
.bind(&weather_data.assignment_number)
|
||||
.bind(weather_data.calculated_wind_speed) // 这个本来就是 Option,无需修改
|
||||
.bind(weather_data.has_spot_check_wind_speed)
|
||||
.bind(&weather_data.version)
|
||||
.fetch_one(pool)
|
||||
.await
|
||||
{
|
||||
@@ -116,8 +117,6 @@ pub async fn create_pool() -> Result<PgPool, Box<dyn Error>> {
|
||||
Ok(pool)
|
||||
}
|
||||
|
||||
// 在db.rs中添加以下函数
|
||||
|
||||
// 获取天气数据详情
|
||||
pub async fn get_weather_details(pool: &PgPool, weather_id: i32) -> Result<WeatherData, String> {
|
||||
let query = r#"
|
||||
@@ -133,7 +132,7 @@ pub async fn get_weather_details(pool: &PgPool, weather_id: i32) -> Result<Weath
|
||||
wd.winddirectionstandarddeviation, wd.windspeed, wd.averagewindspeed,
|
||||
wd.windspeedsuitability, wd.winddirectionsuitability, wd.overallsuitability,
|
||||
wd.inspectiontype, wd.assignmentnumber, wd.calculatedwindspeed, wd.hasspotcheckwindspeed,
|
||||
u.openid
|
||||
u.openid, wd.version
|
||||
FROM weather_data wd
|
||||
JOIN users u ON wd.user_id = u.id
|
||||
WHERE wd.id = $1
|
||||
|
||||
@@ -247,6 +247,8 @@ pub struct WeatherData {
|
||||
pub theta: f64,
|
||||
pub title: String,
|
||||
|
||||
pub version: String,
|
||||
|
||||
#[serde(rename = "windDirection")]
|
||||
#[sqlx(rename = "winddirection")]
|
||||
#[sqlx(try_from = "serde_json::Value")]
|
||||
|
||||
Reference in New Issue
Block a user