009_DI-Elec/newFront/c#前端/SWS.Service/DrawingCatalogueService.cs
2025-08-15 15:36:40 +08:00

67 lines
2.0 KiB
C#

using System;
using System.Threading.Tasks;
using SWS.Commons;
using SWS.Model;
namespace SWS.Service
{
public class DrawingCatalogueService : HttpService
{
public DrawingCatalogueService() : base()
{
}
/// <summary>
/// 根据ID获取图纸目录信息
/// </summary>
/// <param name="drawingCatalogueID">图纸文件ID</param>
/// <returns></returns>
public async Task<ec_drawing_catalogue> GetEntity(string drawingCatalogueID)
{
var url = $"DrawingCatalogueApi/GetEntity?projectId={GlobalObject.curProject.ProjectId}&drawingCatalogueID={drawingCatalogueID}";
try
{
var res = await this.GetAsync<ec_drawing_catalogue>(url);
if (res.code == 200)
{
return res.data;
}
else
{
return null;
}
}
catch (Exception ex)
{
string errorMsg = $"接口:{url}失败,异常:{ex.Message} ";
LoggerHelper.Current.Error(errorMsg);
return null;
}
}
public async Task<string> EditDrawingCatalogue(ec_drawing_catalogue entity)
{
var url = $"DrawingCatalogueApi/EditDrawingCatalogue?projectId={GlobalObject.curProject.ProjectId}";
try
{
var res = await this.PostBodyAsync<ec_drawing_catalogue, ec_drawing_catalogue>(url, entity);
if (res.code == 200 && res.info.Contains("成功"))
{
return "";
}
else
{
return res.info;
}
}
catch (Exception ex)
{
string errorMsg = $"接口:{url}失败,异常:{ex.Message} ";
LoggerHelper.Current.Error(errorMsg);
return errorMsg;
}
}
}
}