using System; using System.Collections.Generic; using System.Threading.Tasks; using BaseInfoClient.Response.Project; using Etor.Infrastructure.Common; using Etor.Infrastructure.Data; using Etor.Infrastructure.Serializer; using Etor.Infrastructure.WebApi; using Newtonsoft.Json; using ServiceClient; namespace BaseInfoClient.Response.Project { public class QueryAllProjectsByOwnerIdResponse { [JsonProperty("projectData")] public List ProjectItems { get; set; } = new List(); } } namespace BaseInfoClient.Extension { public static class QueryAllProjectsByOwnerIdExtension { public static async Task> QueryAllProjectsByOwnerIdAsync(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.IsGetproject=true"); var content = await response.Content.ReadAsStringAsync(); return content.FromJsonTo>().Data.ProjectItems; } catch (Exception e) { LogHelper.Error("根据OwnerId获取小区", e); if (throwException) { BusinessException.Throw("获取小区信息失败"); } else { return new List(); } } return new List(); } } }