mirror of
https://github.com/gwdevhub/Daybreak.git
synced 2026-07-25 08:22:07 +00:00
Implement Daybreak.API. Reorganize FocusView components (#995)
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
using Daybreak.API.Services;
|
||||
using Daybreak.Shared.Models.Api;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Net.Sdk.Web;
|
||||
|
||||
namespace Daybreak.API.Controllers.Rest;
|
||||
|
||||
[GenerateController("api/v1/rest/party")]
|
||||
[Tags("Party")]
|
||||
public sealed class PartyController(PartyService partyService)
|
||||
{
|
||||
private readonly PartyService partyService = partyService;
|
||||
|
||||
[GenerateGet("loadout")]
|
||||
[EndpointName("GetPartyLoadout")]
|
||||
[EndpointSummary("Get the current party loadout")]
|
||||
[EndpointDescription("Get the current party loadout. Returns a json serialized PartyLoadout object")]
|
||||
[ProducesResponseType<PartyLoadout>(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status503ServiceUnavailable)]
|
||||
public async Task<IResult> GetPartyLoadout(
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
var partyLoadout = await this.partyService.GetPartyLoadout(cancellationToken);
|
||||
return partyLoadout is not null ? Results.Ok(partyLoadout) : Results.StatusCode(StatusCodes.Status503ServiceUnavailable);
|
||||
}
|
||||
|
||||
[GeneratePost("loadout")]
|
||||
[EndpointName("SetPartyLoadout")]
|
||||
[EndpointSummary("Set the current party loadout")]
|
||||
[EndpointDescription("Set the current party loadout")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status503ServiceUnavailable)]
|
||||
public async Task<IResult> SetPartyLoadout([FromBody] PartyLoadout partyLoadout, CancellationToken cancellationToken)
|
||||
{
|
||||
var result = await this.partyService.SetPartyLoadout(partyLoadout, cancellationToken);
|
||||
return result ? Results.Ok() : Results.StatusCode(StatusCodes.Status503ServiceUnavailable);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user