From 47470096178248af6c49f35c3e4166ca7d6884d0 Mon Sep 17 00:00:00 2001 From: bairubing Date: Wed, 16 Oct 2024 13:33:54 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=98=8E=E6=96=B0=E5=A2=9ESOLIDWORKS=20Mana?= =?UTF-8?q?ge=20=E8=8E=B7=E5=8F=96=20token=E3=80=81=E5=88=9B=E5=BB=BA?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E6=9C=8D=E5=8A=A1=E3=80=81=E6=96=B0=E5=A2=9E?= =?UTF-8?q?SAP=E5=88=9B=E5=BB=BA=E3=80=81=E4=BF=AE=E6=94=B9=E5=AE=A2?= =?UTF-8?q?=E6=88=B7=E6=A1=A3=E6=A1=88=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Vistar.Application/Entity/Obj132.cs | 274 ++++++++++++++++++ .../Dto/CreateClientRecordInput.cs | 40 +++ .../SapOpenInterfaceService.cs | 102 +++++++ .../Dto/AuthorizationResponse.cs | 22 ++ .../Dto/CreateRecordInput.cs | 25 ++ .../Dto/ManageResponse.cs | 21 ++ .../SolidWorksManageService.cs | 117 ++++++++ 7 files changed, 601 insertions(+) create mode 100644 admin.net.pro/Admin.NET/Vistar.Application/Entity/Obj132.cs create mode 100644 admin.net.pro/Admin.NET/Vistar.Application/Service/SapOpenInterface/Dto/CreateClientRecordInput.cs create mode 100644 admin.net.pro/Admin.NET/Vistar.Application/Service/SapOpenInterface/SapOpenInterfaceService.cs create mode 100644 admin.net.pro/Admin.NET/Vistar.Application/SolidWorksManageService/Dto/AuthorizationResponse.cs create mode 100644 admin.net.pro/Admin.NET/Vistar.Application/SolidWorksManageService/Dto/CreateRecordInput.cs create mode 100644 admin.net.pro/Admin.NET/Vistar.Application/SolidWorksManageService/Dto/ManageResponse.cs create mode 100644 admin.net.pro/Admin.NET/Vistar.Application/SolidWorksManageService/SolidWorksManageService.cs diff --git a/admin.net.pro/Admin.NET/Vistar.Application/Entity/Obj132.cs b/admin.net.pro/Admin.NET/Vistar.Application/Entity/Obj132.cs new file mode 100644 index 0000000..cb80cb9 --- /dev/null +++ b/admin.net.pro/Admin.NET/Vistar.Application/Entity/Obj132.cs @@ -0,0 +1,274 @@ +// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 +// +// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 +// +// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! + +using Admin.NET.Core; +using SqlSugar; +using System.ComponentModel.DataAnnotations; +namespace Vistar.Application.Entity; + +/// +/// +/// +[SugarTable("OBJ132","")] +[Tenant("启威星 1.94.4.74")] +public class Obj132 +{ + /// + /// + /// + [Required] + [SugarColumn(ColumnName = "idRecord", IsIdentity = true, ColumnDescription = "", IsPrimaryKey = true)] + public long idRecord { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "CheckedStatus", ColumnDescription = "")] + public bool? CheckedStatus { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "VersionIndex", ColumnDescription = "")] + public int? VersionIndex { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "IsLatestVersion", ColumnDescription = "")] + public bool? IsLatestVersion { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "CreatedDate", ColumnDescription = "")] + public DateTime? CreatedDate { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "VersionCreatedDate", ColumnDescription = "")] + public DateTime? VersionCreatedDate { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "dateModified", ColumnDescription = "")] + public DateTime? dateModified { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "UserCreatedId", ColumnDescription = "")] + public long? UserCreatedId { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "VersionUserCreatedId", ColumnDescription = "")] + public long? VersionUserCreatedId { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "UserModifiedId", ColumnDescription = "")] + public long? UserModifiedId { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "RecordGuid", ColumnDescription = "", Length = 40)] + public string? RecordGuid { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "isVisibilityNormal", ColumnDescription = "")] + public bool? isVisibilityNormal { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "deleted", ColumnDescription = "")] + public bool? deleted { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "SubObjectGuid", ColumnDescription = "", Length = 40)] + public string? SubObjectGuid { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "PreviousStatus", ColumnDescription = "")] + public bool? PreviousStatus { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "revision", ColumnDescription = "", Length = 10)] + public string? revision { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "Record_image160_160", ColumnDescription = "")] + public byte[]? Record_image160_160 { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "Record_Image320_240", ColumnDescription = "")] + public byte[]? Record_Image320_240 { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "Record_ImageMax", ColumnDescription = "")] + public byte[]? Record_ImageMax { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "_System_objNBS", ColumnDescription = "", Length = 100)] + public string? _System_objNBS { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "_System_ObjDescription", ColumnDescription = "", Length = 200)] + public string? _System_ObjDescription { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "_System_Effectivity_Begin", ColumnDescription = "")] + public DateTime? _System_Effectivity_Begin { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "_System_Effectivity_End", ColumnDescription = "")] + public DateTime? _System_Effectivity_End { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "CheckedOutPc", ColumnDescription = "", Length = 255)] + public string? CheckedOutPc { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "GroupObjId", ColumnDescription = "")] + public long? GroupObjId { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "_CheckOutInProgress", ColumnDescription = "")] + public bool? _CheckOutInProgress { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "EnableNotifications", ColumnDescription = "")] + public bool? EnableNotifications { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "_system_objConfigurationName", ColumnDescription = "", Length = 255)] + public string? _system_objConfigurationName { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "_system_objConfigurationType", ColumnDescription = "")] + public bool? _system_objConfigurationType { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "_system_objConfigurationGuid", ColumnDescription = "", Length = 40)] + public string? _system_objConfigurationGuid { get; set; } + + /// + /// + /// + [Required] + [SugarColumn(ColumnName = "ShowBomFromConfiguration", ColumnDescription = "", Length = 250)] + public string ShowBomFromConfiguration { get; set; } + + /// + /// + /// + [Required] + [SugarColumn(ColumnName = "_System_ObjNbsAuto", ColumnDescription = "", Length = 50)] + public string _System_ObjNbsAuto { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "_System_DerivedFrom", ColumnDescription = "", Length = 50)] + public string? _System_DerivedFrom { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "_System_DerivedFrom_RecordGuid", ColumnDescription = "", Length = 50)] + public string? _System_DerivedFrom_RecordGuid { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "_system_objLinkedCompare", ColumnDescription = "")] + public bool? _system_objLinkedCompare { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "isReleasedVersion", ColumnDescription = "")] + public bool? isReleasedVersion { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "_System_WebLink", ColumnDescription = "", Length = 500)] + public string? _System_WebLink { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "LinkDrw", ColumnDescription = "")] + public bool? LinkDrw { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "ParentRecordGuid", ColumnDescription = "", Length = 40)] + public string? ParentRecordGuid { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "fld004807", ColumnDescription = "", Length = -1)] + public string? fld004807 { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "fld004808", ColumnDescription = "", Length = -1)] + public string? fld004808 { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "fld004950", ColumnDescription = "", Length = -1)] + public string? fld004950 { get; set; } + +} diff --git a/admin.net.pro/Admin.NET/Vistar.Application/Service/SapOpenInterface/Dto/CreateClientRecordInput.cs b/admin.net.pro/Admin.NET/Vistar.Application/Service/SapOpenInterface/Dto/CreateClientRecordInput.cs new file mode 100644 index 0000000..837a8df --- /dev/null +++ b/admin.net.pro/Admin.NET/Vistar.Application/Service/SapOpenInterface/Dto/CreateClientRecordInput.cs @@ -0,0 +1,40 @@ +// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 +// +// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 +// +// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Vistar.Application.Service.SapOpenInterface.Dto; +public class CreateClientRecordInput +{ + /// + /// 标识 新增或修改 + /// + public string actionType { get; set; } + + /// + /// 客户编码 + /// + public string _System_objNBS { get; set; } + + /// + /// 客户名称 + /// + public string _System_objDescription { get; set; } + + /// + /// 客户简介 + /// + public string fld004808 { get; set; } + + /// + /// 注册地址 + /// + public string fld004950 { get; set; } +} diff --git a/admin.net.pro/Admin.NET/Vistar.Application/Service/SapOpenInterface/SapOpenInterfaceService.cs b/admin.net.pro/Admin.NET/Vistar.Application/Service/SapOpenInterface/SapOpenInterfaceService.cs new file mode 100644 index 0000000..f811627 --- /dev/null +++ b/admin.net.pro/Admin.NET/Vistar.Application/Service/SapOpenInterface/SapOpenInterfaceService.cs @@ -0,0 +1,102 @@ +// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 +// +// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 +// +// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! + +using Admin.NET.Core; +using Furion.DependencyInjection; +using Furion.DynamicApiController; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Vistar.Application.Const; +using Vistar.Application.Entity; +using Vistar.Application.Service.SapOpenInterface.Dto; +using Vistar.Application.SolidWorksManageService.Dto; +using static SKIT.FlurlHttpClient.Wechat.Api.Models.ComponentTCBBatchCreateContainerServiceVersionResponse.Types; + +namespace Vistar.Application.Service.SapOpenInterface; +/// +/// 开放接口给Sap +/// +[ApiDescriptionSettings(ApplicationConst.GroupName, Name = "SapOpenInterface", Order = 100)] +public class SapOpenInterfaceService : IDynamicApiController, ITransient +{ + public SqlSugarRepository _obj132Rep; + public SolidWorksManageService.SolidWorksManageService _solidWorksManageService; + public SapOpenInterfaceService(SqlSugarRepository obj132Rep, SolidWorksManageService.SolidWorksManageService solidWorksManageService) + { + _obj132Rep = obj132Rep; + _solidWorksManageService = solidWorksManageService; + } + /// + /// SAP创建、修改客户档案 + /// + /// + /// + [Authorize(AuthenticationSchemes = SignatureAuthenticationDefaults.AuthenticationScheme)] + [ApiDescriptionSettings(Name = "CreateClientRecord"), HttpPost] + [DisplayName("SAP创建、修改客户档案")] + public async Task CreateClientRecord(CreateClientRecordInput input) + { + var response = new ManageResponse(); + + if (string.IsNullOrWhiteSpace(input._System_objNBS) || string.IsNullOrWhiteSpace(input._System_objDescription) || string.IsNullOrWhiteSpace(input.actionType)) + { + response.Success = true; + response.Message = "请输入必填字段"; + return response; + } + + if (input.actionType == "新增") + { + var fieldList = new List(); + + fieldList.Add(new Field { key = "_System_objNBS", value = input._System_objNBS }); + fieldList.Add(new Field { key = "_System_objDescription", value = input._System_objDescription }); + + if (!string.IsNullOrWhiteSpace(input.fld004808)) + { + fieldList.Add(new Field { key = "fld004808", value = input.fld004808 }); + } + + if (!string.IsNullOrWhiteSpace(input.fld004950)) + { + fieldList.Add(new Field { key = "fld004950", value = input.fld004950 }); + } + + var data = new CreateRecordInput + { + object_id = 132, + field_group_id = 422, + fields = fieldList + }; + response= await _solidWorksManageService.CreateRecord(data); + return response; + } + else if (input.actionType == "修改") + { + var updateable = await _obj132Rep.AsUpdateable() + .SetColumns(it => new Obj132 + { + _System_ObjDescription = input._System_objDescription, + fld004808 = input.fld004808, + fld004950 = input.fld004950 + }) + .Where(x => x._System_objNBS == input._System_objNBS) + .ExecuteCommandHasChangeAsync(); + + response.Success = true; + response.Message = updateable ? "修改成功" : "修改失败"; + return response; + } + + return response; + } +} diff --git a/admin.net.pro/Admin.NET/Vistar.Application/SolidWorksManageService/Dto/AuthorizationResponse.cs b/admin.net.pro/Admin.NET/Vistar.Application/SolidWorksManageService/Dto/AuthorizationResponse.cs new file mode 100644 index 0000000..a2d8dc4 --- /dev/null +++ b/admin.net.pro/Admin.NET/Vistar.Application/SolidWorksManageService/Dto/AuthorizationResponse.cs @@ -0,0 +1,22 @@ +// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 +// +// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 +// +// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Vistar.Application.SolidWorksManageService.Dto; +public class AuthorizationResponse +{ + public string access_token { get; set; } + public DateTime expires_in { get; set; } + public string token_type { get; set; } + public string raw_claim { get; set; } + public bool success { get; set; } + public string message { get; set; } +} diff --git a/admin.net.pro/Admin.NET/Vistar.Application/SolidWorksManageService/Dto/CreateRecordInput.cs b/admin.net.pro/Admin.NET/Vistar.Application/SolidWorksManageService/Dto/CreateRecordInput.cs new file mode 100644 index 0000000..0d37d77 --- /dev/null +++ b/admin.net.pro/Admin.NET/Vistar.Application/SolidWorksManageService/Dto/CreateRecordInput.cs @@ -0,0 +1,25 @@ +// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 +// +// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 +// +// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Vistar.Application.SolidWorksManageService.Dto; +public class CreateRecordInput +{ + public long object_id { get; set; } + public long field_group_id { get; set; } + public List fields { get; set; } +} + +public class Field +{ + public string key { get; set; } + public string value { get; set; } +} diff --git a/admin.net.pro/Admin.NET/Vistar.Application/SolidWorksManageService/Dto/ManageResponse.cs b/admin.net.pro/Admin.NET/Vistar.Application/SolidWorksManageService/Dto/ManageResponse.cs new file mode 100644 index 0000000..d768f79 --- /dev/null +++ b/admin.net.pro/Admin.NET/Vistar.Application/SolidWorksManageService/Dto/ManageResponse.cs @@ -0,0 +1,21 @@ +// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 +// +// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 +// +// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Vistar.Application.SolidWorksManageService.Dto; +public class ManageResponse +{ + public bool Success { get; set; } + public string Message { get; set; } + public object Data { get; set; } + public object CustomAction { get; set; } + public object CustomAttributes { get; set; } +} diff --git a/admin.net.pro/Admin.NET/Vistar.Application/SolidWorksManageService/SolidWorksManageService.cs b/admin.net.pro/Admin.NET/Vistar.Application/SolidWorksManageService/SolidWorksManageService.cs new file mode 100644 index 0000000..f30bc11 --- /dev/null +++ b/admin.net.pro/Admin.NET/Vistar.Application/SolidWorksManageService/SolidWorksManageService.cs @@ -0,0 +1,117 @@ +using Admin.NET.Core; +using Admin.NET.Core.Service; +using Furion.DependencyInjection; +using Furion.DynamicApiController; +using Microsoft.Extensions.Caching.Memory; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Reflection.Metadata; +using System.Text; +using System.Threading.Tasks; +using Vistar.Application.SolidWorksManageService.Dto; + +namespace Vistar.Application.SolidWorksManageService; +/// +/// SolidWorksManage服务 +/// +public class SolidWorksManageService : IDynamicApiController, ITransient +{ + private static readonly HttpClient client = new HttpClient(); + private readonly SysConfigService _sysConfigService; + public SolidWorksManageService(SysConfigService sysConfigService) + { + _sysConfigService = sysConfigService; + } + /// + /// 获取 token + /// + /// 授权响应对象 + public async Task Authenticate() + { + // 获取 SolidWorksManage 地址 + string apiUrl = await _sysConfigService.GetConfigValueByCode(ConfigConst.SolidWorksManageApiUrl); + // 拼接接口地址 + string url = $"{apiUrl}/api/Authentication/Authenticate"; + + // 构建请求参数字典 + var parameter = new Dictionary + { + ["username"] = await _sysConfigService.GetConfigValueByCode(ConfigConst.SolidWorksManageUserName), + ["password"] = await _sysConfigService.GetConfigValueByCode(ConfigConst.SolidWorksManagePassword), + ["licenseId"] = await _sysConfigService.GetConfigValueByCode(ConfigConst.SolidWorksManageLicenseId), + ["apikey"] = await _sysConfigService.GetConfigValueByCode(ConfigConst.SolidWorksManageApiKey) + }; + + // 将请求参数格式化为 URL 格式的字符串 + var formattingParameter = string.Join("&", parameter.Select(kvp => $"{Uri.EscapeDataString(kvp.Key)}={Uri.EscapeDataString(kvp.Value)}")); + // 构建完整的请求 URL + var requestUrl = $"{url}?{formattingParameter}"; + + // 使用 using 语句确保 HttpResponseMessage 资源被正确释放 + using (var response = await client.PostAsync(requestUrl, null)) + { + if (response.IsSuccessStatusCode) + { + // 读取响应内容并反序列化为授权响应对象 + string responseBody = await response.Content.ReadAsStringAsync(); + return JsonConvert.DeserializeObject(responseBody); + } + else + { + // 读取响应内容并反序列化为授权响应对象(通常表示请求失败,但这里也尝试反序列化以便进一步处理错误) + string responseBody = await response.Content.ReadAsStringAsync(); + return JsonConvert.DeserializeObject(responseBody); + } + } + } + /// + /// 创建记录 + /// + /// + /// + public async Task CreateRecord(CreateRecordInput input) + { + // 获取 SolidWorksManage 地址 + string apiUrl = await _sysConfigService.GetConfigValueByCode(ConfigConst.SolidWorksManageApiUrl); + // 拼接接口地址 + string url = $"{apiUrl}/api/PropertyCard/CreateRecord"; + //获取token + var token = await _sysConfigService.GetConfigValueByCode(ConfigConst.SolidWorksManageAuthorization); + // 将参数对象序列化为 JSON 字符串 + string jsonParameters = JsonConvert.SerializeObject(input); + // 设置请求内容 + var content = new StringContent(jsonParameters, Encoding.UTF8, "application/json"); + client.DefaultRequestHeaders.Remove("Authorization"); + // 添加 Authorization 到请求头 + client.DefaultRequestHeaders.Add("Authorization", token); + // 发送 POST 请求 + HttpResponseMessage response = await client.PostAsync(url, content); + // 处理响应 + if (response.IsSuccessStatusCode) + { + string responseBody = await response.Content.ReadAsStringAsync(); + // 解析 JSON 数据 + var result = JsonConvert.DeserializeObject(responseBody); + return result; + } + else + { + string responseBody = await response.Content.ReadAsStringAsync(); + + var errorResponse = new ManageResponse() + { + Success = false, + Message = responseBody, + Data="", + CustomAction="", + CustomAttributes="" + }; + return errorResponse; + } + } + +}