using System.Collections.Generic; using System.Threading.Tasks; using GxPress.Common.Page; using GxPress.Repository.Interface.SystemLabel; using GxPress.Request.SystemLabel; using GxPress.Result.SystemLabel; using GxPress.Service.Interface.SystemLabel; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace GxPress.Api.AdminControllers { /// <summary> /// 系统标签管理 /// </summary> [Route("api/admin/system-label")] [ApiController] [Authorize] public class AdminSystemLabelController : ControllerBase { private readonly ISystemLabelRepository _repository; private readonly ISystemLableMediaRepository systemLableMediaRepository; private readonly ISystemLabelService systemLabelService; public AdminSystemLabelController(ISystemLabelRepository repository, ISystemLabelService systemLabelService, ISystemLableMediaRepository systemLableMediaRepository) { _repository = repository; this.systemLabelService = systemLabelService; this.systemLableMediaRepository = systemLableMediaRepository; } /// <summary> /// 添加 /// </summary> /// <param name="note"></param> /// <returns></returns> [HttpPost] public async Task<int> Insert(Entity.SystemLabel.SystemLabel note) { return await _repository.InsertAsync(note); } /// <summary> /// 修改 /// </summary> /// <param name="request"></param> /// <returns></returns> [HttpPut] public async Task<bool> UpdateAsync(SystemLabelUpRequest request) { return await _repository.UpdateAsync(request); } /// <summary> /// 获取标签列表 /// </summary> /// <returns></returns> [HttpGet("list")] public async Task<IEnumerable<SystemLabelResult>> GetAllAsync() { return await systemLabelService.GetAllAsync(); } /// <summary> /// 获取标签列表 /// </summary> /// <returns></returns> [HttpPost("list-page")] public async Task<PagedList<SystemLabelResult>> GetAllPageAsync(SystemLabelRequest request) { return await systemLabelService.GetAllPageAsync(request); } /// <summary> /// 删除 /// </summary> /// <param name="id"></param> /// <returns></returns> [HttpDelete("{id}")] public async Task<bool> DeleteAsync(int id) { return await _repository.DeleteAsync(id); } /// <summary> /// 添加标签媒体 /// </summary> /// <param name="request"></param> /// <returns></returns> [HttpPost("add")] public async Task<bool> InsertAsync(SystemLableMediaRequest request) { return await systemLableMediaRepository.InsertAsync(request); } /// <summary> /// 获取明栏分页 /// </summary> /// <param name="request"></param> /// <returns></returns> [HttpPost("star-page")] public async Task<PagedList<SystemLabelResult>> GetAllStarLablePageAsync(Common.Page.PageParameter request) { return await systemLabelService.GetAllStarLablePageAsync(request); } /// <summary> /// 获取明栏 /// </summary> /// <returns></returns> [HttpPost("star-list")] public async Task<IEnumerable<SystemLabelResult>> GetStarLableAllAsync() { return await systemLabelService.GetStarLableAllAsync(); } } }