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:
@@ -113,9 +113,13 @@ pub async fn get_weather_details(
|
||||
};
|
||||
(temp_claims.openid, temp_claims.resource_id)
|
||||
} else if let Some(claims) = claims {
|
||||
let weather_id = match query.get("id").and_then(|v| v.as_i64()) {
|
||||
Some(id) => id as i32,
|
||||
None => {
|
||||
let weather_id = match query.get("id") {
|
||||
Some(v) if v.is_i64() => v.as_i64().unwrap() as i32,
|
||||
Some(v) if v.is_string() => {
|
||||
v.as_str().and_then(|s| s.parse::<i32>().ok()).unwrap_or(0)
|
||||
}
|
||||
Some(v) if v.is_number() => v.as_f64().unwrap() as i32,
|
||||
_ => {
|
||||
return HttpResponse::BadRequest().json(ErrorResponse {
|
||||
error: "缺少资源ID参数(id)".to_string(),
|
||||
errcode: Some(400),
|
||||
|
||||
Reference in New Issue
Block a user