staging #31

Merged
hy merged 21 commits from staging into master 2025-11-11 18:36:29 +08:00
3 changed files with 24 additions and 3 deletions
Showing only changes of commit 87caff0299 - Show all commits

View File

@ -22,6 +22,16 @@ namespace Learn.Archives.Core.Common
throw new OhException(message, code); throw new OhException(message, code);
} }
/// <summary> /// <summary>
/// 抛出 异常
/// </summary>
/// <param name="message"></param>
/// <param name="code"></param>
/// <exception cref="OhException"></exception>
public static T Error<T>(string message, int code = 500)
{
throw new OhException(message, code);
}
/// <summary>
/// 抛出 模型校验异常 /// 抛出 模型校验异常
/// </summary> /// </summary>
/// <param name="message"></param> /// <param name="message"></param>

View File

@ -71,8 +71,19 @@ namespace Learn.Archives.Core.Common
requestMessage.Content = new StringContent(data.ToJson(), Encoding.UTF8, "application/json"); requestMessage.Content = new StringContent(data.ToJson(), Encoding.UTF8, "application/json");
var responseMessage = await httpClient.SendAsync(requestMessage, HttpCompletionOption.ResponseHeadersRead); var responseMessage = await httpClient.SendAsync(requestMessage, HttpCompletionOption.ResponseHeadersRead);
var resStr = await responseMessage.Content?.ReadAsStringAsync(); var resStr = string.Empty;
var res = JsonSerializer.Deserialize<BaseReturn<UserImportRes>>(resStr); try
{
resStr= await responseMessage?.Content?.ReadAsStringAsync();
}
catch (Exception ex)
{
return Oh.Error<UserImportRes>($"请求用户中心出现异常 {resStr} {ex.Message}");
}
if(string.IsNullOrEmpty(resStr))
return Oh.Error<UserImportRes>($"请求用户中心出现异常 返回了空数据");
var res = JsonSerializer.Deserialize<BaseReturn<UserImportRes>>(resStr);
if (res == null || res.Code != 200) if (res == null || res.Code != 200)
Oh.Error(res.Message, res.Code); Oh.Error(res.Message, res.Code);
return res.Data; return res.Data;

View File

@ -28,6 +28,6 @@
<PackageReference Include="SqlSugar.IOC" Version="2.0.0" /> <PackageReference Include="SqlSugar.IOC" Version="2.0.0" />
<PackageReference Include="SqlSugarCore" Version="5.1.4.170" /> <PackageReference Include="SqlSugarCore" Version="5.1.4.170" />
<PackageReference Include="System.Net.Http" Version="4.3.4" /> <PackageReference Include="System.Net.Http" Version="4.3.4" />
<PackageReference Include="UserCenter.Model" Version="1.4.4" /> <PackageReference Include="UserCenter.Model" Version="1.4.9" />
</ItemGroup> </ItemGroup>
</Project> </Project>