1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- 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;
- }
- /// <summary>
- /// 详情
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- [HttpGet("{id}")]
- public async Task<Entity.tede2.Category.Category> GetAsync(int id)
- {
- return await categoryRepository.GetAsync(id);
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- [HttpDelete("{id}")]
- public async Task<bool> DeleteAsync(int id)
- {
- return await categoryRepository.DeleteAsync(id);
- }
- /// <summary>
- /// 添加
- /// </summary>
- /// <param name="note"></param>
- /// <returns></returns>
- [HttpPost]
- public async Task<int> InsertAsync(Entity.tede2.Category.Category note)
- {
- return await categoryRepository.InsertAsync(note);
- }
- /// <summary>
- /// 修改
- /// </summary>
- /// <param name="note"></param>
- /// <returns></returns>
- [HttpPut]
- public async Task<bool> UpdateAsync(Entity.tede2.Category.Category note)
- {
- return await categoryRepository.UpdateAsync(note);
- }
- /// <summary>
- /// 获取所有
- /// </summary>
- /// <returns></returns>
- [HttpGet]
- public async Task<IEnumerable<Entity.tede2.Category.Category>> GetAllAsync()
- {
- return await categoryRepository.GetAllAsync();
- }
- /// <summary>
- /// 查询子集
- /// </summary>
- /// <param name="parentId"></param>
- /// <returns></returns>
- [HttpGet("children/{parentId}")]
- public async Task<IEnumerable<Entity.tede2.Category.Category>> GetCategoryChildrenAsync(int parentId)
- {
- return await categoryRepository.GetCategoryChildrenAsync(parentId);
- }
- }
- }
|