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