修复bug

This commit is contained in:
2026-08-09 19:33:53 +08:00
parent b9a86e0e6b
commit 892cb881d2
2 changed files with 43 additions and 9 deletions
+10 -8
View File
@@ -606,6 +606,7 @@ void database_server(Global *g) {
CHECK_JSON_PARAM
auto g = Global::instance();
const auto include_model = params.try_get_bool("include_model").value_or(false);
const auto client_schema_hash = params.try_get_string("schema_hash").value_or("");
HTTP_REQUIRE_VALUE(data_source_key,
params.try_get_string("data_source_key"))
std::shared_ptr<Data_Source> db;
@@ -635,16 +636,17 @@ void database_server(Global *g) {
{
Scope_Timer timer("aircraft_list.json_serialization",
g->http_monitor_config.slow_scope_threshold_ms);
if (include_model) {
auto data = JSON::object();
data.append({"items", std::move(ret)});
auto response = JSON::object();
auto data = JSON::object();
data.append({"items", std::move(ret)});
auto response = JSON::object();
const auto& schema_hash = Aircraft_List_JSON_Service_O::view_model_schema_hash();
response.append({"schema_version", Aircraft_List_JSON_Service_O::view_model_schema_version});
response.append({"schema_hash", schema_hash});
if (include_model || client_schema_hash != schema_hash) {
response.append({"model", Aircraft_List_JSON_Service_O::view_model()});
response.append({"data", std::move(data)});
body = response.to_json_string();
} else {
body = warp(ret).to_json_string();
}
response.append({"data", std::move(data)});
body = response.to_json_string();
}
res->setBody(body);
});