WebMediaController.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using System.Threading.Tasks;
  2. using GxPress.Auth;
  3. using GxPress.Repository.Interface.Media;
  4. using GxPress.Result.Media;
  5. using GxPress.Service.Interface.Media;
  6. using Microsoft.AspNetCore.Authorization;
  7. using Microsoft.AspNetCore.Http;
  8. using Microsoft.AspNetCore.Mvc;
  9. namespace GxPress.Api.WebControllers
  10. {
  11. /// <summary>
  12. /// 媒体
  13. /// </summary>
  14. [Route("api/web/media")]
  15. [ApiController]
  16. [Authorize]
  17. public class WebMediaController : Controller
  18. {
  19. private readonly IMediaRepository mediaRepository;
  20. private readonly ILoginContext _loginContext;
  21. private readonly IMediaService mediaService;
  22. private readonly IHttpContextAccessor httpContextAccessor;
  23. public WebMediaController(IMediaRepository mediaRepository, ILoginContext _loginContext, IMediaService mediaService, IHttpContextAccessor httpContextAccessor)
  24. {
  25. this.mediaRepository = mediaRepository;
  26. this._loginContext = _loginContext;
  27. this.mediaService = mediaService;
  28. this.httpContextAccessor = httpContextAccessor;
  29. }
  30. /// <summary>
  31. /// 详情
  32. /// </summary>
  33. /// <param name="id"></param>
  34. /// <returns></returns>
  35. [HttpGet("{id}")]
  36. [AllowAnonymous]
  37. public async Task<MediaResult> GetAsync(int id)
  38. {
  39. return await mediaService.GetAsync(id);
  40. }
  41. }
  42. }