You've already forked FrameTour-BE
refactor(scenic): 重构景区管理接口并新增 V2 版本
- 新增 ScenicV2Controller 控制器,实现景区 V2 版本的 CRUD操作和配置管理 - 移除 ScenicConfigWithDefaultClient 和 ScenicMetaClient 接口- 更新 ScenicV2Client接口,添加分页查询方法 - 删除 ConfigWithDefaultResponse、BatchSetFieldEnabledRequest、EnabledFieldsResponse、FieldConfigDTO 和 SetFieldEnabledRequest 类 - 新增 ScenicV2ListResponse 和 ScenicV2WithConfigListResponse 类- 更新 ScenicConfigIntegrationService 和 ScenicIntegrationService,移除与配置相关的方法 - 删除 ScenicMetaIntegrationService 类
This commit is contained in:
@@ -0,0 +1,310 @@
|
|||||||
|
package com.ycwl.basic.controller.pc;
|
||||||
|
|
||||||
|
import com.ycwl.basic.integration.scenic.dto.config.BatchConfigRequest;
|
||||||
|
import com.ycwl.basic.integration.scenic.dto.config.BatchUpdateResponse;
|
||||||
|
import com.ycwl.basic.integration.scenic.dto.config.CreateConfigRequest;
|
||||||
|
import com.ycwl.basic.integration.scenic.dto.config.ScenicConfigV2DTO;
|
||||||
|
import com.ycwl.basic.integration.scenic.dto.config.UpdateConfigRequest;
|
||||||
|
import com.ycwl.basic.integration.scenic.dto.filter.ScenicFilterPageResponse;
|
||||||
|
import com.ycwl.basic.integration.scenic.dto.filter.ScenicFilterRequest;
|
||||||
|
import com.ycwl.basic.integration.scenic.dto.scenic.CreateScenicRequest;
|
||||||
|
import com.ycwl.basic.integration.scenic.dto.scenic.ScenicV2DTO;
|
||||||
|
import com.ycwl.basic.integration.scenic.dto.scenic.ScenicV2WithConfigDTO;
|
||||||
|
import com.ycwl.basic.integration.scenic.dto.scenic.ScenicV2ListResponse;
|
||||||
|
import com.ycwl.basic.integration.scenic.dto.scenic.ScenicV2WithConfigListResponse;
|
||||||
|
import com.ycwl.basic.integration.scenic.dto.scenic.UpdateScenicRequest;
|
||||||
|
import com.ycwl.basic.integration.scenic.service.ScenicConfigIntegrationService;
|
||||||
|
import com.ycwl.basic.integration.scenic.service.ScenicIntegrationService;
|
||||||
|
import com.ycwl.basic.utils.ApiResponse;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:longbinbin
|
||||||
|
* @Date:2024/12/26
|
||||||
|
* 景区管理 V2 版本控制器 - 基于 zt-scenic 集成服务
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/scenic/v2")
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class ScenicV2Controller {
|
||||||
|
|
||||||
|
private final ScenicIntegrationService scenicIntegrationService;
|
||||||
|
private final ScenicConfigIntegrationService scenicConfigIntegrationService;
|
||||||
|
|
||||||
|
// ========== 景区基础 CRUD 操作 ==========
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 景区V2核心信息分页列表
|
||||||
|
*/
|
||||||
|
@GetMapping("/")
|
||||||
|
public ApiResponse<ScenicV2ListResponse> listScenics(@RequestParam(defaultValue = "1") Integer page,
|
||||||
|
@RequestParam(defaultValue = "10") Integer pageSize,
|
||||||
|
@RequestParam(required = false) Integer status,
|
||||||
|
@RequestParam(required = false) String name) {
|
||||||
|
log.info("分页查询景区核心信息列表, page: {}, pageSize: {}, status: {}, name: {}", page, pageSize, status, name);
|
||||||
|
|
||||||
|
// 参数验证:限制pageSize最大值为100
|
||||||
|
if (pageSize > 100) {
|
||||||
|
pageSize = 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
ScenicV2ListResponse response = scenicIntegrationService.listScenics(page, pageSize, status, name);
|
||||||
|
return ApiResponse.success(response);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("分页查询景区核心信息列表失败", e);
|
||||||
|
return ApiResponse.fail("分页查询景区列表失败: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 景区V2带配置信息分页列表
|
||||||
|
*/
|
||||||
|
@GetMapping("/with-config")
|
||||||
|
public ApiResponse<ScenicV2WithConfigListResponse> listScenicsWithConfig(@RequestParam(defaultValue = "1") Integer page,
|
||||||
|
@RequestParam(defaultValue = "10") Integer pageSize,
|
||||||
|
@RequestParam(required = false) Integer status,
|
||||||
|
@RequestParam(required = false) String name) {
|
||||||
|
log.info("分页查询景区带配置信息列表, page: {}, pageSize: {}, status: {}, name: {}", page, pageSize, status, name);
|
||||||
|
|
||||||
|
// 参数验证:限制pageSize最大值为100
|
||||||
|
if (pageSize > 100) {
|
||||||
|
pageSize = 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
ScenicV2WithConfigListResponse response = scenicIntegrationService.listScenicsWithConfig(page, pageSize, status, name);
|
||||||
|
return ApiResponse.success(response);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("分页查询景区带配置信息列表失败", e);
|
||||||
|
return ApiResponse.fail("分页查询景区带配置信息列表失败: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询单个景区详情
|
||||||
|
*/
|
||||||
|
@GetMapping("/{scenicId}")
|
||||||
|
public ApiResponse<ScenicV2DTO> getScenic(@PathVariable Long scenicId) {
|
||||||
|
log.info("查询景区详情, scenicId: {}", scenicId);
|
||||||
|
try {
|
||||||
|
ScenicV2DTO scenic = scenicIntegrationService.getScenic(scenicId);
|
||||||
|
return ApiResponse.success(scenic);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("查询景区详情失败, scenicId: {}", scenicId, e);
|
||||||
|
return ApiResponse.fail("查询景区详情失败: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询景区列表(支持筛选和分页)- 高级筛选
|
||||||
|
*/
|
||||||
|
@PostMapping("/filter")
|
||||||
|
public ApiResponse<ScenicFilterPageResponse> filterScenics(@RequestBody @Valid ScenicFilterRequest request) {
|
||||||
|
log.info("高级筛选景区列表, 筛选条件数: {}, 页码: {}, 页大小: {}",
|
||||||
|
request.getFilters().size(), request.getPage(), request.getPageSize());
|
||||||
|
try {
|
||||||
|
ScenicFilterPageResponse response = scenicIntegrationService.filterScenics(request);
|
||||||
|
return ApiResponse.success(response);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("高级筛选景区列表失败", e);
|
||||||
|
return ApiResponse.fail("高级筛选景区列表失败: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增景区
|
||||||
|
*/
|
||||||
|
@PostMapping("/create")
|
||||||
|
public ApiResponse<ScenicV2DTO> createScenic(@RequestBody @Valid CreateScenicRequest request) {
|
||||||
|
log.info("新增景区, name: {}, mpId: {}", request.getName(), request.getMpId());
|
||||||
|
try {
|
||||||
|
ScenicV2DTO scenic = scenicIntegrationService.createScenic(request);
|
||||||
|
return ApiResponse.success(scenic);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("新增景区失败, name: {}", request.getName(), e);
|
||||||
|
return ApiResponse.fail("新增景区失败: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改景区
|
||||||
|
*/
|
||||||
|
@PutMapping("/{scenicId}")
|
||||||
|
public ApiResponse<ScenicV2DTO> updateScenic(@PathVariable Long scenicId,
|
||||||
|
@RequestBody @Valid UpdateScenicRequest request) {
|
||||||
|
log.info("修改景区, scenicId: {}", scenicId);
|
||||||
|
try {
|
||||||
|
ScenicV2DTO scenic = scenicIntegrationService.updateScenic(scenicId, request);
|
||||||
|
return ApiResponse.success(scenic);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("修改景区失败, scenicId: {}", scenicId, e);
|
||||||
|
return ApiResponse.fail("修改景区失败: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除景区
|
||||||
|
*/
|
||||||
|
@DeleteMapping("/{scenicId}")
|
||||||
|
public ApiResponse<Void> deleteScenic(@PathVariable Long scenicId) {
|
||||||
|
log.info("删除景区, scenicId: {}", scenicId);
|
||||||
|
try {
|
||||||
|
scenicIntegrationService.deleteScenic(scenicId);
|
||||||
|
return ApiResponse.success(null);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("删除景区失败, scenicId: {}", scenicId, e);
|
||||||
|
return ApiResponse.fail("删除景区失败: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ========== 景区配置管理 ==========
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取景区及其配置信息
|
||||||
|
*/
|
||||||
|
@GetMapping("/{scenicId}/with-config")
|
||||||
|
public ApiResponse<ScenicV2WithConfigDTO> getScenicWithConfig(@PathVariable Long scenicId) {
|
||||||
|
log.info("获取景区配置信息, scenicId: {}", scenicId);
|
||||||
|
try {
|
||||||
|
ScenicV2WithConfigDTO scenic = scenicIntegrationService.getScenicWithConfig(scenicId);
|
||||||
|
return ApiResponse.success(scenic);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("获取景区配置信息失败, scenicId: {}", scenicId, e);
|
||||||
|
return ApiResponse.fail("获取景区配置信息失败: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取景区扁平化配置
|
||||||
|
*/
|
||||||
|
@GetMapping("/{scenicId}/flat-config")
|
||||||
|
public ApiResponse<Map<String, Object>> getScenicFlatConfig(@PathVariable Long scenicId) {
|
||||||
|
log.info("获取景区扁平化配置, scenicId: {}", scenicId);
|
||||||
|
try {
|
||||||
|
Map<String, Object> config = scenicIntegrationService.getScenicFlatConfig(scenicId);
|
||||||
|
return ApiResponse.success(config);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("获取景区扁平化配置失败, scenicId: {}", scenicId, e);
|
||||||
|
return ApiResponse.fail("获取景区扁平化配置失败: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取景区配置列表
|
||||||
|
*/
|
||||||
|
@GetMapping("/{scenicId}/config")
|
||||||
|
public ApiResponse<List<ScenicConfigV2DTO>> listConfigs(@PathVariable Long scenicId) {
|
||||||
|
log.info("获取景区配置列表, scenicId: {}", scenicId);
|
||||||
|
try {
|
||||||
|
List<ScenicConfigV2DTO> configs = scenicConfigIntegrationService.listConfigs(scenicId);
|
||||||
|
return ApiResponse.success(configs);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("获取景区配置列表失败, scenicId: {}", scenicId, e);
|
||||||
|
return ApiResponse.fail("获取景区配置列表失败: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据配置键获取配置
|
||||||
|
*/
|
||||||
|
@GetMapping("/{scenicId}/config/{configKey}")
|
||||||
|
public ApiResponse<ScenicConfigV2DTO> getConfigByKey(@PathVariable Long scenicId,
|
||||||
|
@PathVariable String configKey) {
|
||||||
|
log.info("根据键获取景区配置, scenicId: {}, configKey: {}", scenicId, configKey);
|
||||||
|
try {
|
||||||
|
ScenicConfigV2DTO config = scenicConfigIntegrationService.getConfigByKey(scenicId, configKey);
|
||||||
|
return ApiResponse.success(config);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("根据键获取景区配置失败, scenicId: {}, configKey: {}", scenicId, configKey, e);
|
||||||
|
return ApiResponse.fail("获取配置失败: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建景区配置
|
||||||
|
*/
|
||||||
|
@PostMapping("/{scenicId}/config")
|
||||||
|
public ApiResponse<ScenicConfigV2DTO> createConfig(@PathVariable Long scenicId,
|
||||||
|
@RequestBody @Valid CreateConfigRequest request) {
|
||||||
|
log.info("创建景区配置, scenicId: {}, configKey: {}", scenicId, request.getConfigKey());
|
||||||
|
try {
|
||||||
|
ScenicConfigV2DTO config = scenicConfigIntegrationService.createConfig(scenicId, request);
|
||||||
|
return ApiResponse.success(config);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("创建景区配置失败, scenicId: {}, configKey: {}", scenicId, request.getConfigKey(), e);
|
||||||
|
return ApiResponse.fail("创建配置失败: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新景区配置
|
||||||
|
*/
|
||||||
|
@PutMapping("/{scenicId}/config/{configId}")
|
||||||
|
public ApiResponse<ScenicConfigV2DTO> updateConfig(@PathVariable Long scenicId,
|
||||||
|
@PathVariable String configId,
|
||||||
|
@RequestBody @Valid UpdateConfigRequest request) {
|
||||||
|
log.info("更新景区配置, scenicId: {}, configId: {}", scenicId, configId);
|
||||||
|
try {
|
||||||
|
ScenicConfigV2DTO config = scenicConfigIntegrationService.updateConfig(scenicId, configId, request);
|
||||||
|
return ApiResponse.success(config);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("更新景区配置失败, scenicId: {}, configId: {}", scenicId, configId, e);
|
||||||
|
return ApiResponse.fail("更新配置失败: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除景区配置
|
||||||
|
*/
|
||||||
|
@DeleteMapping("/{scenicId}/config/{configId}")
|
||||||
|
public ApiResponse<Void> deleteConfig(@PathVariable Long scenicId, @PathVariable String configId) {
|
||||||
|
log.info("删除景区配置, scenicId: {}, configId: {}", scenicId, configId);
|
||||||
|
try {
|
||||||
|
scenicConfigIntegrationService.deleteConfig(scenicId, configId);
|
||||||
|
return ApiResponse.success(null);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("删除景区配置失败, scenicId: {}, configId: {}", scenicId, configId, e);
|
||||||
|
return ApiResponse.fail("删除配置失败: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量更新景区配置
|
||||||
|
*/
|
||||||
|
@PutMapping("/{scenicId}/config/batch")
|
||||||
|
public ApiResponse<BatchUpdateResponse> batchUpdateConfigs(@PathVariable Long scenicId,
|
||||||
|
@RequestBody @Valid BatchConfigRequest request) {
|
||||||
|
log.info("批量更新景区配置, scenicId: {}, configs count: {}", scenicId, request.getConfigs().size());
|
||||||
|
try {
|
||||||
|
BatchUpdateResponse response = scenicConfigIntegrationService.batchUpdateConfigs(scenicId, request);
|
||||||
|
return ApiResponse.success(response);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("批量更新景区配置失败, scenicId: {}", scenicId, e);
|
||||||
|
return ApiResponse.fail("批量更新配置失败: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 扁平化批量更新景区配置
|
||||||
|
*/
|
||||||
|
@PutMapping("/{scenicId}/flat-config")
|
||||||
|
public ApiResponse<BatchUpdateResponse> batchFlatUpdateConfigs(@PathVariable Long scenicId,
|
||||||
|
@RequestBody Map<String, Object> configs) {
|
||||||
|
log.info("扁平化批量更新景区配置, scenicId: {}, configs count: {}", scenicId, configs.size());
|
||||||
|
try {
|
||||||
|
BatchUpdateResponse response = scenicConfigIntegrationService.batchFlatUpdateConfigs(scenicId, configs);
|
||||||
|
return ApiResponse.success(response);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("扁平化批量更新景区配置失败, scenicId: {}", scenicId, e);
|
||||||
|
return ApiResponse.fail("扁平化批量更新配置失败: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -1,15 +0,0 @@
|
|||||||
package com.ycwl.basic.integration.scenic.client;
|
|
||||||
|
|
||||||
import com.ycwl.basic.integration.common.response.CommonResponse;
|
|
||||||
import com.ycwl.basic.integration.scenic.dto.config.ConfigWithDefaultResponse;
|
|
||||||
import org.springframework.cloud.openfeign.FeignClient;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
|
||||||
|
|
||||||
@FeignClient(name = "zt-scenic", contextId = "scenic-config-with-default", path = "/api/scenic/config-with-default")
|
|
||||||
public interface ScenicConfigWithDefaultClient {
|
|
||||||
|
|
||||||
@GetMapping("/{scenicId}/{configKey}")
|
|
||||||
CommonResponse<ConfigWithDefaultResponse> getConfigWithDefault(@PathVariable("scenicId") Long scenicId,
|
|
||||||
@PathVariable("configKey") String configKey);
|
|
||||||
}
|
|
@@ -1,40 +0,0 @@
|
|||||||
package com.ycwl.basic.integration.scenic.client;
|
|
||||||
|
|
||||||
import com.ycwl.basic.integration.common.response.CommonResponse;
|
|
||||||
import com.ycwl.basic.integration.scenic.dto.meta.*;
|
|
||||||
import com.ycwl.basic.integration.scenic.dto.scenic.ScenicV2WithConfigDTO;
|
|
||||||
import com.ycwl.basic.integration.scenic.dto.scenic.UpdateScenicRequest;
|
|
||||||
import org.springframework.cloud.openfeign.FeignClient;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
@FeignClient(name = "zt-scenic", contextId = "scenic-meta", path = "/api/scenic/meta")
|
|
||||||
public interface ScenicMetaClient {
|
|
||||||
|
|
||||||
@GetMapping("/{scenicId}/fields/enabled")
|
|
||||||
CommonResponse<EnabledFieldsResponse> getEnabledFields(@PathVariable("scenicId") Long scenicId);
|
|
||||||
|
|
||||||
@GetMapping("/fields/all")
|
|
||||||
CommonResponse<List<FieldConfigDTO>> getAllFields();
|
|
||||||
|
|
||||||
@GetMapping("/fields/{fieldKey}")
|
|
||||||
CommonResponse<FieldConfigDTO> getFieldConfig(@PathVariable("fieldKey") String fieldKey);
|
|
||||||
|
|
||||||
@PostMapping("/{scenicId}/fields/{fieldKey}/enabled")
|
|
||||||
CommonResponse<Void> setFieldEnabled(@PathVariable("scenicId") Long scenicId,
|
|
||||||
@PathVariable("fieldKey") String fieldKey,
|
|
||||||
@RequestBody SetFieldEnabledRequest request);
|
|
||||||
|
|
||||||
@PostMapping("/{scenicId}/fields/batch-enabled")
|
|
||||||
CommonResponse<Void> batchSetFieldEnabled(@PathVariable("scenicId") Long scenicId,
|
|
||||||
@RequestBody BatchSetFieldEnabledRequest request);
|
|
||||||
|
|
||||||
@GetMapping("/{scenicId}/with-config")
|
|
||||||
CommonResponse<ScenicV2WithConfigDTO> getScenicWithConfigEnhanced(@PathVariable("scenicId") Long scenicId);
|
|
||||||
|
|
||||||
@PutMapping("/{scenicId}/config")
|
|
||||||
CommonResponse<Void> updateConfigEnhanced(@PathVariable("scenicId") Long scenicId,
|
|
||||||
@RequestBody Map<String, Object> configs);
|
|
||||||
}
|
|
@@ -6,6 +6,8 @@ import com.ycwl.basic.integration.scenic.dto.filter.ScenicFilterRequest;
|
|||||||
import com.ycwl.basic.integration.scenic.dto.scenic.CreateScenicRequest;
|
import com.ycwl.basic.integration.scenic.dto.scenic.CreateScenicRequest;
|
||||||
import com.ycwl.basic.integration.scenic.dto.scenic.ScenicV2DTO;
|
import com.ycwl.basic.integration.scenic.dto.scenic.ScenicV2DTO;
|
||||||
import com.ycwl.basic.integration.scenic.dto.scenic.ScenicV2WithConfigDTO;
|
import com.ycwl.basic.integration.scenic.dto.scenic.ScenicV2WithConfigDTO;
|
||||||
|
import com.ycwl.basic.integration.scenic.dto.scenic.ScenicV2ListResponse;
|
||||||
|
import com.ycwl.basic.integration.scenic.dto.scenic.ScenicV2WithConfigListResponse;
|
||||||
import com.ycwl.basic.integration.scenic.dto.scenic.UpdateScenicRequest;
|
import com.ycwl.basic.integration.scenic.dto.scenic.UpdateScenicRequest;
|
||||||
import org.springframework.cloud.openfeign.FeignClient;
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
@@ -21,8 +23,6 @@ public interface ScenicV2Client {
|
|||||||
@GetMapping("/{scenicId}/with-config")
|
@GetMapping("/{scenicId}/with-config")
|
||||||
CommonResponse<ScenicV2WithConfigDTO> getScenicWithConfig(@PathVariable("scenicId") Long scenicId);
|
CommonResponse<ScenicV2WithConfigDTO> getScenicWithConfig(@PathVariable("scenicId") Long scenicId);
|
||||||
|
|
||||||
@GetMapping("/{scenicId}/flat")
|
|
||||||
CommonResponse<Map<String, Object>> getScenicFlatConfig(@PathVariable("scenicId") Long scenicId);
|
|
||||||
|
|
||||||
@PostMapping("/")
|
@PostMapping("/")
|
||||||
CommonResponse<ScenicV2DTO> createScenic(@RequestBody CreateScenicRequest request);
|
CommonResponse<ScenicV2DTO> createScenic(@RequestBody CreateScenicRequest request);
|
||||||
@@ -36,4 +36,16 @@ public interface ScenicV2Client {
|
|||||||
|
|
||||||
@PostMapping("/filter")
|
@PostMapping("/filter")
|
||||||
CommonResponse<ScenicFilterPageResponse> filterScenics(@RequestBody ScenicFilterRequest request);
|
CommonResponse<ScenicFilterPageResponse> filterScenics(@RequestBody ScenicFilterRequest request);
|
||||||
|
|
||||||
|
@GetMapping("/")
|
||||||
|
CommonResponse<ScenicV2ListResponse> listScenics(@RequestParam(defaultValue = "1") Integer page,
|
||||||
|
@RequestParam(defaultValue = "10") Integer pageSize,
|
||||||
|
@RequestParam(required = false) Integer status,
|
||||||
|
@RequestParam(required = false) String name);
|
||||||
|
|
||||||
|
@GetMapping("/with-config")
|
||||||
|
CommonResponse<ScenicV2WithConfigListResponse> listScenicsWithConfig(@RequestParam(defaultValue = "1") Integer page,
|
||||||
|
@RequestParam(defaultValue = "10") Integer pageSize,
|
||||||
|
@RequestParam(required = false) Integer status,
|
||||||
|
@RequestParam(required = false) String name);
|
||||||
}
|
}
|
@@ -1,16 +0,0 @@
|
|||||||
package com.ycwl.basic.integration.scenic.dto.config;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class ConfigWithDefaultResponse {
|
|
||||||
@JsonProperty("configKey")
|
|
||||||
private String configKey;
|
|
||||||
|
|
||||||
@JsonProperty("configValue")
|
|
||||||
private String configValue;
|
|
||||||
|
|
||||||
@JsonProperty("source")
|
|
||||||
private String source;
|
|
||||||
}
|
|
@@ -1,26 +0,0 @@
|
|||||||
package com.ycwl.basic.integration.scenic.dto.meta;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import jakarta.validation.Valid;
|
|
||||||
import jakarta.validation.constraints.NotEmpty;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class BatchSetFieldEnabledRequest {
|
|
||||||
@JsonProperty("fields")
|
|
||||||
@NotEmpty(message = "字段列表不能为空")
|
|
||||||
@Valid
|
|
||||||
private List<FieldEnabledItem> fields;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public static class FieldEnabledItem {
|
|
||||||
@JsonProperty("fieldKey")
|
|
||||||
@NotEmpty(message = "字段键不能为空")
|
|
||||||
private String fieldKey;
|
|
||||||
|
|
||||||
@JsonProperty("enabled")
|
|
||||||
private Boolean enabled;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,12 +0,0 @@
|
|||||||
package com.ycwl.basic.integration.scenic.dto.meta;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class EnabledFieldsResponse {
|
|
||||||
@JsonProperty("enabledFields")
|
|
||||||
private List<String> enabledFields;
|
|
||||||
}
|
|
@@ -1,22 +0,0 @@
|
|||||||
package com.ycwl.basic.integration.scenic.dto.meta;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class FieldConfigDTO {
|
|
||||||
@JsonProperty("fieldKey")
|
|
||||||
private String fieldKey;
|
|
||||||
|
|
||||||
@JsonProperty("fieldName")
|
|
||||||
private String fieldName;
|
|
||||||
|
|
||||||
@JsonProperty("fieldType")
|
|
||||||
private String fieldType;
|
|
||||||
|
|
||||||
@JsonProperty("description")
|
|
||||||
private String description;
|
|
||||||
|
|
||||||
@JsonProperty("enabled")
|
|
||||||
private Boolean enabled;
|
|
||||||
}
|
|
@@ -1,13 +0,0 @@
|
|||||||
package com.ycwl.basic.integration.scenic.dto.meta;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import jakarta.validation.constraints.NotNull;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class SetFieldEnabledRequest {
|
|
||||||
@JsonProperty("enabled")
|
|
||||||
@NotNull(message = "enabled状态不能为空")
|
|
||||||
private Boolean enabled;
|
|
||||||
}
|
|
@@ -0,0 +1,21 @@
|
|||||||
|
package com.ycwl.basic.integration.scenic.dto.scenic;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ScenicV2ListResponse {
|
||||||
|
@JsonProperty("list")
|
||||||
|
private List<ScenicV2DTO> list;
|
||||||
|
|
||||||
|
@JsonProperty("total")
|
||||||
|
private Long total;
|
||||||
|
|
||||||
|
@JsonProperty("page")
|
||||||
|
private Integer page;
|
||||||
|
|
||||||
|
@JsonProperty("pageSize")
|
||||||
|
private Integer pageSize;
|
||||||
|
}
|
@@ -0,0 +1,21 @@
|
|||||||
|
package com.ycwl.basic.integration.scenic.dto.scenic;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ScenicV2WithConfigListResponse {
|
||||||
|
@JsonProperty("list")
|
||||||
|
private List<ScenicV2WithConfigDTO> list;
|
||||||
|
|
||||||
|
@JsonProperty("total")
|
||||||
|
private Long total;
|
||||||
|
|
||||||
|
@JsonProperty("page")
|
||||||
|
private Integer page;
|
||||||
|
|
||||||
|
@JsonProperty("pageSize")
|
||||||
|
private Integer pageSize;
|
||||||
|
}
|
@@ -3,7 +3,6 @@ package com.ycwl.basic.integration.scenic.service;
|
|||||||
import com.ycwl.basic.integration.common.exception.IntegrationException;
|
import com.ycwl.basic.integration.common.exception.IntegrationException;
|
||||||
import com.ycwl.basic.integration.common.response.CommonResponse;
|
import com.ycwl.basic.integration.common.response.CommonResponse;
|
||||||
import com.ycwl.basic.integration.scenic.client.ScenicConfigV2Client;
|
import com.ycwl.basic.integration.scenic.client.ScenicConfigV2Client;
|
||||||
import com.ycwl.basic.integration.scenic.client.ScenicConfigWithDefaultClient;
|
|
||||||
import com.ycwl.basic.integration.scenic.dto.config.*;
|
import com.ycwl.basic.integration.scenic.dto.config.*;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@@ -18,7 +17,6 @@ import java.util.Map;
|
|||||||
public class ScenicConfigIntegrationService {
|
public class ScenicConfigIntegrationService {
|
||||||
|
|
||||||
private final ScenicConfigV2Client scenicConfigV2Client;
|
private final ScenicConfigV2Client scenicConfigV2Client;
|
||||||
private final ScenicConfigWithDefaultClient scenicConfigWithDefaultClient;
|
|
||||||
|
|
||||||
public List<ScenicConfigV2DTO> listConfigs(Long scenicId) {
|
public List<ScenicConfigV2DTO> listConfigs(Long scenicId) {
|
||||||
log.info("获取景区配置列表, scenicId: {}", scenicId);
|
log.info("获取景区配置列表, scenicId: {}", scenicId);
|
||||||
@@ -68,11 +66,6 @@ public class ScenicConfigIntegrationService {
|
|||||||
return handleResponse(response, "扁平化批量更新景区配置失败");
|
return handleResponse(response, "扁平化批量更新景区配置失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConfigWithDefaultResponse getConfigWithDefault(Long scenicId, String configKey) {
|
|
||||||
log.info("获取带默认值的配置, scenicId: {}, configKey: {}", scenicId, configKey);
|
|
||||||
CommonResponse<ConfigWithDefaultResponse> response = scenicConfigWithDefaultClient.getConfigWithDefault(scenicId, configKey);
|
|
||||||
return handleResponse(response, "获取带默认值的配置失败");
|
|
||||||
}
|
|
||||||
|
|
||||||
private <T> T handleResponse(CommonResponse<T> response, String errorMessage) {
|
private <T> T handleResponse(CommonResponse<T> response, String errorMessage) {
|
||||||
if (response == null || !response.isSuccess()) {
|
if (response == null || !response.isSuccess()) {
|
||||||
|
@@ -9,6 +9,8 @@ import com.ycwl.basic.integration.scenic.dto.filter.ScenicFilterRequest;
|
|||||||
import com.ycwl.basic.integration.scenic.dto.scenic.CreateScenicRequest;
|
import com.ycwl.basic.integration.scenic.dto.scenic.CreateScenicRequest;
|
||||||
import com.ycwl.basic.integration.scenic.dto.scenic.ScenicV2DTO;
|
import com.ycwl.basic.integration.scenic.dto.scenic.ScenicV2DTO;
|
||||||
import com.ycwl.basic.integration.scenic.dto.scenic.ScenicV2WithConfigDTO;
|
import com.ycwl.basic.integration.scenic.dto.scenic.ScenicV2WithConfigDTO;
|
||||||
|
import com.ycwl.basic.integration.scenic.dto.scenic.ScenicV2ListResponse;
|
||||||
|
import com.ycwl.basic.integration.scenic.dto.scenic.ScenicV2WithConfigListResponse;
|
||||||
import com.ycwl.basic.integration.scenic.dto.scenic.UpdateScenicRequest;
|
import com.ycwl.basic.integration.scenic.dto.scenic.UpdateScenicRequest;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@@ -66,6 +68,18 @@ public class ScenicIntegrationService {
|
|||||||
return handleResponse(response, "筛选景区失败");
|
return handleResponse(response, "筛选景区失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ScenicV2ListResponse listScenics(Integer page, Integer pageSize, Integer status, String name) {
|
||||||
|
log.info("分页查询景区列表, page: {}, pageSize: {}, status: {}, name: {}", page, pageSize, status, name);
|
||||||
|
CommonResponse<ScenicV2ListResponse> response = scenicV2Client.listScenics(page, pageSize, status, name);
|
||||||
|
return handleResponse(response, "分页查询景区列表失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
public ScenicV2WithConfigListResponse listScenicsWithConfig(Integer page, Integer pageSize, Integer status, String name) {
|
||||||
|
log.info("分页查询景区带配置列表, page: {}, pageSize: {}, status: {}, name: {}", page, pageSize, status, name);
|
||||||
|
CommonResponse<ScenicV2WithConfigListResponse> response = scenicV2Client.listScenicsWithConfig(page, pageSize, status, name);
|
||||||
|
return handleResponse(response, "分页查询景区带配置列表失败");
|
||||||
|
}
|
||||||
|
|
||||||
private <T> T handleResponse(CommonResponse<T> response, String errorMessage) {
|
private <T> T handleResponse(CommonResponse<T> response, String errorMessage) {
|
||||||
if (response == null || !response.isSuccess()) {
|
if (response == null || !response.isSuccess()) {
|
||||||
String msg = response != null && response.getMessage() != null
|
String msg = response != null && response.getMessage() != null
|
||||||
|
@@ -1,76 +0,0 @@
|
|||||||
package com.ycwl.basic.integration.scenic.service;
|
|
||||||
|
|
||||||
import com.ycwl.basic.integration.common.exception.IntegrationException;
|
|
||||||
import com.ycwl.basic.integration.common.response.CommonResponse;
|
|
||||||
import com.ycwl.basic.integration.scenic.client.ScenicMetaClient;
|
|
||||||
import com.ycwl.basic.integration.scenic.dto.meta.*;
|
|
||||||
import com.ycwl.basic.integration.scenic.dto.scenic.ScenicV2WithConfigDTO;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
@Slf4j
|
|
||||||
@Service
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
public class ScenicMetaIntegrationService {
|
|
||||||
|
|
||||||
private final ScenicMetaClient scenicMetaClient;
|
|
||||||
|
|
||||||
public EnabledFieldsResponse getEnabledFields(Long scenicId) {
|
|
||||||
log.info("获取启用的字段, scenicId: {}", scenicId);
|
|
||||||
CommonResponse<EnabledFieldsResponse> response = scenicMetaClient.getEnabledFields(scenicId);
|
|
||||||
return handleResponse(response, "获取启用的字段失败");
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<FieldConfigDTO> getAllFields() {
|
|
||||||
log.info("获取所有字段配置");
|
|
||||||
CommonResponse<List<FieldConfigDTO>> response = scenicMetaClient.getAllFields();
|
|
||||||
return handleResponse(response, "获取所有字段配置失败");
|
|
||||||
}
|
|
||||||
|
|
||||||
public FieldConfigDTO getFieldConfig(String fieldKey) {
|
|
||||||
log.info("获取字段配置, fieldKey: {}", fieldKey);
|
|
||||||
CommonResponse<FieldConfigDTO> response = scenicMetaClient.getFieldConfig(fieldKey);
|
|
||||||
return handleResponse(response, "获取字段配置失败");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFieldEnabled(Long scenicId, String fieldKey, Boolean enabled) {
|
|
||||||
log.info("设置字段启用状态, scenicId: {}, fieldKey: {}, enabled: {}", scenicId, fieldKey, enabled);
|
|
||||||
SetFieldEnabledRequest request = new SetFieldEnabledRequest();
|
|
||||||
request.setEnabled(enabled);
|
|
||||||
CommonResponse<Void> response = scenicMetaClient.setFieldEnabled(scenicId, fieldKey, request);
|
|
||||||
handleResponse(response, "设置字段启用状态失败");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void batchSetFieldEnabled(Long scenicId, BatchSetFieldEnabledRequest request) {
|
|
||||||
log.info("批量设置字段启用状态, scenicId: {}, fields count: {}", scenicId, request.getFields().size());
|
|
||||||
CommonResponse<Void> response = scenicMetaClient.batchSetFieldEnabled(scenicId, request);
|
|
||||||
handleResponse(response, "批量设置字段启用状态失败");
|
|
||||||
}
|
|
||||||
|
|
||||||
public ScenicV2WithConfigDTO getScenicWithConfigEnhanced(Long scenicId) {
|
|
||||||
log.info("获取景区与配置(增强版), scenicId: {}", scenicId);
|
|
||||||
CommonResponse<ScenicV2WithConfigDTO> response = scenicMetaClient.getScenicWithConfigEnhanced(scenicId);
|
|
||||||
return handleResponse(response, "获取景区与配置(增强版)失败");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void updateConfigEnhanced(Long scenicId, Map<String, Object> configs) {
|
|
||||||
log.info("更新配置(增强版), scenicId: {}, configs count: {}", scenicId, configs.size());
|
|
||||||
CommonResponse<Void> response = scenicMetaClient.updateConfigEnhanced(scenicId, configs);
|
|
||||||
handleResponse(response, "更新配置(增强版)失败");
|
|
||||||
}
|
|
||||||
|
|
||||||
private <T> T handleResponse(CommonResponse<T> response, String errorMessage) {
|
|
||||||
if (response == null || !response.isSuccess()) {
|
|
||||||
String msg = response != null && response.getMessage() != null
|
|
||||||
? response.getMessage()
|
|
||||||
: errorMessage;
|
|
||||||
Integer code = response != null ? response.getCode() : 5000;
|
|
||||||
throw new IntegrationException(code, msg, "zt-scenic");
|
|
||||||
}
|
|
||||||
return response.getData();
|
|
||||||
}
|
|
||||||
}
|
|
Reference in New Issue
Block a user