using System.Collections.Generic;
using System.Threading.Tasks;
using GxPress.Repository.Interface.Category;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
namespace GxPress.Api.AdminControllers
{
[ApiController]
[Authorize]
[Route("api/admin/category")]
public class AdminCategoryController : Controller
{
private readonly ICategoryRepository categoryRepository;
public AdminCategoryController(ICategoryRepository categoryRepository)
{
this.categoryRepository = categoryRepository;
}
///
/// 详情
///
///
///
[HttpGet("{id}")]
public async Task GetAsync(int id)
{
return await categoryRepository.GetAsync(id);
}
///
/// 删除
///
///
///
[HttpDelete("{id}")]
public async Task DeleteAsync(int id)
{
return await categoryRepository.DeleteAsync(id);
}
///
/// 添加
///
///
///
[HttpPost]
public async Task InsertAsync(Entity.tede2.Category.Category note)
{
return await categoryRepository.InsertAsync(note);
}
///
/// 修改
///
///
///
[HttpPut]
public async Task UpdateAsync(Entity.tede2.Category.Category note)
{
return await categoryRepository.UpdateAsync(note);
}
///
/// 获取所有
///
///
[HttpGet]
public async Task> GetAllAsync()
{
return await categoryRepository.GetAllAsync();
}
///
/// 查询子集
///
///
///
[HttpGet("children/{parentId}")]
public async Task> GetCategoryChildrenAsync(int parentId)
{
return await categoryRepository.GetCategoryChildrenAsync(parentId);
}
}
}