|
@@ -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;
|
|
|
}
|