2020-12-28 14:55:48 +08:00
|
|
|
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 ServiceClient;
|
|
|
|
|
using ServiceClient.Response.PropertyEmployee;
|
|
|
|
|
using ServiceClient.Response.User;
|
|
|
|
|
|
|
|
|
|
namespace ServiceClient.Response.PropertyEmployee
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class QueryEmployeeInfoByUserIdResponse
|
|
|
|
|
{
|
|
|
|
|
[JsonProperty("staffData")] public EmployeeItem UserInfo { get; set; } = new EmployeeItem();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
namespace BaseInfoClient.Extension
|
|
|
|
|
{
|
|
|
|
|
public static class QueryEmployeeInfoByUserIdResponseExtension
|
|
|
|
|
{
|
|
|
|
|
public static async Task<EmployeeItem> QueryEmployeeInfoByUserId(this BaseInfoHttpClient client, int ownerId,
|
|
|
|
|
int userId, bool throwException = false)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var response = await client.CreateHttpClient().GetAsync(
|
|
|
|
|
$"{client.BaseUrl}/api/baseinfo/v1/BaseData/GetOneBasePerson?Data.staffId={userId}&OwnerID={ownerId}");
|
|
|
|
|
|
|
|
|
|
var content = await response.Content.ReadAsStringAsync();
|
|
|
|
|
|
|
|
|
|
return content.FromJsonTo<ApiResult<QueryEmployeeInfoByUserIdResponse>>().Data.UserInfo;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
LogHelper.Error("根据员工Id获取员工信息",e);
|
|
|
|
|
|
|
|
|
|
if (throwException)
|
|
|
|
|
{
|
|
|
|
|
BusinessException.Throw("获取员工信息失败");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return new EmployeeItem();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new EmployeeItem();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2020-10-07 20:25:03 +08:00
|
|
|
}
|