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> 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(ResultCode.USER_NOT_FOUND); } } } }