李昊 il y a 4 ans
Parent
commit
765ba6b0a6

+ 19 - 9
gx_api/GxPress/Service/GxPress.Service.Implement/Middle/MiddleService.cs

@@ -467,10 +467,13 @@ namespace GxPress.Service.Implement.Middle
         {
             var query = Q.NewQuery();
             query.Where(nameof(Entity.Middle.Middle.ParentId), request.ParentId)
-                .Where(nameof(Entity.Middle.Middle.AttributeValue), 2)
-                .Where(nameof(Entity.Middle.Middle.FolderType), request.TypeId)
-                .Where(nameof(Entity.Middle.Middle.UserId), request.UserId)
-                .Where(nameof(Entity.Middle.Middle.IsDelete), false).WhereNotIn(nameof(Entity.Middle.Middle.Id), request.FolderIds);
+                .Where(nameof(Entity.Middle.Middle.AttributeValue), 2);
+            if (request.TypeId == -AllTypeConst.Note.GetHashCode())
+                query.Where(nameof(Entity.Middle.Middle.FolderType), AllTypeConst.Note.GetHashCode());
+            else
+                query.Where(nameof(Entity.Middle.Middle.FolderType), request.TypeId);
+            query.Where(nameof(Entity.Middle.Middle.UserId), request.UserId)
+            .Where(nameof(Entity.Middle.Middle.IsDelete), false).WhereNotIn(nameof(Entity.Middle.Middle.Id), request.FolderIds);
             if (!string.IsNullOrWhiteSpace(request.KeyWord))
                 query.WhereLike(nameof(Entity.Middle.Middle.FolderName), $"%{request.KeyWord}%");
             if (request.TypeId == -AllTypeConst.Note.GetHashCode())
@@ -516,8 +519,12 @@ namespace GxPress.Service.Implement.Middle
             var middle = await _middleRepository.GetMiddleAsync(Q.Where(nameof(Entity.Middle.Middle.Id), request.ParentId));
             var query = Q.NewQuery();
             query.Where(nameof(Entity.Middle.Middle.ParentId), request.ParentId)
-                .Where(nameof(Entity.Middle.Middle.AttributeValue), 2)
-                .Where(nameof(Entity.Middle.Middle.FolderType), request.TypeId)
+                .Where(nameof(Entity.Middle.Middle.AttributeValue), 2);
+            if (request.TypeId == -AllTypeConst.Note.GetHashCode())
+                query.Where(nameof(Entity.Middle.Middle.FolderType), AllTypeConst.Note.GetHashCode());
+            else
+                query.Where(nameof(Entity.Middle.Middle.FolderType), request.TypeId);
+            query.Where(nameof(Entity.Middle.Middle.UserId), request.UserId)
                 .Where(nameof(Entity.Middle.Middle.UserId), request.UserId)
                 .Where(nameof(Entity.Middle.Middle.IsDelete), false).WhereNotIn(nameof(Entity.Middle.Middle.Id), request.FolderIds);
             if (!string.IsNullOrWhiteSpace(request.KeyWord))
@@ -527,7 +534,12 @@ namespace GxPress.Service.Implement.Middle
             if (request.TypeId == AllTypeConst.Note.GetHashCode())
                 query.WhereIn(nameof(Entity.Middle.Middle.RoleId), new List<int> { 1 });
             var middles = await _middleRepository.FindAsync(query.OrderByDesc(nameof(Entity.Middle.Middle.IsTop), nameof(Entity.Middle.Middle.Sort), nameof(Entity.Middle.Middle.LastModifiedDate)));
-            var result = new MiddleSearchFolderByParendIsResult();
+            var result = new MiddleSearchFolderByParendIsResult()
+            {
+                Id = middle == null ? 0 : middle.Id,
+                Name = middle == null ? "" : middle.FolderName
+            };
+            result.Item = new List<MiddleSearchFolderResult>();
             foreach (var item in middles)
             {
                 MiddleSearchFolderResult middleSearchFolderResult = new MiddleSearchFolderResult
@@ -550,8 +562,6 @@ namespace GxPress.Service.Implement.Middle
                 }
                 result.Item.Add(middleSearchFolderResult);
             }
-            result.Id = middle.Id;
-            result.Name = middle.FolderName;
             return result;
         }