init
This commit is contained in:
commit
ab2e20f7e1
72 changed files with 2000 additions and 0 deletions
28
Femto.Api/Controllers/Authors/AuthorsController.cs
Normal file
28
Femto.Api/Controllers/Authors/AuthorsController.cs
Normal file
|
@ -0,0 +1,28 @@
|
|||
using Femto.Api.Controllers.Authors.Dto;
|
||||
using Femto.Modules.Blog.Domain.Posts.Commands.GetAuthorPosts;
|
||||
using MediatR;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Femto.Api.Controllers.Authors;
|
||||
|
||||
[ApiController]
|
||||
[Route("authors")]
|
||||
public class AuthorsController(IMediator mediator) : ControllerBase
|
||||
{
|
||||
[HttpGet("{authorId}/posts")]
|
||||
public async Task<ActionResult<GetAuthorPostsResponse>> GetAuthorPosts(
|
||||
Guid authorId,
|
||||
[FromQuery] GetAuthorPostsSearchParams searchParams,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var posts = await mediator.Send(
|
||||
new GetAuthorPostsQuery(authorId, searchParams.Cursor, searchParams.Count),
|
||||
cancellationToken
|
||||
);
|
||||
|
||||
return new GetAuthorPostsResponse(
|
||||
posts.Select(p => new AuthorPostDto(p.PostId, p.Text, p.Media.Select(m => m.Url)))
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
using JetBrains.Annotations;
|
||||
|
||||
namespace Femto.Api.Controllers.Authors.Dto;
|
||||
|
||||
[PublicAPI]
|
||||
public record GetAuthorPostsResponse(IEnumerable<AuthorPostDto> Posts);
|
||||
|
||||
[PublicAPI]
|
||||
public record AuthorPostDto(Guid PostId, string Content, IEnumerable<Uri> Media);
|
|
@ -0,0 +1,3 @@
|
|||
namespace Femto.Api.Controllers.Authors;
|
||||
|
||||
public record GetAuthorPostsSearchParams(Guid? Cursor, int? Count);
|
Loading…
Add table
Add a link
Reference in a new issue