|
@@ -47,7 +47,17 @@ namespace GxPress.Repository.Implement.Collection
|
|
|
{
|
|
|
return await _repository.InsertAsync(collection);
|
|
|
}
|
|
|
-
|
|
|
+ /// <summary>
|
|
|
+ /// 设置收藏置顶
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="collection"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public async Task<bool> SetTopAsync(int id)
|
|
|
+ {
|
|
|
+ var collction = await _repository.GetAsync(id);
|
|
|
+ collction.IsTop = !collction.IsTop;
|
|
|
+ return await _repository.UpdateAsync(collction);
|
|
|
+ }
|
|
|
/// <summary>
|
|
|
/// 查询结果
|
|
|
/// </summary>
|
|
@@ -276,19 +286,20 @@ namespace GxPress.Repository.Implement.Collection
|
|
|
if (!string.IsNullOrEmpty(request.SearchKey))
|
|
|
sqlStr += $" and a.Title like '%{request.SearchKey}%' ";
|
|
|
var sql = $@"SELECT
|
|
|
- a.Id,a.UserId,a.Title,a.CollectionType,a.CollectionDataId,a.SourceUserId,(select FolderName from tede_middle where id=b.ParentId) as FolderName,b.ParentId
|
|
|
+ a.Id,a.UserId,a.Title,a.CollectionType,a.CollectionDataId,a.SourceUserId,a.IsTop,(select FolderName from tede_middle where id=b.ParentId) as FolderName,b.Id,b.Middle, b.ParentId
|
|
|
FROM
|
|
|
tede_collection a
|
|
|
INNER JOIN
|
|
|
tede_middle b ON a.Id = b.MiddleId AND b.FolderType ={collectionContsValue} {sqlStr}
|
|
|
- AND a.UserId ={request.UserId} and b.IsDelete=0 order by a.CreatedDate desc limit {(request.Page - 1) * request.PerPage},{request.PerPage} ";
|
|
|
+ AND a.UserId ={request.UserId} and b.IsDelete=0 order by a.IsTop desc ,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.MiddleId = middle.Id;
|
|
|
+ result.Id = middle.Id;
|
|
|
result.FolderId = middle != null ? middle.ParentId : 0;
|
|
|
return result;
|
|
|
},
|