完善平台报名数据上传功能
This commit is contained in:
parent
f4e5db3f52
commit
74311db71a
@ -3,6 +3,7 @@ using System.Text;
|
|||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
using YD_Event.Application.CitizenSports.Dtos;
|
using YD_Event.Application.CitizenSports.Dtos;
|
||||||
using YD_Event.Core.Options;
|
using YD_Event.Core.Options;
|
||||||
|
|
||||||
@ -309,8 +310,7 @@ public sealed class CitizenSportsPlatformService : ITransient
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return JsonConvert.DeserializeObject<CitizenSportsPlatformResponse<T>>(responseText)
|
return DeserializePlatformResponse<T>(responseText);
|
||||||
?? throw new JsonException("响应为空");
|
|
||||||
}
|
}
|
||||||
catch (JsonException exception)
|
catch (JsonException exception)
|
||||||
{
|
{
|
||||||
@ -319,6 +319,27 @@ public sealed class CitizenSportsPlatformService : ITransient
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal static CitizenSportsPlatformResponse<T> DeserializePlatformResponse<T>(string responseText)
|
||||||
|
{
|
||||||
|
var envelope = JsonConvert.DeserializeObject<CitizenSportsPlatformResponse<JToken>>(responseText)
|
||||||
|
?? throw new JsonException("响应为空");
|
||||||
|
T? data = default;
|
||||||
|
if (envelope.Data?.Type == JTokenType.Object)
|
||||||
|
data = envelope.Data.ToObject<T>();
|
||||||
|
else if (envelope.IsSuccess && envelope.Data?.Type is not (null or JTokenType.Null))
|
||||||
|
throw new JsonException("成功响应的 data 不是对象");
|
||||||
|
|
||||||
|
return new CitizenSportsPlatformResponse<T>
|
||||||
|
{
|
||||||
|
Code = envelope.Code,
|
||||||
|
Status = envelope.Status,
|
||||||
|
Message = envelope.Message,
|
||||||
|
Msg = envelope.Msg,
|
||||||
|
Data = data,
|
||||||
|
SystemTime = envelope.SystemTime
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
private CitizenSportsPlatformOptions GetValidatedOptions()
|
private CitizenSportsPlatformOptions GetValidatedOptions()
|
||||||
{
|
{
|
||||||
var options = _optionsMonitor.CurrentValue;
|
var options = _optionsMonitor.CurrentValue;
|
||||||
|
|||||||
@ -150,7 +150,7 @@ internal sealed class CitizenSportsPlayer
|
|||||||
[JsonProperty("playerPhone", NullValueHandling = NullValueHandling.Ignore)]
|
[JsonProperty("playerPhone", NullValueHandling = NullValueHandling.Ignore)]
|
||||||
public string? PlayerPhone { get; set; }
|
public string? PlayerPhone { get; set; }
|
||||||
|
|
||||||
[JsonProperty("playerBirth", NullValueHandling = NullValueHandling.Ignore)]
|
[JsonProperty("playerBirthday", NullValueHandling = NullValueHandling.Ignore)]
|
||||||
public string? PlayerBirth { get; set; }
|
public string? PlayerBirth { get; set; }
|
||||||
|
|
||||||
[JsonProperty("groupName", NullValueHandling = NullValueHandling.Ignore)]
|
[JsonProperty("groupName", NullValueHandling = NullValueHandling.Ignore)]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user