李昊 4 anos atrás
pai
commit
d5d028fd6a

+ 83 - 0
gx_api/GxPress/Api/GxPress.Api/AppControllers/MediaController.cs

@@ -0,0 +1,83 @@
+using System.Threading.Tasks;
+using GxPress.Auth;
+using GxPress.Repository.Interface.Media;
+using GxPress.Repository.Interface.Order;
+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.AppControllers
+{
+    /// <summary>
+    /// 媒体
+    /// </summary>
+    [Route("api/app/media")]
+    [ApiController]
+    [Authorize]
+    public class MediaController : Controller
+    {
+        private readonly IMediaRepository mediaRepository;
+        private readonly ILoginContext _loginContext;
+        private readonly IMediaService mediaService;
+        private IHttpContextAccessor _contextAccessor;
+        private readonly IMediaLibraryRepository mediaLibraryRepository;
+        private HttpContext _context { get { return _contextAccessor.HttpContext; } }
+        private readonly IOrderRepository orderRepository;
+        public MediaController(IMediaRepository mediaRepository, ILoginContext _loginContext, IMediaService mediaService, IHttpContextAccessor contextAccessor, IMediaLibraryRepository mediaLibraryRepository, IOrderRepository orderRepository)
+        {
+            this.mediaRepository = mediaRepository;
+            this._loginContext = _loginContext;
+            this.mediaService = mediaService;
+            _contextAccessor = contextAccessor;
+            this.mediaLibraryRepository = mediaLibraryRepository;
+            this.orderRepository = orderRepository;
+        }
+        /// <summary>
+        /// 书籍详情
+        /// /// </summary>
+        /// <param name="id"></param>
+        /// <returns></returns>
+        [HttpGet("book/{id}")]
+        [AllowAnonymous]
+        public async Task<BookMediaResult> GetBookMediaResult(int id)
+        {
+            var result = await mediaService.GetBookMediaResultAsync(id, _loginContext.AccountId);
+            if (_loginContext.AccountId > 0 && result.FreeProportion == 0)
+                result.IsBuy = true;
+            else if (_loginContext.AccountId > 0)
+                result.IsBuy = await orderRepository.GetExistsAsync(_loginContext.AccountId, id);
+            return result;
+        }
+        /// <summary>
+        /// 获取视频详情
+        /// </summary>
+        /// <param name="id"></param>
+        /// <returns></returns>
+        [HttpGet("video/{id}")]
+        [AllowAnonymous]
+        public async Task<VideoMediaResult> GetVideoMediaResultAsync(int id)
+        {
+            var result = await mediaService.GetVideoMediaResultAsync(id);
+            if (_loginContext.AccountId > 0 && result.FreeProportion == 0)
+                result.IsBuy = true;
+            else if (_loginContext.AccountId > 0)
+                result.IsBuy = await orderRepository.GetExistsAsync(_loginContext.AccountId, id);
+            return result;
+        }
+        /// <summary>
+        /// 获取章节内容
+        /// </summary>
+        /// <param name="request"></param>
+        /// <returns></returns>
+        [HttpPost("book/content")]
+        [AllowAnonymous]
+        public async Task<string> GetBookMediaContentResultAsync(BookCatalogRequest request)
+        {
+            request.UserId = _loginContext.AccountId;
+            return await mediaService.GetBookMediaContentResultAsync(request);
+        }
+    }
+}

+ 1 - 0
gx_api/GxPress/Service/GxPress.Service.Implement/AppHomePage/AppHomePageService.Sku.cs

@@ -18,6 +18,7 @@ namespace GxPress.Service.Implement.AppHomePage
             //出版社
             var pressList = await mediaRepository.GetPresssAsync();
             var PressSiftList = new List<PressSift>();
+            PressSiftList.Add(new PressSift { Key = 0, Value = "全部" });
             foreach (var item in pressList)
                 PressSiftList.Add(new PressSift { Key = 0, Value = item });
             result.PressSift = PressSiftList;