配置生成逻辑优化
This commit is contained in:
@@ -262,22 +262,20 @@ adminive::Resource_Transaction<Data_feed_Config_Data> data_feed_settings_transac
|
||||
adminive::Resource_Transaction<Map_View_Config> map_view_transaction(Global* global) {
|
||||
adminive::Resource_Transaction<Map_View_Config> transaction;
|
||||
transaction.prepare = [global](const Map_View_Config& value, const adminive::Request_Context&) {
|
||||
if(!Map_View_Config::is_scene_mode(value.scene_mode))
|
||||
throw adminive::Field_Validation_Error("scene_mode", "场景模式必须为 2d 或 3d");
|
||||
global->map_resources_config.read([&](const auto& resources) {
|
||||
if(!resources.is_imagery_key(value.map2d.current_imagery_key))
|
||||
if (!resources.is_imagery_key(value.map2d.current_imagery_key))
|
||||
throw adminive::Field_Validation_Error("map2d.current_imagery_key", "影像源不存在");
|
||||
if(!resources.is_terrain_key(value.map2d.current_terrain_key))
|
||||
if (!resources.is_terrain_key(value.map2d.current_terrain_key))
|
||||
throw adminive::Field_Validation_Error("map2d.current_terrain_key", "地形源不存在");
|
||||
if(!resources.is_imagery_key(value.map3d.current_imagery_key))
|
||||
if (!resources.is_imagery_key(value.map3d.current_imagery_key))
|
||||
throw adminive::Field_Validation_Error("map3d.current_imagery_key", "影像源不存在");
|
||||
if(!resources.is_terrain_key(value.map3d.current_terrain_key))
|
||||
if (!resources.is_terrain_key(value.map3d.current_terrain_key))
|
||||
throw adminive::Field_Validation_Error("map3d.current_terrain_key", "地形源不存在");
|
||||
});
|
||||
};
|
||||
const auto persist = [global](const Map_View_Config& value, const adminive::Request_Context&) {
|
||||
global->map_resources_config.write([&](auto& resources) {
|
||||
resources.current_imagery_key = value.scene_mode == "2d" ? value.map2d.current_imagery_key : value.map3d.current_imagery_key;
|
||||
resources.current_imagery_key = value.scene_mode == Map_Scene_Mode::map_2d ? value.map2d.current_imagery_key : value.map3d.current_imagery_key;
|
||||
});
|
||||
Config::save(Config_Section::map_view, value.to_base_json());
|
||||
Config::save(Config_Section::map_resources);
|
||||
@@ -771,7 +769,7 @@ std::vector<External_Resource_Row> external_resource_rows(Global* global) {
|
||||
rows.reserve(list->children.size());
|
||||
for(const auto& item : list->children) {
|
||||
External_Resources_Data value;
|
||||
value.from_base_json(&item, false);
|
||||
value.from_base_json(&item);
|
||||
External_Resource_Row row;
|
||||
row.name = value.name;
|
||||
row.description = value.description;
|
||||
|
||||
Reference in New Issue
Block a user