Files
2026-10-16 23:33:13 -07:00

27 lines
852 B
C#

using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using RadicadeServer.DB;
using RadicadeServer.Extensions;
using RadicadeServer.RecNet.Progression;
using RadicadeServer.RecNet.Royale;
namespace RadicadeServer.API.Royale.V1
{
[Route("api/royale/v1")]
public class RoyaleV1(RecDBContext db) : Controller
{
[HttpGet("current"), Authorize]
public async Task<ActionResult<RoyaleProgressDTO>> GetCurrentProgress()
{
var userId = User.GetUserId();
if (userId == null) return Unauthorized();
var data = await db.Progression.FirstOrDefaultAsync(x => x.PlayerId == userId.Value);
data ??= new ProgressionData { PlayerId = userId.Value };
return Ok(RoyaleShared.BuildProgress(data));
}
}
}