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.
75 lines
2.2 KiB
75 lines
2.2 KiB
using Build_God_Api.Common;
|
|
using Build_God_Api.DB;
|
|
using Build_God_Api.Dto;
|
|
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 EquipmentController(IEquipmentService service) : ControllerBase
|
|
{
|
|
private readonly IEquipmentService service = service;
|
|
|
|
[HttpPost]
|
|
[Authorize(Roles = "admin")]
|
|
public async Task<ActionResult<bool>> Add([FromBody] EquipmentTemplate item)
|
|
{
|
|
return await service.Add(item);
|
|
}
|
|
|
|
[HttpPost("list")]
|
|
[Authorize(Roles = "admin")]
|
|
public async Task<ActionResult<bool>> Add([FromBody] List<EquipmentTemplate> items)
|
|
{
|
|
return await service.Add(items);
|
|
}
|
|
|
|
[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] EquipmentTemplate item)
|
|
{
|
|
return await service.Update(item);
|
|
}
|
|
|
|
[HttpPost("all")]
|
|
[Authorize]
|
|
public async Task<ActionResult<PagedResult<EquipmentTemplate>>> GetAll([FromBody] SearchEquipmentDto dto)
|
|
{
|
|
return await service.GetAll(dto);
|
|
}
|
|
|
|
[HttpGet("types")]
|
|
[Authorize]
|
|
public ActionResult<List<EnumInfoDto>> GetEquipmentTypes()
|
|
{
|
|
var result = EnumHelper.GetEnumList<EquipmentType>();
|
|
return result;
|
|
}
|
|
|
|
[HttpGet("rarities")]
|
|
[Authorize]
|
|
public ActionResult<List<EnumInfoDto>> GetEquipmentRarity()
|
|
{
|
|
var result = EnumHelper.GetEnumList<Rarity>();
|
|
return result;
|
|
}
|
|
|
|
[HttpGet("attribute-types")]
|
|
[Authorize]
|
|
public ActionResult<List<EnumInfoDto>> GetEquipmentAttributeTypes()
|
|
{
|
|
var result = EnumHelper.GetEnumList<EquipmentAttributeType>();
|
|
return result;
|
|
}
|
|
}
|
|
}
|
|
|