using System; using System.Collections.Generic; 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; namespace ServiceClient.Response.Householder { public class QueryHouseholderInfoByUserIdResponse { [JsonProperty("userData")] public HouseholderItem HouseholderItem { get; set; } } } namespace BaseInfoClient.Extension { public static class QueryHouseholderInfoByUserIdExtension { public static async Task QueryHouseholderInfoByUserId(this BaseInfoHttpClient client , int ownerId, int userId, bool throwException = false) { try { var response = await client.CreateHttpClient().GetAsync( $"{client.BaseUrl}/api/baseinfo/v1/BaseData/GetOneBasePerson?OwnerID={ownerId}&Data.userId={userId}"); var content = await response.Content.ReadAsStringAsync(); return content.FromJsonTo>().Data.HouseholderItem; } catch (Exception e) { LogHelper.Error("根据UserId获取住户", e); if (throwException) { BusinessException.Throw("获取住户信息失败"); } else { return new HouseholderItem(); } } return new HouseholderItem(); } } }