Able to list awards

This commit is contained in:
2025-09-09 00:32:34 +08:00
parent 89320fc540
commit fa7010db3d

View File

@@ -589,6 +589,25 @@ public class PostController(
[MaxLength(4096)] public string? Message { get; set; } [MaxLength(4096)] public string? Message { get; set; }
} }
[HttpGet("{id:guid}/awards")]
public async Task<ActionResult<PostAward>> GetPostAwards(Guid id, [FromQuery] int offset = 0,
[FromQuery] int take = 20)
{
var queryable = db.PostAwards
.Where(a => a.PostId == id)
.AsQueryable();
var totalCount = await queryable.CountAsync();
Response.Headers.Append("X-Total", totalCount.ToString());
var awards = await queryable
.Take(take)
.Skip(offset)
.ToListAsync();
return Ok(awards);
}
public class PostAwardResponse public class PostAwardResponse
{ {
public Guid OrderId { get; set; } public Guid OrderId { get; set; }