using System; using System.Collections.Generic; using System.Threading.Tasks; using BaseInfoClient.Response.Build; using Etor.Infrastructure.Common; using Etor.Infrastructure.Data; using Etor.Infrastructure.Serializer; using Etor.Infrastructure.WebApi; using Newtonsoft.Json; using ServiceClient; namespace BaseInfoClient.Response.Build { public class QueryAllBuildsByOwnerIdResponse { [JsonProperty("buildData")] public List BuildItems { get; set; } = new List(); } } namespace BaseInfoClient.Extension { public static class QuerAllyBuildsByOwnerIdExtension { public static async Task> QueryAllBuildsByOwnerIdAsync(this BaseInfoHttpClient client, int ownerId, bool throwException = false) { try { var response = await client.CreateHttpClient().GetAsync( $"{client.BaseUrl}/api/baseinfo/v1/BaseData/GetAllBaseProject?OwnerID={ownerId}&Data.IsGetBuild=true"); var content = await response.Content.ReadAsStringAsync(); return content.FromJsonTo>().Data.BuildItems; } catch (Exception e) { LogHelper.Error("根据OwnerId获取楼宇", e); if (throwException) { BusinessException.Throw("获取楼宇信息失败"); } else { return new List(); } } return new List(); } } }