fix: 统一字段命名为 camelCase 并修复详情 API

- models.rs: 将 inspectiontype/assignmentnumber 的 serde rename 改为
  inspectionType/assignmentNumber,与前端 TypeScript 接口保持一致
- models.rs: 为 WeatherDataBrief 添加 isFavorite 字段支持
- models.rs: WeatherData.is_favorite 添加 skip_deserializing 避免 POST
  请求解析失败,同时使用 default 处理数据库 NULL 值
- handlers/weather.rs: get_weather_details 支持 string 和 number 类型的
  id 参数解析
- IMPROVEMENTS.md: 新增第十三章记录本次对话经验(serde 配置、config
  路径解析、TOML 结构等)
This commit is contained in:
2026-04-17 20:47:00 +08:00
parent bdbba2cd60
commit 61b1174b30
6 changed files with 124 additions and 15 deletions

View File

@@ -113,6 +113,7 @@ pub struct WeatherDataBrief {
pub longitude: String,
pub latitude: String,
#[serde(rename = "isFavorite", default)]
pub is_favorite: bool,
}
@@ -134,7 +135,7 @@ pub struct WeatherData {
#[sqlx(rename = "areatype")]
pub area_type: String,
#[serde(rename = "assignmentnumber")]
#[serde(rename = "assignmentNumber")]
#[sqlx(rename = "assignmentnumber")]
pub assignment_number: Option<String>,
@@ -186,7 +187,7 @@ pub struct WeatherData {
#[sqlx(rename = "hour")]
pub hours: i32,
#[serde(rename = "inspectiontype")]
#[serde(rename = "inspectionType")]
#[sqlx(rename = "inspectiontype")]
pub inspection_type: Option<String>,
@@ -266,6 +267,8 @@ pub struct WeatherData {
#[sqlx(rename = "windspeedsuitability")]
pub wind_speed_suitability: String,
#[serde(skip_deserializing)]
#[serde(rename = "isFavorite", default)]
pub is_favorite: bool,
}