李昊 4 lat temu
rodzic
commit
49d3db1a45

+ 11 - 0
gx_api/GxPress/Api/GxPress.Api/WebControllers/WebMiddleController.cs

@@ -151,6 +151,17 @@ namespace GxPress.Api.WebControllers
             request.UserId = _loginContext.AccountId;
             return await _middleService.SearchFolderAsync(request);
         }
+        /// <summary>
+        /// 查询文件夹包含父级
+        /// </summary>
+        /// <param name="request"></param>
+        /// <returns></returns>
+        [HttpPost("search-folder-parent")]
+        public async Task<MiddleSearchFolderByParendIsResult> SearchFolderAndParentIdAsync(MiddleSearchFolderRequest request)
+        {
+            request.UserId = _loginContext.AccountId;
+            return await _middleService.SearchFolderAndParentIdAsync(request);
+        }
 
         /// <summary>
         /// 获取话题 笔记共享范围文件夹

+ 0 - 4
gx_api/GxPress/Model/GxPress.Request/App/Middle/MiddleSearchFolderRequest.cs

@@ -27,10 +27,6 @@ namespace GxPress.Request.App.Middle
         public List<int> FolderIds { get; set; }
 
         /// <summary>
-        /// 文件夹类型 1公开 2私有 3 共享  0 所以
-        /// </summary>
-        public int RoleId { get; set; }
-        /// <summary>
         /// 
         /// </summary>
         public MiddleSearchFolderRequest()

+ 12 - 0
gx_api/GxPress/Model/GxPress.Result/App/Middle/MiddleSearchFolderResult.cs

@@ -1,3 +1,5 @@
+using System.Collections.Generic;
+
 namespace GxPress.Result.App.Middle
 {
     /// <summary>
@@ -47,4 +49,14 @@ namespace GxPress.Result.App.Middle
         /// <value></value>
         public bool IsSystemDefault { get; set; }
     }
+    /// <summary>
+    /// 
+    /// </summary>
+    public class MiddleSearchFolderByParendIsResult
+    {
+        public List<MiddleSearchFolderResult> Item { get; set; }
+        public int Id { get; set; }
+
+        public string Name { get; set; }
+    }
 }

+ 55 - 3
gx_api/GxPress/Service/GxPress.Service.Implement/Middle/MiddleService.cs

@@ -473,8 +473,10 @@ namespace GxPress.Service.Implement.Middle
                 .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.RoleId > 0)
-                query.Where(nameof(Entity.Middle.Middle.RoleId), request.RoleId);
+            if (request.TypeId == -AllTypeConst.Note.GetHashCode())
+                query.WhereIn(nameof(Entity.Middle.Middle.RoleId), new List<int> { 1, 3 });
+            else
+                query.Where(nameof(Entity.Middle.Middle.RoleId), 2);
             var middles = await _middleRepository.FindAsync(query.OrderByDesc(nameof(Entity.Middle.Middle.IsTop), nameof(Entity.Middle.Middle.Sort), nameof(Entity.Middle.Middle.LastModifiedDate)));
             List<MiddleSearchFolderResult> result = new List<MiddleSearchFolderResult>();
             foreach (var item in middles)
@@ -503,6 +505,56 @@ namespace GxPress.Service.Implement.Middle
             return result;
         }
 
+
+        /// <summary>
+        /// 查询文件夹包含父级
+        /// </summary>
+        /// <param name="request"></param>
+        /// <returns></returns>
+        public async Task<MiddleSearchFolderByParendIsResult> SearchFolderAndParentIdAsync(MiddleSearchFolderRequest request)
+        {
+            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.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())
+                query.WhereIn(nameof(Entity.Middle.Middle.RoleId), new List<int> { 1, 3 });
+            else
+                query.Where(nameof(Entity.Middle.Middle.RoleId), 2);
+            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();
+            foreach (var item in middles)
+            {
+                MiddleSearchFolderResult middleSearchFolderResult = new MiddleSearchFolderResult
+                {
+                    Name = item.FolderName,
+                    Id = item.Id,
+                    IsDisable = request.FolderIds.Any(n => n.Equals(item.Id)),
+                    RoleId = item.RoleId,
+                    IsFolder = await _middleRepository.IsFolderAsync(item.Id),
+                    IsTop = item.IsTop
+                };
+                if (item.RoleId == 3)
+                {
+                    var sourceId = item.Id;
+                    if (item.ParentId != 0)
+                        sourceId = item.MiddleSonId;
+                    var userMiddles = await _userMiddleService.FindUserMiddlesAsync(item.FolderType, sourceId);
+                    // var folderUsers = await _folderUserRepository.GetAllAsync(Q.Where(nameof(FolderUser.MiddleId), item.Id).OrderByDesc(nameof(FolderUser.CreatedDate)).Take(10));
+                    middleSearchFolderResult.EnjoyUser = StringUtils.ObjectCollectionToString(userMiddles.Select(n => n.SourceName), "、");
+                }
+                result.Item.Add(middleSearchFolderResult);
+            }
+            result.Id = middle.Id;
+            result.Name = middle.FolderName;
+            return result;
+        }
+
         /// <summary>
         /// 修改权限
         /// </summary>
@@ -685,7 +737,7 @@ namespace GxPress.Service.Implement.Middle
                     RoleId = item.RoleId,
                     IsFolder = await _middleRepository.IsFolderAsync(item.Id),
                     IsTop = item.IsTop,
-                    FileCount = await _middleRepository.CountAsync(Q.Where(nameof(Entity.Middle.Middle.ParentId), item.Id).Where(nameof(Entity.Middle.Middle.IsDelete),false)),
+                    FileCount = await _middleRepository.CountAsync(Q.Where(nameof(Entity.Middle.Middle.ParentId), item.Id).Where(nameof(Entity.Middle.Middle.IsDelete), false)),
                     IsSystemDefault = item.IsSystemDefault
                 };
                 if (item.RoleId == 3)

+ 8 - 2
gx_api/GxPress/Service/GxPress.Service.Interface/Middle/IMiddleService.cs

@@ -80,7 +80,7 @@ namespace GxPress.Service.Interface.Middle
         /// </summary>
         /// <param name="userId"></param>
         /// <returns></returns>
-        Task<MiddleDefaultResult> GetEnjoyDefaultAsync(int userId,int folderType);
+        Task<MiddleDefaultResult> GetEnjoyDefaultAsync(int userId, int folderType);
 
         /// <summary>
         /// 获取话题 笔记共享范围文件夹
@@ -102,11 +102,17 @@ namespace GxPress.Service.Interface.Middle
         /// <param name="userId"></param>
         /// <returns></returns>
         Task<bool> DeleteAllAsync(int folderType, int userId);
-           /// <summary>
+        /// <summary>
         /// 获取话题最近使用的文件夹
         /// </summary>
         /// <param name="request"></param>
         /// <returns></returns>
         Task<List<MiddleSearchFolderResult>> GetLatelyNoteFolderAsync(int userId);
+        /// <summary>
+        /// 查询文件夹包含父级
+        /// </summary>
+        /// <param name="request"></param>
+        /// <returns></returns>
+        Task<MiddleSearchFolderByParendIsResult> SearchFolderAndParentIdAsync(MiddleSearchFolderRequest request);
     }
 }