AdminAppChannelController.cs 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. using System.Collections.Generic;
  2. using System.Threading.Tasks;
  3. using GxPress.Entity.tede2.AppChannel;
  4. using GxPress.EnumConst;
  5. using GxPress.Repository.Interface.AppChannel;
  6. using GxPress.Request.AppChannel;
  7. using GxPress.Result.AppChannel;
  8. using Microsoft.AspNetCore.Authorization;
  9. using Microsoft.AspNetCore.Mvc;
  10. namespace GxPress.Api.AdminControllers
  11. {
  12. /// <summary>
  13. /// APP频道
  14. /// </summary>
  15. [Route("api/admin/app-channel")]
  16. [ApiController]
  17. [Authorize]
  18. public class AdminAppChannelController : Controller
  19. {
  20. private readonly IChannelCategoryMediaRepository channelCategoryMediaRepository;
  21. private readonly IChannelCategoryRepository channelCategoryRepository;
  22. private readonly IAppChannelRepository appChannelRepository;
  23. public AdminAppChannelController(IChannelCategoryMediaRepository channelCategoryMediaRepository, IChannelCategoryRepository channelCategoryRepository, IAppChannelRepository appChannelRepository)
  24. {
  25. this.channelCategoryMediaRepository = channelCategoryMediaRepository;
  26. this.channelCategoryRepository = channelCategoryRepository;
  27. this.appChannelRepository = appChannelRepository;
  28. }
  29. /// <summary>
  30. /// 获取导航详情
  31. /// </summary>
  32. /// <param name="id"></param>
  33. /// <returns></returns>
  34. [HttpGet("channel/{id}")]
  35. public async Task<Entity.tede2.AppChannel.AppChannel> GetAsync(int id)
  36. {
  37. return await appChannelRepository.GetAsync(id);
  38. }
  39. /// <summary>
  40. /// 查询 公众号 700 视频 710 期刊杂志 720 图书 730
  41. /// </summary>
  42. /// <returns></returns>
  43. [HttpGet("channel/list/{channelTypeValye}")]
  44. public async Task<IEnumerable<Entity.tede2.AppChannel.AppChannel>> GetAllAsync(int channelTypeValye)
  45. {
  46. return await appChannelRepository.GetAllAsync((AppChannelConst)channelTypeValye);
  47. }
  48. /// <summary>
  49. /// 删除导航
  50. /// </summary>
  51. /// <param name="id"></param>
  52. /// <returns></returns>
  53. [HttpDelete("channel/{id}")]
  54. public async Task<bool> DeleteAsync(int id)
  55. {
  56. return await appChannelRepository.DeleteAsync(id);
  57. }
  58. /// <summary>
  59. /// 修改导航
  60. /// </summary>
  61. /// <param name="request"></param>
  62. /// <returns></returns>
  63. [HttpPut("channel")]
  64. public async Task<bool> UpdateAsync(Entity.tede2.AppChannel.AppChannel request)
  65. {
  66. return await appChannelRepository.UpdateAsync(request);
  67. }
  68. /// <summary>
  69. /// 添加导航
  70. /// </summary>
  71. /// <param name="model"></param>
  72. /// <returns></returns>
  73. [HttpPost("channel")]
  74. public async Task<bool> InsertAsync(Entity.tede2.AppChannel.AppChannel model)
  75. {
  76. return await appChannelRepository.InsertAsync(model);
  77. }
  78. /// <summary>
  79. /// 获取导航分类详情
  80. /// </summary>
  81. /// <param name="id"></param>
  82. /// <returns></returns>
  83. [HttpGet("channel-category/{id}")]
  84. public async Task<Entity.tede2.AppChannel.ChannelCategory> ChannelCategoryGetAsync(int id)
  85. {
  86. return await channelCategoryRepository.GetAsync(id);
  87. }
  88. /// <summary>
  89. /// 查询导航分类
  90. /// </summary>
  91. /// <returns></returns>
  92. [HttpGet("channel-category/list/{appChannelId}")]
  93. public async Task<IEnumerable<ChannelCategoryResult>> ChannelCategoryGetAllAsync(int appChannelId)
  94. {
  95. return await channelCategoryRepository.GetAllAsync(appChannelId);
  96. }
  97. /// <summary>
  98. /// 删除导航分类
  99. /// </summary>
  100. /// <param name="id"></param>
  101. /// <returns></returns>
  102. [HttpDelete("channel-category/{id}")]
  103. public async Task<bool> ChannelCategoryDeleteAsync(int id)
  104. {
  105. return await channelCategoryRepository.DeleteAsync(id);
  106. }
  107. /// <summary>
  108. /// 添加导航分类
  109. /// </summary>
  110. /// <param name="request"></param>
  111. /// <returns></returns>
  112. [HttpPost("channel-category")]
  113. public async Task<bool> InsertAsync(ChannelCategory request)
  114. {
  115. return await channelCategoryRepository.InsertAsync(request);
  116. }
  117. /// <summary>
  118. /// 删除导航媒体
  119. /// </summary>
  120. /// <param name="id"></param>
  121. /// <returns></returns>
  122. [HttpDelete("channel-category-media/{id}")]
  123. public async Task<bool> ChannelCategoryMediaDeleteAsync(int id)
  124. {
  125. return await channelCategoryMediaRepository.DeleteAsync(id);
  126. }
  127. /// <summary>
  128. /// 添加导航媒体
  129. /// </summary>
  130. /// <param name="request"></param>
  131. /// <returns></returns>
  132. [HttpPost("channel-category-media")]
  133. public async Task<bool> ChannelCategoryMediaInsertAsync(ChannelCategoryMediaInRequest request)
  134. {
  135. return await channelCategoryMediaRepository.InsertAsync(request);
  136. }
  137. }
  138. }