Files
juipnet/Infrastructure/ServiceClient/BaseInfoClient/Response/PropertyEmployee/QueryAllEmployeesByOwnerIdResponse.cs
“wanyongkang” ed3b2c653e 接口文件
2024-04-10 13:55:27 +08:00

57 lines
1.8 KiB
C#

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.PropertyEmployee;
using ServiceClient.Response.User;
namespace ServiceClient.Response.PropertyEmployee
{
public class QueryAllEmployeesByOwnerIdResponse
{
[JsonProperty("staffData")]
public List<EmployeeItem> EmployeeInfos { get; set; }=new List<EmployeeItem>();
}
}
namespace BaseInfoClient.Extension
{
public static class QueryAllEmployeesByOwnerIdResponseExtension
{
public static async Task<List<EmployeeItem>> QueryAllEmployeesByOwnerId(this BaseInfoHttpClient client
, int ownerId, bool throwException = false)
{
try
{
var response = await client.CreateHttpClient().GetAsync(
$"{client.BaseUrl}/api/baseinfo/v1/BaseData/GetAllBasePerson?Data.IsGetSaff=true&OwnerID={ownerId}");
var content = await response.Content.ReadAsStringAsync();
return content.FromJsonTo<ApiResult<QueryAllEmployeesByOwnerIdResponse>>().Data.EmployeeInfos;
}
catch (Exception e)
{
LogHelper.Error("根据OwnerId获取物业员工",e);
if (throwException)
{
BusinessException.Throw("获取员工信息失败");
}
else
{
return new List<EmployeeItem>();
}
}
return new List<EmployeeItem>();
}
}
}