From c33261384f7abd2c974aa729d322c033e0414da2 Mon Sep 17 00:00:00 2001 From: schangxiang@126.com <schangxiang@126.com> Date: 周三, 02 4月 2025 18:38:52 +0800 Subject: [PATCH] 增加 返回内容 --- Api/iWare.Authorize.csproj | 1 Api/Entity/AuthorizeFunRetEntity.cs | 54 ++++++++++++++++++++++++--- Api/Util/AuthorizeHelper.cs | 12 +++-- 3 files changed, 56 insertions(+), 11 deletions(-) diff --git a/Api/Entity/AuthorizeFunRetEntity.cs b/Api/Entity/AuthorizeFunRetEntity.cs index d9c0264..928135f 100644 --- a/Api/Entity/AuthorizeFunRetEntity.cs +++ b/Api/Entity/AuthorizeFunRetEntity.cs @@ -35,17 +35,47 @@ public double? remainingDays { get; set; } /// <summary> + /// 鍒版湡鏃ユ湡 + /// </summary> + public string expiryDate { get; set; } + + /// <summary> + /// 鎺堟潈鏃ユ湡 + /// </summary> + public string issueDate { get; set; } + + /// <summary> + /// 椤圭洰鍚嶇О + /// </summary> + public string projectId { get; set; } + + /// <summary> + /// 鎺堟潈绫诲瀷 + /// </summary> + public string type { get; set; } + + /// <summary> + /// 缁戝畾MAC + /// </summary> + public string macAddress { get; set; } + + /// <summary> /// 杩斿洖鎴愬姛 /// </summary> /// <param name="_resMsg"></param> /// <returns></returns> - public static AuthorizeFunRetEntity Success(string _resMsg, object _resData = null) + public static AuthorizeFunRetEntity Success(string _resMsg, AuthorizeFunRetEntity newFun) { return new AuthorizeFunRetEntity() { result = true, resMsg = _resMsg, - resData = _resData + + expiryDate = newFun.expiryDate, + issueDate = newFun.issueDate, + macAddress = newFun.macAddress, + projectId = newFun.projectId, + type = newFun.type }; } /// <summary> @@ -53,13 +83,19 @@ /// </summary> /// <param name="_resMsg"></param> /// <returns></returns> - public static AuthorizeFunRetEntity Success(string _resMsg, double _remainingDays) + public static AuthorizeFunRetEntity Success(string _resMsg, double _remainingDays, AuthorizeFunRetEntity newFun) { return new AuthorizeFunRetEntity() { result = true, resMsg = _resMsg, - remainingDays = _remainingDays + remainingDays = _remainingDays, + + expiryDate = newFun.expiryDate, + issueDate = newFun.issueDate, + macAddress = newFun.macAddress, + projectId = newFun.projectId, + type = newFun.type }; } @@ -99,13 +135,19 @@ /// </summary> /// <param name="_resMsg"></param> /// <returns></returns> - public static AuthorizeFunRetEntity Fail(string _resMsg, double _remainingDays) + public static AuthorizeFunRetEntity Fail(string _resMsg, double _remainingDays, AuthorizeFunRetEntity newFun) { return new AuthorizeFunRetEntity() { result = false, resMsg = _resMsg, - remainingDays = _remainingDays + remainingDays = _remainingDays, + + expiryDate = newFun.expiryDate, + issueDate = newFun.issueDate, + macAddress = newFun.macAddress, + projectId = newFun.projectId, + type = newFun.type }; } } diff --git a/Api/Util/AuthorizeHelper.cs b/Api/Util/AuthorizeHelper.cs index 631cf72..8937594 100644 --- a/Api/Util/AuthorizeHelper.cs +++ b/Api/Util/AuthorizeHelper.cs @@ -1,4 +1,5 @@ 锘縰sing iWare.Authorize.Dto; +using Newtonsoft.Json; using ProjectCode; namespace iWare.Authorize @@ -33,12 +34,13 @@ string rst = EnDecode.ReadAndValidateLicenseFile(firstFile.FullName); if (!string.IsNullOrEmpty(rst)) { + AuthorizeFunRetEntity newRet = JsonConvert.DeserializeObject<AuthorizeFunRetEntity>(rst); if (EnDecode.ValidatePermanentLicense(firstFile.FullName)) { - return AuthorizeFunRetEntity.Success("鎴愬姛"); + return AuthorizeFunRetEntity.Success("鎴愬姛", newRet); } else - return ValidateLicenseForDev(firstFile.FullName, input); + return ValidateLicenseForDev(firstFile.FullName, input, newRet); } else { @@ -57,7 +59,7 @@ /// </summary> /// <param name="filePath"></param> /// <returns></returns> - private static AuthorizeFunRetEntity ValidateLicenseForDev(string filePath, ValidateLicenseInput input) + private static AuthorizeFunRetEntity ValidateLicenseForDev(string filePath, ValidateLicenseInput input, AuthorizeFunRetEntity newRet) { //璇诲彇 寮�鍙戞巿鏉� var val = EnDecode.ValidateDevLicense(filePath); @@ -71,10 +73,10 @@ return AuthorizeFunRetEntity.Success("鎴愬姛", val.RemainingDays, $"鎺堟潈鍓╀綑澶╂暟{val.RemainingDays}灏忎簬{waringDays}澶�"); } } - return AuthorizeFunRetEntity.Success("鎴愬姛", val.RemainingDays); + return AuthorizeFunRetEntity.Success("鎴愬姛", val.RemainingDays, newRet); } else - return AuthorizeFunRetEntity.Fail("鎺堟潈澶辫触", val.RemainingDays); + return AuthorizeFunRetEntity.Fail("鎺堟潈澶辫触", val.RemainingDays, newRet); } diff --git a/Api/iWare.Authorize.csproj b/Api/iWare.Authorize.csproj index 37b4af2..96ee76e 100644 --- a/Api/iWare.Authorize.csproj +++ b/Api/iWare.Authorize.csproj @@ -8,6 +8,7 @@ <ItemGroup> <PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.2" /> + <PackageReference Include="Newtonsoft.Json" Version="13.0.3" /> <PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" /> </ItemGroup> -- Gitblit v1.9.3