WebMediaController.cs 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. using System.Threading.Tasks;
  2. using GxPress.Auth;
  3. using GxPress.Repository.Interface.Media;
  4. using GxPress.Request.Media;
  5. using GxPress.Result.Media;
  6. using GxPress.Service.Interface.Media;
  7. using Microsoft.AspNetCore.Authorization;
  8. using Microsoft.AspNetCore.Http;
  9. using Microsoft.AspNetCore.Mvc;
  10. namespace GxPress.Api.WebControllers
  11. {
  12. /// <summary>
  13. /// 媒体
  14. /// </summary>
  15. [Route("api/web/media")]
  16. [ApiController]
  17. [Authorize]
  18. public class WebMediaController : Controller
  19. {
  20. private readonly IMediaRepository mediaRepository;
  21. private readonly ILoginContext _loginContext;
  22. private readonly IMediaService mediaService;
  23. private readonly IHttpContextAccessor httpContextAccessor;
  24. public WebMediaController(IMediaRepository mediaRepository, ILoginContext _loginContext, IMediaService mediaService, IHttpContextAccessor httpContextAccessor)
  25. {
  26. this.mediaRepository = mediaRepository;
  27. this._loginContext = _loginContext;
  28. this.mediaService = mediaService;
  29. this.httpContextAccessor = httpContextAccessor;
  30. }
  31. /// <summary>
  32. /// 详情
  33. /// </summary>
  34. /// <param name="id"></param>
  35. /// <returns></returns>
  36. [HttpGet("{id}")]
  37. [AllowAnonymous]
  38. public async Task<MediaResult> GetAsync(int id)
  39. {
  40. return await mediaService.GetAsync(id);
  41. }
  42. /// <summary>
  43. /// 书籍详情
  44. /// /// </summary>
  45. /// <param name="id"></param>
  46. /// <returns></returns>
  47. [HttpGet("book/{id}")]
  48. [AllowAnonymous]
  49. public async Task<BookMediaResult> GetBookMediaResult(int id)
  50. {
  51. return await mediaService.GetBookMediaResultAsync(id);
  52. }
  53. /// <summary>
  54. /// 获取章节内容
  55. /// </summary>
  56. /// <param name="request"></param>
  57. /// <returns></returns>
  58. [HttpPost("book/content")]
  59. [AllowAnonymous]
  60. public async Task<string> GetBookMediaContentResultAsync(BookCatalogRequest request)
  61. {
  62. return await mediaService.GetBookMediaContentResultAsync(request);
  63. }
  64. }
  65. }