李昊 4 years ago
parent
commit
611bc99867

+ 5 - 2
gx_api/GxPress/Repository/GxPress.Repository.Implement/Collection/CollectionRepository.cs

@@ -272,12 +272,15 @@ namespace GxPress.Repository.Implement.Collection
         {
             var result = new PagedList<CollectionNoFolderResult>();
             var collectionContsValue = GxPress.EnumConst.AllTypeConst.Collect.GetHashCode();
+            var sqlStr = string.Empty;
+            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
                         FROM
                             tede_collection a
                                 INNER JOIN
-                            tede_middle b ON a.Id = b.MiddleId AND b.FolderType ={collectionContsValue}
+                            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} ";
             var databaseType = StringUtils.ToEnum<DatabaseType>(_databaseTypestr, DatabaseType.MySql);
             var database = new Database(databaseType, _connectionString);
@@ -295,7 +298,7 @@ namespace GxPress.Repository.Implement.Collection
                         FROM
                             tede_collection a
                                 INNER JOIN
-                            tede_middle b ON a.Id = b.MiddleId AND b.FolderType ={collectionContsValue}
+                            tede_middle b ON a.Id = b.MiddleId AND b.FolderType ={collectionContsValue} {sqlStr}
                                 AND a.UserId ={request.UserId} and b.IsDelete=0";
             result.Total = await connection.ExecuteScalarAsync<int>(sql);
             return result;