Files
juipnet/Infrastructure/ServiceClient/BaseInfoClient/Response/User/QueryVisiterAndUserByWxOpenIdResponse.cs

63 lines
2.0 KiB
C#
Raw Normal View History

2020-12-28 14:55:48 +08:00
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 Newtonsoft.Json.Serialization;
using ServiceClient;
using ServiceClient.Response.Householder;
using ServiceClient.Response.User;
namespace ServiceClient.Response.User
{
public class QueryVisiterAndUserByWxOpenIdResponse
{
[JsonProperty("userData")]
public HouseholderItem HouseholderItem { get; set; }
[JsonProperty("visterData")]
public VisterItem VisterItem { get; set; }
}
}
namespace BaseInfoClient.Extension
{
public static class QueryVisiterAndUserByWxOpenIdResponseExtension
{
public static async Task<QueryVisiterAndUserByWxOpenIdResponse> QueryVisiterAndUserByWxOpenId(
this BaseInfoHttpClient client, string openId,bool throwException = false)
{
try
{
var response =
await client.CreateHttpClient().GetAsync(
$"{client.BaseUrl}/api/baseinfo/v1/BaseData/GetUserVisterByOpenID?openId={openId}");
//var response =
// await client.CreateHttpClient().GetAsync(
// $"https://localhost:44324/api/baseinfo/v1/BaseData/GetUserVisterByOpenID?openId={openId}");
var content = await response.Content.ReadAsStringAsync();
return content.FromJsonTo<ApiResult<QueryVisiterAndUserByWxOpenIdResponse>>().Data;
}
catch (Exception e)
{
LogHelper.Error("根据openId查询用户",e);
if (throwException)
{
BusinessException.Throw("获取用户信息失败");
}
else
{
return new QueryVisiterAndUserByWxOpenIdResponse();
}
}
return new QueryVisiterAndUserByWxOpenIdResponse();
}
}
2020-10-07 20:25:03 +08:00
}