12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- using System.Threading.Tasks;
- using GxPress.Auth;
- using GxPress.Repository.Interface.Media;
- using GxPress.Request.Media;
- using GxPress.Result.Media;
- using GxPress.Service.Interface.Media;
- using Microsoft.AspNetCore.Authorization;
- using Microsoft.AspNetCore.Http;
- using Microsoft.AspNetCore.Mvc;
- namespace GxPress.Api.WebControllers
- {
- /// <summary>
- /// 媒体
- /// </summary>
- [Route("api/web/media")]
- [ApiController]
- [Authorize]
- public class WebMediaController : Controller
- {
- private readonly IMediaRepository mediaRepository;
- private readonly ILoginContext _loginContext;
- private readonly IMediaService mediaService;
- private readonly IHttpContextAccessor httpContextAccessor;
- public WebMediaController(IMediaRepository mediaRepository, ILoginContext _loginContext, IMediaService mediaService, IHttpContextAccessor httpContextAccessor)
- {
- this.mediaRepository = mediaRepository;
- this._loginContext = _loginContext;
- this.mediaService = mediaService;
- this.httpContextAccessor = httpContextAccessor;
- }
- /// <summary>
- /// 详情
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- [HttpGet("{id}")]
- [AllowAnonymous]
- public async Task<MediaResult> GetAsync(int id)
- {
- return await mediaService.GetAsync(id);
- }
- /// <summary>
- /// 书籍详情
- /// /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- [HttpGet("book/{id}")]
- [AllowAnonymous]
- public async Task<BookMediaResult> GetBookMediaResult(int id)
- {
- return await mediaService.GetBookMediaResultAsync(id);
- }
- /// <summary>
- /// 获取章节内容
- /// </summary>
- /// <param name="request"></param>
- /// <returns></returns>
- [HttpPost("book/content")]
- [AllowAnonymous]
- public async Task<string> GetBookMediaContentResultAsync(BookCatalogRequest request)
- {
- return await mediaService.GetBookMediaContentResultAsync(request);
- }
- }
- }
|