Tz2/Assets/Zion/Scripts/ERP/Interfaces/ApiUrls.cs

140 lines
5.6 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using DefaultNamespace;
using MotionFramework;
using System.Collections.Generic;
using UnityEngine;
namespace Zion.ERP.Inventory
{
/// <summary>
/// API接口配置类
/// 支持配置化管理和动态参数替换
/// </summary>
public static class ApiUrls
{
/// <summary>
/// 获取API接口URL使用配置系统
/// </summary>
/// <param name="endpointName">接口名称</param>
/// <param name="dynamicParams">动态参数</param>
/// <returns>完整的URL</returns>
public static string GetApiUrl(string endpointName, Dictionary<string, string> dynamicParams = null)
{
var configManager = MotionEngine.GetModule<ApiConfigManager>();
if (configManager != null && configManager.IsInitialized)
{
return configManager.GetApiUrl(endpointName, dynamicParams);
}
// else
// {
// Debug.LogWarning("API配置管理器未初始化使用备用方案");
// return GetLegacyApiUrl(endpointName);
// }
return "";
}
/// <summary>
/// 获取API接口配置
/// </summary>
/// <param name="endpointName">接口名称</param>
/// <returns>API接口配置</returns>
public static ApiEndpoint GetEndpoint(string endpointName)
{
try
{
var configManager = MotionEngine.GetModule<ApiConfigManager>();
return configManager?.GetEndpoint(endpointName);
}
catch (System.Exception ex)
{
Debug.LogError($"获取API配置失败{ex.Message}");
return null;
}
}
// /// <summary>
// /// 备用方案使用原有的硬编码方式获取URL
// /// </summary>
// /// <param name="endpointName">接口名称</param>
// /// <returns>URL</returns>
// private static string GetLegacyApiUrl(string endpointName)
// {
// // 从 GlobalDataStorage 中获取 IP 地址和端口
// string ipAddress = MotionEngine.GetModule<GlobalDataStorage>()?.ExamInfo?.IpAddress ?? "172.16.1.127:8080";
// string paperId = MotionEngine.GetModule<GlobalDataStorage>()?.ExamInfo?.PaperId ?? "";
// string baseUrl = $"http://{ipAddress}";
//
// switch (endpointName)
// {
// case "GetProSimulationExaminationQueryById":
// return $"{baseUrl}/member/proSimulationExamination/queryById?id={paperId}";
// case "AddSubmitDetail":
// return $"{baseUrl}/member/pro/simulationStepRecord/addSubmitDetail";
// case "UploadFileAndParam":
// return $"{baseUrl}/member/pro/upload/uploadFileAndParam";
// case "Get3DCourse":
// return $"{baseUrl}/member/proSimulationCourse/queryByOutId?id={paperId}";
// case "GetErrorFeedbackContractExecutionData":
// return "http://172.16.1.127:9000/file/biaodan/合同执行情况数据反馈_1行.xlsx";
// case "GetOKFeedbackContractExecutionData":
// return "http://172.16.1.127:9000/file/biaodan/合同执行情况数据反馈_8行.xlsx";
// case "GetWarehouseRegMasterOpsDataCard":
// return "http://172.16.1.127:9000/file/biaodan/新注册仓库的主数据运维流程答题卡.xlsx";
// default:
// Debug.LogError($"未找到API接口{endpointName}");
// return "";
// }
// }
/// <summary>
/// 中转库存相关API接口
/// 保持向后兼容性
/// </summary>
public static class TransitInventory
{
/// <summary>
/// 异常合同执行情况数据反馈_1行
/// </summary>
public static string GetErrorFeedbackContractExecutionData => GetApiUrl("GetErrorFeedbackContractExecutionData");
/// <summary>
/// 正确合同执行情况数据反馈_8行
/// </summary>
public static string GetOKFeedbackContractExecutionData => GetApiUrl("GetOKFeedbackContractExecutionData");
/// <summary>
/// 新注册仓库的主数据运维流程答题卡
/// </summary>
public static string GetWarehouseRegMasterOpsDataCard => GetApiUrl("GetWarehouseRegMasterOpsDataCard");
/// <summary>
/// 获取任务书和流程
/// </summary>
public static string GetProSimulationExaminationQueryById => GetApiUrl("GetProSimulationExaminationQueryById");
/// <summary>
/// 上传考试信息
/// </summary>
public static string AddSubmitDetail => GetApiUrl("AddSubmitDetail");
/// <summary>
/// 上传文件
/// </summary>
public static string UploadFileAndParam => GetApiUrl("UploadFileAndParam");
/// <summary>
/// 获取学习试题
/// </summary>
public static string GetLearningTest => GetApiUrl("GetLearningTest");
/// <summary>
/// 获取学习试题
/// </summary>
public static string GetLearningTestIsView => GetApiUrl("GetLearningTestIsView");
/// <summary>
/// 获取三维课程
/// </summary>
public static string Get3DCourse => GetApiUrl("Get3DCourse");
}
}
}