Compare commits
3 Commits
1f82aa960a
...
249917e460
| Author | SHA1 | Date |
|---|---|---|
|
|
249917e460 | |
|
|
4e6f8c9c84 | |
|
|
87caff0299 |
|
|
@ -22,6 +22,16 @@ namespace Learn.Archives.Core.Common
|
|||
throw new OhException(message, code);
|
||||
}
|
||||
/// <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>
|
||||
/// <param name="message"></param>
|
||||
|
|
|
|||
|
|
@ -71,8 +71,19 @@ namespace Learn.Archives.Core.Common
|
|||
requestMessage.Content = new StringContent(data.ToJson(), Encoding.UTF8, "application/json");
|
||||
|
||||
var responseMessage = await httpClient.SendAsync(requestMessage, HttpCompletionOption.ResponseHeadersRead);
|
||||
var resStr = await responseMessage.Content?.ReadAsStringAsync();
|
||||
var res = JsonSerializer.Deserialize<BaseReturn<UserImportRes>>(resStr);
|
||||
var resStr = string.Empty;
|
||||
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)
|
||||
Oh.Error(res.Message, res.Code);
|
||||
return res.Data;
|
||||
|
|
|
|||
|
|
@ -28,6 +28,6 @@
|
|||
<PackageReference Include="SqlSugar.IOC" Version="2.0.0" />
|
||||
<PackageReference Include="SqlSugarCore" Version="5.1.4.170" />
|
||||
<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>
|
||||
</Project>
|
||||
|
|
|
|||
Loading…
Reference in New Issue