From 74311db71aa5e069abca34903423236dded1eb19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A9=AC=E6=A2=93=E5=BD=AD?= Date: Fri, 30 Oct 2026 15:34:12 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E5=B9=B3=E5=8F=B0=E6=8A=A5?= =?UTF-8?q?=E5=90=8D=E6=95=B0=E6=8D=AE=E4=B8=8A=E4=BC=A0=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CitizenSportsPlatformService.cs | 25 +++++++++++++++++-- .../Dtos/CitizenSportsSyncDtos.cs | 2 +- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/YD_Event.Application/CitizenSports/CitizenSportsPlatformService.cs b/YD_Event.Application/CitizenSports/CitizenSportsPlatformService.cs index 12304eb..ce70180 100644 --- a/YD_Event.Application/CitizenSports/CitizenSportsPlatformService.cs +++ b/YD_Event.Application/CitizenSports/CitizenSportsPlatformService.cs @@ -3,6 +3,7 @@ using System.Text; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using Newtonsoft.Json; +using Newtonsoft.Json.Linq; using YD_Event.Application.CitizenSports.Dtos; using YD_Event.Core.Options; @@ -309,8 +310,7 @@ public sealed class CitizenSportsPlatformService : ITransient try { - return JsonConvert.DeserializeObject>(responseText) - ?? throw new JsonException("响应为空"); + return DeserializePlatformResponse(responseText); } catch (JsonException exception) { @@ -319,6 +319,27 @@ public sealed class CitizenSportsPlatformService : ITransient } } + internal static CitizenSportsPlatformResponse DeserializePlatformResponse(string responseText) + { + var envelope = JsonConvert.DeserializeObject>(responseText) + ?? throw new JsonException("响应为空"); + T? data = default; + if (envelope.Data?.Type == JTokenType.Object) + data = envelope.Data.ToObject(); + else if (envelope.IsSuccess && envelope.Data?.Type is not (null or JTokenType.Null)) + throw new JsonException("成功响应的 data 不是对象"); + + return new CitizenSportsPlatformResponse + { + Code = envelope.Code, + Status = envelope.Status, + Message = envelope.Message, + Msg = envelope.Msg, + Data = data, + SystemTime = envelope.SystemTime + }; + } + private CitizenSportsPlatformOptions GetValidatedOptions() { var options = _optionsMonitor.CurrentValue; diff --git a/YD_Event.Application/CitizenSports/Dtos/CitizenSportsSyncDtos.cs b/YD_Event.Application/CitizenSports/Dtos/CitizenSportsSyncDtos.cs index fd1f11c..9070a46 100644 --- a/YD_Event.Application/CitizenSports/Dtos/CitizenSportsSyncDtos.cs +++ b/YD_Event.Application/CitizenSports/Dtos/CitizenSportsSyncDtos.cs @@ -150,7 +150,7 @@ internal sealed class CitizenSportsPlayer [JsonProperty("playerPhone", NullValueHandling = NullValueHandling.Ignore)] public string? PlayerPhone { get; set; } - [JsonProperty("playerBirth", NullValueHandling = NullValueHandling.Ignore)] + [JsonProperty("playerBirthday", NullValueHandling = NullValueHandling.Ignore)] public string? PlayerBirth { get; set; } [JsonProperty("groupName", NullValueHandling = NullValueHandling.Ignore)]