Merged PR 76: Ajout de PublicCreatorInfo Backend
Ajout de PublicCreatorInfo dans le swagger
This commit is contained in:
@@ -1,10 +1,12 @@
|
|||||||
using Hutopy.Application.Common.Interfaces;
|
using Hutopy.Application.Common.Interfaces;
|
||||||
|
using Hutopy.Application.Common.Models;
|
||||||
|
|
||||||
namespace Hutopy.Application.Users.Queries.GetMinimalUser;
|
namespace Hutopy.Application.Users.Queries.GetMinimalUser;
|
||||||
|
|
||||||
public record GetMinimalUserQuery : IRequest<MinimalUserDto>
|
public record GetMinimalUserQuery : IRequest<MinimalUserDto>
|
||||||
{
|
{
|
||||||
public string UserId { get; set; } = string.Empty;
|
public string? UserId { get; set; } = string.Empty;
|
||||||
|
public string? UserName { get; set; } = string.Empty;
|
||||||
};
|
};
|
||||||
|
|
||||||
public class GetMinimalUserQueryHandler(
|
public class GetMinimalUserQueryHandler(
|
||||||
@@ -14,15 +16,27 @@ public class GetMinimalUserQueryHandler(
|
|||||||
{
|
{
|
||||||
public async Task<MinimalUserDto> Handle(GetMinimalUserQuery request, CancellationToken cancellationToken)
|
public async Task<MinimalUserDto> Handle(GetMinimalUserQuery request, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var identityUser = await identityService.FindUserByIdAsync(request.UserId);
|
UserModel? identityUser = null;
|
||||||
|
|
||||||
|
if (request.UserId != string.Empty)
|
||||||
|
{
|
||||||
|
identityUser = await identityService.FindUserByIdAsync(request.UserId);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (request.UserName != string.Empty)
|
||||||
|
{
|
||||||
|
identityUser = await identityService.GetUserByUserNameAsync(request.UserName);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
var user = new MinimalUserDto
|
var user = new MinimalUserDto
|
||||||
{
|
{
|
||||||
FirstName = identityUser?.FirstName ?? "",
|
FirstName = identityUser?.FirstName ?? string.Empty,
|
||||||
LastName = identityUser?.LastName ?? "",
|
LastName = identityUser?.LastName ?? string.Empty,
|
||||||
UserName = identityUser?.UserName ?? ""
|
UserName = identityUser?.UserName ?? string.Empty
|
||||||
};
|
};
|
||||||
|
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4,5 +4,5 @@ public class MinimalUserDto
|
|||||||
{
|
{
|
||||||
public required string FirstName { get; init; }
|
public required string FirstName { get; init; }
|
||||||
public required string LastName { get; init; }
|
public required string LastName { get; init; }
|
||||||
public string UserName { get; init; } = String.Empty;
|
public required string UserName { get; init; } = String.Empty;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,15 +12,17 @@ public class Users : EndpointGroupBase
|
|||||||
.MapPost(CreateUser)
|
.MapPost(CreateUser)
|
||||||
.MapGet(GetMinimalUser)
|
.MapGet(GetMinimalUser)
|
||||||
.MapIdentityApi<ApplicationUser>();
|
.MapIdentityApi<ApplicationUser>();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static async Task<Guid> CreateUser(ISender sender, CreateUserCommand command)
|
private static async Task<Guid> CreateUser(ISender sender, CreateUserCommand command)
|
||||||
{
|
{
|
||||||
return await sender.Send(command);
|
return await sender.Send(command);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static async Task<MinimalUserDto> GetMinimalUser(ISender sender, [AsParameters] GetMinimalUserQuery query)
|
private static async Task<MinimalUserDto> GetMinimalUser(ISender sender, [AsParameters] GetMinimalUserQuery query)
|
||||||
{
|
{
|
||||||
return await sender.Send(query);
|
return await sender.Send(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -251,12 +251,20 @@
|
|||||||
{
|
{
|
||||||
"name": "UserId",
|
"name": "UserId",
|
||||||
"in": "query",
|
"in": "query",
|
||||||
"required": true,
|
|
||||||
"schema": {
|
"schema": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"nullable": true
|
"nullable": true
|
||||||
},
|
},
|
||||||
"x-position": 1
|
"x-position": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "UserName",
|
||||||
|
"in": "query",
|
||||||
|
"schema": {
|
||||||
|
"type": "string",
|
||||||
|
"nullable": true
|
||||||
|
},
|
||||||
|
"x-position": 2
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"responses": {
|
"responses": {
|
||||||
|
|||||||
Reference in New Issue
Block a user