Commit 0
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user