AdminSystemLabelController.cs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. using System.Collections.Generic;
  2. using System.Threading.Tasks;
  3. using GxPress.Common.Page;
  4. using GxPress.Repository.Interface.SystemLabel;
  5. using GxPress.Request.SystemLabel;
  6. using GxPress.Result.SystemLabel;
  7. using GxPress.Service.Interface.SystemLabel;
  8. using Microsoft.AspNetCore.Authorization;
  9. using Microsoft.AspNetCore.Mvc;
  10. namespace GxPress.Api.AdminControllers
  11. {
  12. /// <summary>
  13. /// 系统标签管理
  14. /// </summary>
  15. [Route("api/admin/system-label")]
  16. [ApiController]
  17. [Authorize]
  18. public class AdminSystemLabelController : ControllerBase
  19. {
  20. private readonly ISystemLabelRepository _repository;
  21. private readonly ISystemLableMediaRepository systemLableMediaRepository;
  22. private readonly ISystemLabelService systemLabelService;
  23. public AdminSystemLabelController(ISystemLabelRepository repository, ISystemLabelService systemLabelService, ISystemLableMediaRepository systemLableMediaRepository)
  24. {
  25. _repository = repository;
  26. this.systemLabelService = systemLabelService;
  27. this.systemLableMediaRepository = systemLableMediaRepository;
  28. }
  29. /// <summary>
  30. /// 添加
  31. /// </summary>
  32. /// <param name="note"></param>
  33. /// <returns></returns>
  34. [HttpPost]
  35. public async Task<int> Insert(Entity.SystemLabel.SystemLabel note)
  36. {
  37. return await _repository.InsertAsync(note);
  38. }
  39. /// <summary>
  40. /// 修改
  41. /// </summary>
  42. /// <param name="request"></param>
  43. /// <returns></returns>
  44. [HttpPut]
  45. public async Task<bool> UpdateAsync(SystemLabelUpRequest request)
  46. {
  47. return await _repository.UpdateAsync(request);
  48. }
  49. /// <summary>
  50. /// 获取标签列表
  51. /// </summary>
  52. /// <returns></returns>
  53. [HttpGet("list")]
  54. public async Task<IEnumerable<SystemLabelResult>> GetAllAsync()
  55. {
  56. return await systemLabelService.GetAllAsync();
  57. }
  58. /// <summary>
  59. /// 获取标签列表
  60. /// </summary>
  61. /// <returns></returns>
  62. [HttpPost("list-page")]
  63. public async Task<PagedList<SystemLabelResult>> GetAllPageAsync(Common.Page.PageParameter pageParameter)
  64. {
  65. return await systemLabelService.GetAllPageAsync(pageParameter);
  66. }
  67. /// <summary>
  68. /// 删除
  69. /// </summary>
  70. /// <param name="id"></param>
  71. /// <returns></returns>
  72. [HttpDelete("{id}")]
  73. public async Task<bool> DeleteAsync(int id)
  74. {
  75. return await _repository.DeleteAsync(id);
  76. }
  77. /// <summary>
  78. /// 添加标签媒体
  79. /// </summary>
  80. /// <param name="request"></param>
  81. /// <returns></returns>
  82. [HttpPost("add")]
  83. public async Task<bool> InsertAsync(SystemLableMediaRequest request)
  84. {
  85. return await systemLableMediaRepository.InsertAsync(request);
  86. }
  87. }
  88. }