修复bug

This commit is contained in:
2026-08-09 16:05:16 +08:00
parent 4b9dd5c199
commit a80199ef36
2 changed files with 90 additions and 1 deletions
+11 -1
View File
@@ -604,6 +604,7 @@ void database_server(Global *g) {
svr.Post(api + "aircraft_list", [](HTTP_Param) {
CHECK_JSON_PARAM
auto g = Global::instance();
const auto include_model = params.try_get_bool("include_model").value_or(false);
HTTP_REQUIRE_VALUE(data_source_key,
params.try_get_string("data_source_key"))
std::shared_ptr<Data_Source> db;
@@ -633,7 +634,16 @@ void database_server(Global *g) {
{
Scope_Timer timer("aircraft_list.json_serialization",
g->http_monitor_config.slow_scope_threshold_ms);
body = warp(ret).to_json_string();
if (include_model) {
auto data = JSON::object();
data.append({"items", std::move(ret)});
auto response = JSON::object();
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();
}
}
res->setBody(body);
});