Ajout de PublicCreatorInfo
This commit is contained in:
@@ -0,0 +1,9 @@
|
|||||||
|
namespace Hutopy.Application.Users.Queries.GetCreatorInfo;
|
||||||
|
|
||||||
|
public class CreatorInfoDto
|
||||||
|
{
|
||||||
|
public required string FirstName { get; init; }
|
||||||
|
public required string LastName { get; init; }
|
||||||
|
public string UserName { get; init; } = String.Empty;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
using Hutopy.Application.Common.Interfaces;
|
||||||
|
|
||||||
|
namespace Hutopy.Application.Users.Queries.GetCreatorInfo;
|
||||||
|
|
||||||
|
public record GetCreatorInfoQuery : IRequest<CreatorInfoDto>
|
||||||
|
{
|
||||||
|
public string UserName { get; set; } = string.Empty;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
public class GetCreatorInfoHandler(
|
||||||
|
IIdentityService identityService
|
||||||
|
)
|
||||||
|
: IRequestHandler<GetCreatorInfoQuery, CreatorInfoDto>
|
||||||
|
{
|
||||||
|
public async Task<CreatorInfoDto> Handle(GetCreatorInfoQuery request, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
|
||||||
|
var userName = await identityService.GetUserByUserNameAsync(request.UserName);
|
||||||
|
var creatorInfo = new CreatorInfoDto
|
||||||
|
{
|
||||||
|
|
||||||
|
FirstName = userName?.FirstName ?? "",
|
||||||
|
LastName = userName?.LastName ?? "",
|
||||||
|
UserName = userName?.UserName ?? "",
|
||||||
|
|
||||||
|
};
|
||||||
|
return creatorInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
19
src/Web/Endpoints/GetCreatorInfo.cs
Normal file
19
src/Web/Endpoints/GetCreatorInfo.cs
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
using Hutopy.Application.Users.Queries;
|
||||||
|
using Hutopy.Application.Users.Queries.GetCreatorInfo;
|
||||||
|
|
||||||
|
|
||||||
|
namespace Hutopy.Web.Endpoints;
|
||||||
|
|
||||||
|
public class GetCreatorInfo : EndpointGroupBase
|
||||||
|
{
|
||||||
|
public override void Map(WebApplication app)
|
||||||
|
{
|
||||||
|
app.MapGroup(this)
|
||||||
|
.MapGet(GetSelectedCreatorInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static async Task<CreatorInfoDto> GetSelectedCreatorInfo(ISender sender, [AsParameters] GetCreatorInfoQuery query)
|
||||||
|
{
|
||||||
|
return await sender.Send(query);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,6 +6,38 @@
|
|||||||
"version": "1.0.0"
|
"version": "1.0.0"
|
||||||
},
|
},
|
||||||
"paths": {
|
"paths": {
|
||||||
|
"/api/GetCreatorInfo": {
|
||||||
|
"get": {
|
||||||
|
"tags": [
|
||||||
|
"GetCreatorInfo"
|
||||||
|
],
|
||||||
|
"operationId": "GetSelectedCreatorInfo",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "UserName",
|
||||||
|
"in": "query",
|
||||||
|
"required": true,
|
||||||
|
"schema": {
|
||||||
|
"type": "string",
|
||||||
|
"nullable": true
|
||||||
|
},
|
||||||
|
"x-position": 1
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "",
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/components/schemas/CreatorInfoDto"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"/api/GetMyUser": {
|
"/api/GetMyUser": {
|
||||||
"get": {
|
"get": {
|
||||||
"tags": [
|
"tags": [
|
||||||
@@ -688,6 +720,21 @@
|
|||||||
},
|
},
|
||||||
"components": {
|
"components": {
|
||||||
"schemas": {
|
"schemas": {
|
||||||
|
"CreatorInfoDto": {
|
||||||
|
"type": "object",
|
||||||
|
"additionalProperties": false,
|
||||||
|
"properties": {
|
||||||
|
"firstName": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"lastName": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"userName": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"UserDto": {
|
"UserDto": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
|
|||||||
Reference in New Issue
Block a user