添加项目文件。
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
using ContactService.WebApi.Application.Dtos;
|
||||
using Grpc.Core;
|
||||
using IM.Commons;
|
||||
using IM.Protocols.Grpc.User;
|
||||
|
||||
namespace ContactService.WebApi.Application.IntegrationServices
|
||||
{
|
||||
public class IdentityIntegrationService : IIdentityIntegrationService
|
||||
{
|
||||
private readonly UserInternal.UserInternalClient client;
|
||||
|
||||
public IdentityIntegrationService(UserInternal.UserInternalClient client)
|
||||
{
|
||||
this.client = client;
|
||||
}
|
||||
|
||||
public async Task<Result<UserInfoDto>> FindUserByIdAsync(Guid id)
|
||||
{
|
||||
var req = new GetUserInfoRequest()
|
||||
{
|
||||
UserId = id.ToString()
|
||||
};
|
||||
try
|
||||
{
|
||||
var res = await client.GetUserInfoAsyncAsync(req);
|
||||
return Result.Success(new UserInfoDto
|
||||
{
|
||||
Avatar = res.Avatar,
|
||||
CreationTime = res.CreationTime.ToDateTimeOffset(),
|
||||
Deletion = res.Deletion.ToDateTimeOffset(),
|
||||
Description = res.Description,
|
||||
Email = res.Email,
|
||||
Id = Guid.Parse(res.Id),
|
||||
NickName = res.NickName,
|
||||
Phone = res.Phone,
|
||||
Region = res.Region,
|
||||
UserName = res.UserName
|
||||
});
|
||||
}catch(RpcException e)
|
||||
{
|
||||
return Result.Fail<UserInfoDto>(ResultCode.USER_NOT_FOUND);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user