文字游戏
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

42 lines
1.1 KiB

using Build_God_Api.DB;
using Build_God_Api.Services;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace Build_God_Api.Controllers
{
[ApiController]
[Route("api/god/[controller]")]
public class LevelController(ILevelService service) : ControllerBase
{
private readonly ILevelService service = service;
[HttpPost]
[Authorize(Roles = "admin")]
public async Task<ActionResult<bool>> Add([FromBody] Level item)
{
return await service.Add(item);
}
[HttpDelete("{id}")]
[Authorize(Roles = "admin")]
public async Task<ActionResult<bool>> Delete(int id)
{
return await service.Delete(id);
}
[HttpPut]
[Authorize(Roles = "admin")]
public async Task<ActionResult<bool>> Update([FromBody] Level item)
{
return await service.Update(item);
}
[HttpGet("all")]
[Authorize]
public async Task<ActionResult<List<Level>>> GetAll()
{
return await service.GetAll();
}
}
}