adding resources

This commit is contained in:
hz
2026-05-18 15:05:55 -05:00
parent 32b953aa61
commit 6366ca46c6
11 changed files with 363 additions and 13 deletions
@@ -0,0 +1,33 @@
using LocationsApi.Models;
using LocationsApi.Services;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System.Security.Claims;
namespace LocationsApi.Controllers;
[ApiController]
[Route("api/[controller]")]
public class ResourcesController : ControllerBase
{
private readonly ResourceService _resources;
public ResourcesController(ResourceService resources)
{
_resources = resources;
}
[Authorize(Roles = "USER,SUPER")]
[HttpGet("me")]
public async Task<ActionResult<PlayerResourcesResponse>> GetMine()
{
var username = User.FindFirstValue(ClaimTypes.Name);
if (string.IsNullOrWhiteSpace(username))
{
return Unauthorized();
}
var resources = await _resources.GetAsync(username);
return Ok(PlayerResourcesResponse.FromResources(resources));
}
}