Files
juipnet/Infrastructure/ServiceClient/BaseInfoClient/Response/User/QueryVisterByVisterIdResponse.cs
wanyongkang d318014316 初始提交
2020-10-07 20:25:03 +08:00

53 lines
1.6 KiB
C#

using System;
using System.Threading.Tasks;
using Etor.Infrastructure.Common;
using Etor.Infrastructure.Data;
using Etor.Infrastructure.Serializer;
using Etor.Infrastructure.WebApi;
using Newtonsoft.Json;
using ServiceClient;
using ServiceClient.Response.User;
namespace ServiceClient.Response.User
{
public class QueryVisterByVisterIdResponse
{
[JsonProperty("visterData")] public VisterItem VisterItem { get; set; } = new VisterItem();
}
}
namespace BaseInfoClient.Extension
{
public static class QueryVisterByVisterIdResponseExtension
{
public static async Task<VisterItem> QueryVisterByVisterId(this BaseInfoHttpClient client, int ownerId,
int visterId, bool throwException = false)
{
try
{
var response = await client.CreateHttpClient().GetAsync(
$"{client.BaseUrl}/api/baseinfo/v1/BaseData/GetOneBasePerson?OwnerID={ownerId}&Data.visterId={visterId}");
var content = await response.Content.ReadAsStringAsync();
return content.FromJsonTo<ApiResult<QueryVisterByVisterIdResponse>>().Data.VisterItem;
}
catch (Exception e)
{
LogHelper.Error("根据访客Id查询访客信息",e);
if (throwException)
{
BusinessException.Throw("获取访客信息失败");
}
else
{
return new VisterItem();
}
}
return new VisterItem();
}
}
}