This commit is contained in:
2026-08-31 14:42:22 +08:00
72 changed files with 2479 additions and 168 deletions
@@ -20,6 +20,7 @@ namespace IdentityService.WebApi.Applications.User
Description = u.Description,
Email = u.Email,
Id = u.Id,
NickName = u.NickName,
Phone = u.PhoneNumber,
Region = u.Region,
UserName = u.UserName
@@ -31,6 +31,16 @@ namespace IdentityService.WebApi.Applications.User
return Result<UserResponse?>.Success(mapper.Map<UserResponse>(user));
}
public async Task<Result<UserResponse?>> GetUserInfoByUnameAsync(string username)
{
var user = await repository.FindByUserNameAsync(username);
if (user is null)
{
return Result<UserResponse?>.Fail(ResultCode.USER_NOT_FOUND);
}
return Result<UserResponse?>.Success(mapper.Map<UserResponse>(user));
}
public async Task<Result<UserResponse>> UpdateAsync(UserUpdateCommand command)
{
@@ -36,6 +36,12 @@ namespace IdentityService.WebApi.Controllers.User
{
return Ok(await userService.GetUserInfoAsync(userId));
}
[HttpGet]
[ProducesDefaultResponseType(typeof(Result<UserResponse?>))]
public async Task<IActionResult> FindByUname(string username)
{
return Ok(await userService.GetUserInfoByUnameAsync(username));
}
[HttpPost]
[ProducesDefaultResponseType(typeof(Result<UserResponse>))]
+4 -17
View File
@@ -1,27 +1,14 @@
FROM swr.cn-north-4.myhuaweicloud.com/ddn-k8s/mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src
COPY IM_API_NEW.sln ./
COPY User.WebApi/IdentityService.WebApi.csproj User.WebApi/
COPY User.Domain/IdentityService.Domain.csproj User.Domain/
COPY User.Infrastructure/IdentityService.Infrastructure.csproj User.Infrastructure/
COPY DomainCommons/IM.DomainCommons.csproj DomainCommons/
COPY Infrastructure/IM.Infrastructure.csproj Infrastructure/
COPY IM.ASPNETCore/IM.ASPNETCore.csproj IM.ASPNETCore/
COPY IM.Commons/IM.Commons.csproj IM.Commons/
COPY IM.InitCommon/IM.InitCommon.csproj IM.InitCommon/
COPY IM.Jwt/IM.Jwt.csproj IM.Jwt/
COPY IM.Protocols/IM.Protocols.csproj IM.Protocols/
RUN dotnet restore User.WebApi/IdentityService.WebApi.csproj
COPY . .
# 清除本机 obj 中的 NuGet fallback 路径引用
RUN find . -type d \( -name obj -o -name bin \) -prune -exec rm -rf {} + 2>/dev/null || true
RUN dotnet publish User.WebApi/IdentityService.WebApi.csproj \
-c Release \
-o /app/publish \
--no-restore
-o /app/publish
FROM swr.cn-north-4.myhuaweicloud.com/ddn-k8s/mcr.microsoft.com/dotnet/aspnet:8.0 AS runtime
WORKDIR /app
+42
View File
@@ -35,5 +35,47 @@ namespace IdentityService.WebApi.Services
UserName = res.Data.UserName
};
}
public override async Task<GetUserListResponse> GetUserListAsync(
GetUserListRequest request,
ServerCallContext context)
{
var ids = request.UserIds
.Select(Guid.Parse)
.ToList();
var res = await service.GetUsersByIdsAsync(ids);
if (!res.Succeeded)
{
throw new RpcException(new Status(StatusCode.NotFound, res.Message));
}
var response = new GetUserListResponse();
response.Users.AddRange(res.Data.Select(user =>
{
var item = new UserResponse
{
Avatar = user.Avatar ?? "",
CreationTime = user.CreationTime.ToUniversalTime().ToTimestamp(),
Description = user.Description,
Email = user.Email ?? "",
Id = user.Id.ToString(),
NickName = user.NickName,
Phone = user.Phone ?? "",
Region = user.Region,
UserName = user.UserName
};
if (user.Deletion.HasValue)
{
item.Deletion = user.Deletion.Value.ToUniversalTime().ToTimestamp();
}
return item;
}));
return response;
}
}
}