AdminAppChannelController.cs 5.6 KB

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