using System.Collections.Generic; using System.Threading.Tasks; using GxPress.Common.Page; using GxPress.Repository.Interface.SpecialLabel; using GxPress.Request.SpecialLabel; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace GxPress.Api.AdminControllers { /// <summary> /// 特使标签数据 /// </summary> [Route("api/admin/special-label")] [ApiController] [Authorize] public class AdminSpecialLabelController : Controller { private readonly ISpecialLabelRepository specialLabelRepository; public AdminSpecialLabelController(ISpecialLabelRepository specialLabelRepository) { this.specialLabelRepository = specialLabelRepository; } /// <summary> /// 添加 /// </summary> /// <param name="model"></param> /// <returns></returns> [HttpPost] public async Task<bool> InsertAsync(Entity.SystemLabel.SpecialLabel model) { return await specialLabelRepository.InsertAsync(model) > 0; } /// <summary> /// 修改 /// </summary> /// <param name="model"></param> /// <returns></returns> [HttpPut] public async Task<bool> UpdateAsync(Entity.SystemLabel.SpecialLabel model) { return await specialLabelRepository.UpdateAsync(model); } /// <summary> /// 获取 /// </summary> /// <param name="id"></param> /// <returns></returns> [HttpGet("{id}")] public async Task<Entity.SystemLabel.SpecialLabel> GetAsync(int id) { return await specialLabelRepository.GetAsync(id); } /// <summary> /// 删除 /// </summary> /// <param name="id"></param> /// <returns></returns> [HttpDelete("{id}")] public async Task<bool> DeleteAsync(int id) { return await specialLabelRepository.DeleteAsync(id); } /// <summary> /// 获取类型下的数据 /// </summary> /// <param name="typeValue"></param> /// <returns></returns> [HttpGet("list/{typeValue}")] public async Task<IEnumerable<Entity.SystemLabel.SpecialLabel>> GetAllAsync(int typeValue) { return await specialLabelRepository.GetAllAsync(typeValue); } /// <summary> ///特使标签数据 /// </summary> /// <param name="request"></param> /// <returns></returns> [HttpPost("list")] public async Task<PagedList<Entity.SystemLabel.SpecialLabel>> GetAllAsync(SpecialLabelSearchRequest request) { return await specialLabelRepository.GetAllAsync(request); } } }