40 lines
1.5 KiB
C#
40 lines
1.5 KiB
C#
using Google.Protobuf.WellKnownTypes;
|
|
using Grpc.Core;
|
|
using IdentityService.WebApi.Applications.User;
|
|
using IM.Protocols.Grpc.User;
|
|
|
|
namespace IdentityService.WebApi.Services
|
|
{
|
|
public class UserService:UserInternal.UserInternalBase
|
|
{
|
|
private readonly Applications.User.UserService service;
|
|
|
|
public UserService(Applications.User.UserService service)
|
|
{
|
|
this.service = service;
|
|
}
|
|
public override async Task<UserResponse> GetUserInfoAsync(GetUserInfoRequest request, ServerCallContext context)
|
|
{
|
|
var res = await service.GetUserInfoAsync(Guid.Parse(request.UserId));
|
|
if (!res.Succeeded)
|
|
{
|
|
throw new RpcException(new Status(StatusCode.NotFound, res.Message));
|
|
}
|
|
|
|
return new UserResponse()
|
|
{
|
|
Avatar = res.Data.Avatar ?? "",
|
|
CreationTime = res.Data.CreationTime.ToUniversalTime().ToTimestamp(),
|
|
Deletion = res.Data.Deletion is null ? DateTime.MinValue.ToUniversalTime().ToTimestamp() : res.Data.Deletion.Value.ToUniversalTime().ToTimestamp(),
|
|
Description = res.Data.Description,
|
|
Email = res.Data.Email ?? "",
|
|
Id = res.Data.Id.ToString(),
|
|
NickName = res.Data.NickName,
|
|
Phone = res.Data.Phone ?? "",
|
|
Region = res.Data.Region,
|
|
UserName = res.Data.UserName
|
|
};
|
|
}
|
|
}
|
|
}
|