|
@@ -268,16 +268,36 @@ namespace GxPress.Repository.Implement.Collection
|
|
|
/// </summary>
|
|
|
/// <param name="request"></param>
|
|
|
/// <returns></returns>
|
|
|
- public async Task<PagedList<CollectionListPageResult>> GetCollectionNoFolderPageListAsync(CollectionPageSearchRequest request)
|
|
|
+ public async Task<PagedList<CollectionNoFolderResult>> GetCollectionNoFolderPageListAsync(CollectionPageSearchRequest request)
|
|
|
{
|
|
|
- var result = new PagedList<CollectionListPageResult>();
|
|
|
- var query = Q.NewQuery();
|
|
|
- query.Where(nameof(Entity.Collection.UserId), request.UserId);
|
|
|
- if (!string.IsNullOrEmpty(request.SearchKey))
|
|
|
- query.WhereLike(nameof(Entity.Collection.Title), $"%{request.SearchKey}%");
|
|
|
- result.Total = await _repository.CountAsync(query);
|
|
|
- query.ForPage(request.Page, request.PerPage);
|
|
|
- result.Items = await _repository.GetAllAsync<CollectionListPageResult>(query);
|
|
|
+ var result = new PagedList<CollectionNoFolderResult>();
|
|
|
+ var collectionContsValue = GxPress.EnumConst.AllTypeConst.Collect.GetHashCode();
|
|
|
+ var sql = $@"SELECT
|
|
|
+ a.Id,a.UserId,a.CollectionType,a.CollectionDataId,a.SourceUserId,(select FolderName from tede_middle where id=b.ParentId) as FolderName,b.ParentId
|
|
|
+ FROM
|
|
|
+ tede_collection a
|
|
|
+ INNER JOIN
|
|
|
+ tede_middle b ON a.Id = b.MiddleId AND b.FolderType ={collectionContsValue}
|
|
|
+ AND a.UserId ={request.UserId} and b.IsDelete=0 order by a.CreatedDate desc limit {(request.Page - 1) * request.PerPage},{request.PerPage} ";
|
|
|
+ var databaseType = StringUtils.ToEnum<DatabaseType>(_databaseTypestr, DatabaseType.MySql);
|
|
|
+ var database = new Database(databaseType, _connectionString);
|
|
|
+ var connection = database.GetConnection();
|
|
|
+ result.Items = await connection.QueryAsync<CollectionNoFolderResult, Entity.Middle.Middle, CollectionNoFolderResult>(sql,
|
|
|
+ (result, middle) =>
|
|
|
+ {
|
|
|
+ result.MiddleId = result.Id;
|
|
|
+ result.FolderId = middle != null ? middle.ParentId : 0;
|
|
|
+ return result;
|
|
|
+ },
|
|
|
+ splitOn: "ParentId");
|
|
|
+ sql = $@"SELECT
|
|
|
+ count(1)
|
|
|
+ FROM
|
|
|
+ tede_collection a
|
|
|
+ INNER JOIN
|
|
|
+ tede_middle b ON a.Id = b.MiddleId AND b.FolderType ={collectionContsValue}
|
|
|
+ AND a.UserId ={request.UserId} and b.IsDelete=0";
|
|
|
+ result.Total = await connection.ExecuteScalarAsync<int>(sql);
|
|
|
return result;
|
|
|
}
|
|
|
}
|