53 lines
1.6 KiB
C#
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();
|
|
}
|
|
}
|
|
} |