This commit is contained in:
hz
2025-05-08 09:29:20 -05:00
parent 4f67e2b56f
commit c0a94f26d6
31 changed files with 1181 additions and 0 deletions
+41
View File
@@ -0,0 +1,41 @@
using System.Threading.Tasks;
using GameAuthApi.Models;
using GameAuthApi.Services;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace GameAuthApi.Controllers;
[ApiController]
[Route("api/[controller]")]
public class SpawnableController : ControllerBase
{
private readonly SpawnableService _spawnableService;
public SpawnableController(SpawnableService spawnableService)
{
_spawnableService = spawnableService;
}
[HttpPost]
[Authorize(Roles = "SUPER")]
public async Task<IActionResult> Create([FromBody] CreateSpawnableRequest req)
{
var spawnable = new Spawnable
{
Name = req.Name.ToLower(),
SpawnRate = req.SpawnRate
};
await _spawnableService.CreateAsync(spawnable);
return Ok(spawnable);
}
[HttpGet]
[Authorize(Roles = "SUPER")]
public async Task<IActionResult> GetAll()
{
var all = await _spawnableService.GetAllAsync();
return Ok(all);
}
}