李昊 %!s(int64=4) %!d(string=hai) anos
pai
achega
696baa93b2

+ 0 - 3
gx_api/GxPress/Infrastructure/GxPress.Common/Page/PageParameter.cs

@@ -1,6 +1,3 @@
-using System.Collections.Generic;
-using GxPress.Common.Validation;
-
 namespace GxPress.Common.Page
 {
     /// <summary>

+ 15 - 0
gx_api/GxPress/Model/GxPress.Request/Media/MediaRequest.cs

@@ -192,6 +192,21 @@ namespace GxPress.Request.Media
         /// </summary>
         /// <value></value>
         public string KeyWord { get; set; }
+        /// <summary>
+        /// 开始时间
+        /// </summary>
+        /// <value></value>
+        public string BeginTime { get; set; }
+        /// <summary>
+        /// 结束时间
+        /// </summary>
+        /// <value></value>
+        public string EndTime { get; set; }
+        /// <summary>
+        /// 是否上下架 0全部 1 上架 2下架
+        /// </summary>
+        /// <value></value>
+        public int IsChecked { get; set; }
 
     }
 }

+ 25 - 3
gx_api/GxPress/Repository/GxPress.Repository.Implement/Media/MediaRepository.cs

@@ -162,21 +162,43 @@ namespace GxPress.Repository.Implement.Media
         {
             return await _repository.UpdateAsync(query) > 0;
         }
-
+        /// <summary>
+        /// 查询
+        /// </summary>
+        /// <param name="request"></param>
+        /// <returns></returns>
         public async Task<PagedList<Entity.tede2.Media.Media>> GetAllAsync(MediaSearchRequest request)
         {
             var result = new PagedList<Entity.tede2.Media.Media>();
             var query = Q.NewQuery();
             if (!string.IsNullOrEmpty(request.KeyWord))
-                query.WhereLike(nameof(Entity.tede2.Media.Media.Title), $"%{request.KeyWord}%");
+            {
+                query.OrWhereLike(nameof(Entity.tede2.Media.Media.Title), $"%{request.KeyWord}%");
+                query.OrWhereLike(nameof(Entity.tede2.Media.Media.Creator), $"%{request.KeyWord}%");
+            }
             if (request.IsDelete > 0)
                 query.Where(nameof(Entity.tede2.Media.Media.IsDelete), request.IsDelete == 1);
             if (request.MediaType > 0)
                 query.Where(nameof(Entity.tede2.Media.Media.MediaType), request.MediaType);
             if (request.LibraryType > 0)
                 query.Where(nameof(Entity.tede2.Media.Media.IsLibrary), request.LibraryType == 1);
+            if (!string.IsNullOrEmpty(request.BeginTime) && !string.IsNullOrEmpty(request.EndTime))
+            {
+                if (DateTime.TryParse(request.BeginTime, out var beginTime) && DateTime.TryParse(request.EndTime, out var endTime))
+                {
+                    query.WhereDate(nameof(Entity.tede2.Media.Media.CreatedDate), ">=", beginTime);
+                    query.WhereDate(nameof(Entity.tede2.Media.Media.CreatedDate), "<=", endTime);
+                }
+            }
+            if (request.IsChecked > 0)
+                query.Where(nameof(Entity.tede2.Media.Media.IsChecked), request.IsChecked == 1);
             result.Total = await _repository.CountAsync(query);
-            var item = await _repository.GetAllAsync(query.OrderByDesc(nameof(Entity.tede2.Media.Media.CreatedDate)).ForPage(request.Page, request.PerPage));
+            //排序
+            if (string.IsNullOrEmpty(request.Sort))
+                query.OrderByDesc(nameof(Entity.tede2.Media.Media.CreatedDate));
+            else
+                query.OrderByDesc(nameof(Entity.tede2.Media.Media.SellAmount));
+            var item = await _repository.GetAllAsync(query.ForPage(request.Page, request.PerPage));
             result.Items = item;
             return result;
         }