李昊 4 years ago
parent
commit
1e8a0c405a

+ 1 - 0
gx_api/GxPress/Api/GxPress.Api/AdminControllers/AdminFileController.cs

@@ -28,6 +28,7 @@ namespace GxPress.Api.AdminControllers
         /// <param name="file"></param>
         /// <returns></returns>
         [HttpPost("upload")]
+        [DisableRequestSizeLimit]
         public async Task<ResultPath> Upload(IFormFile file)
         {
             if (file == null) throw new BusinessException("请选择需要上传的文件");

+ 5 - 2
gx_api/GxPress/Api/GxPress.Api/AppControllers/FileController.cs

@@ -44,8 +44,9 @@ namespace GxPress.Api.AppControllers
         /// </summary>
         /// <param name="file"></param>
         /// <returns></returns>
-        [AllowAnonymous]
         [HttpPost("upload")]
+        [AllowAnonymous]
+        [DisableRequestSizeLimit]
         public async Task<ResultPath> Upload(IFormFile file)
         {
             if (file == null) throw new BusinessException("请选择需要上传的文件");
@@ -91,6 +92,7 @@ namespace GxPress.Api.AppControllers
         /// <returns></returns>
         [HttpPost("uploads")]
         [AllowAnonymous]
+        [DisableRequestSizeLimit]
         public async Task<List<ResultPath>> Uploads(List<IFormFile> file)
         {
             if (file == null) throw new BusinessException("请选择需要上传的文件");
@@ -169,6 +171,7 @@ namespace GxPress.Api.AppControllers
         /// <returns></returns>
         [HttpPost("upload-files")]
         [AllowAnonymous]
+        [DisableRequestSizeLimit]
         public async Task<List<ResultPath>> UploadFiles(List<IFormFile> file, [FromForm] string code)
         {
             if (string.IsNullOrWhiteSpace(code))
@@ -194,7 +197,7 @@ namespace GxPress.Api.AppControllers
 
                 var saveResult = FileHelper.SaveFile(StringUtils.GetWebRootPath(_environment.WebRootPath), item.FileName,
                     bytes);
-                saveResult.AbsolutePath =StringUtils.AddDomain(saveResult.RelativePath) +
+                saveResult.AbsolutePath = StringUtils.AddDomain(saveResult.RelativePath) +
                                           saveResult.RelativePath;
                 saveResult.FileName = item.FileName;
                 saveResult.FileType = item.FileName.Split('.')[item.FileName.Split('.').Length - 1];

+ 9 - 0
gx_api/GxPress/Api/GxPress.Api/AppControllers/MiddleController.cs

@@ -208,6 +208,15 @@ namespace GxPress.Api.AppControllers
         /// </summary>
         /// <returns></returns>
         [HttpGet("lately-folder")]
+        public async Task<List<MiddleSearchFolderResult>> GetLatelyTopicFolderAsync()
+        {
+            return await _middleService.GetLatelyTopicFolderAsync(_loginContext.AccountId);
+        }
+        /// <summary>
+        /// 获取笔记最近使用的文件夹
+        /// </summary>
+        /// <returns></returns>
+        [HttpGet("lately-folder-note")]
         public async Task<List<MiddleSearchFolderResult>> GetLatelyNoteFolderAsync()
         {
             return await _middleService.GetLatelyNoteFolderAsync(_loginContext.AccountId);

+ 3 - 1
gx_api/GxPress/Api/GxPress.Api/WebControllers/WebFileController.cs

@@ -46,6 +46,7 @@ namespace GxPress.Api.WebControllers
         /// <returns></returns>
         [AllowAnonymous]
         [HttpPost("upload")]
+        [DisableRequestSizeLimit]
         public async Task<ResultPath> Upload(IFormFile file)
         {
             if (file == null) throw new BusinessException("请选择需要上传的文件");
@@ -91,6 +92,7 @@ namespace GxPress.Api.WebControllers
         /// <returns></returns>
         [HttpPost("uploads")]
         [AllowAnonymous]
+        [DisableRequestSizeLimit]
         public async Task<List<ResultPath>> Uploads(List<IFormFile> file)
         {
             if (file == null) throw new BusinessException("请选择需要上传的文件");
@@ -169,6 +171,7 @@ namespace GxPress.Api.WebControllers
         /// <returns></returns>
         [HttpPost("upload-files")]
         [AllowAnonymous]
+        [DisableRequestSizeLimit]
         public async Task<List<ResultPath>> UploadFiles(List<IFormFile> file, [FromForm] string code)
         {
             if (string.IsNullOrWhiteSpace(code))
@@ -221,7 +224,6 @@ namespace GxPress.Api.WebControllers
                 saveResult.FileId = await fileLibraryService.InsertAsync(fileLibrary);
                 result.Add(saveResult);
             }
-
             return result;
         }
     }

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

@@ -219,6 +219,15 @@ namespace GxPress.Api.WebControllers
         /// </summary>
         /// <returns></returns>
         [HttpGet("lately-folder")]
+        public async Task<List<MiddleSearchFolderResult>> GetLatelyTopicFolderAsync()
+        {
+            return await _middleService.GetLatelyTopicFolderAsync(_loginContext.AccountId);
+        }
+        /// <summary>
+        /// 获取笔记最近使用的文件夹
+        /// </summary>
+        /// <returns></returns>
+        [HttpGet("lately-folder-note")]
         public async Task<List<MiddleSearchFolderResult>> GetLatelyNoteFolderAsync()
         {
             return await _middleService.GetLatelyNoteFolderAsync(_loginContext.AccountId);

+ 45 - 2
gx_api/GxPress/Service/GxPress.Service.Implement/Middle/MiddleService.cs

@@ -825,7 +825,7 @@ namespace GxPress.Service.Implement.Middle
                             ORDER BY IsSystemDefault DESC,AttributeValue desc , IsTop DESC , Sort DESC , CreatedDate DESC";
             var database = new Database(DatabaseType.MySql, ConfigHelper.GetValue("Database:ConnectionString"));
             var connection = database.GetConnection();
-            var middles =await connection.QueryAsync<Entity.Middle.Middle>(sql);
+            var middles = await connection.QueryAsync<Entity.Middle.Middle>(sql);
             // var query = Q.NewQuery();
             // if (request.ParentId >= 0)
             //     query.Where(nameof(Entity.Middle.Middle.ParentId), request.ParentId);
@@ -874,7 +874,7 @@ namespace GxPress.Service.Implement.Middle
         /// </summary>
         /// <param name="request"></param>
         /// <returns></returns>
-        public async Task<List<MiddleSearchFolderResult>> GetLatelyNoteFolderAsync(int userId)
+        public async Task<List<MiddleSearchFolderResult>> GetLatelyTopicFolderAsync(int userId)
         {
             //获取用户最近发布的话题
             var folderIds = await _noteRepository.GetLatelyFolderIdAsync(userId);
@@ -913,6 +913,49 @@ namespace GxPress.Service.Implement.Middle
 
             return result;
         }
+        /// <summary>
+        /// 获取笔记最近使用的文件夹
+        /// </summary>
+        /// <param name="request"></param>
+        /// <returns></returns>
+        public async Task<List<MiddleSearchFolderResult>> GetLatelyNoteFolderAsync(int userId)
+        {
+            //获取用户最近发布的话题
+            var folderIds = await _noteRepository.GetLatelyFolderIdAsync(userId);
+            var query = Q.NewQuery();
+            query.Where(nameof(Entity.Middle.Middle.AttributeValue), 2)
+                .Where(nameof(Entity.Middle.Middle.FolderType), AllTypeConst.Note.GetHashCode())
+                .Where(nameof(Entity.Middle.Middle.UserId), userId)
+                .Where(nameof(Entity.Middle.Middle.IsDelete), false)
+                .WhereIn(nameof(Entity.Middle.Middle.Id), folderIds);
+            query.WhereIn(nameof(Entity.Middle.Middle.RoleId), new List<int>() { 2 });
+            var middles = await _middleRepository.FindAsync(query.OrderByDesc(nameof(Entity.Middle.Middle.CreatedDate)));
+            List<MiddleSearchFolderResult> result = new List<MiddleSearchFolderResult>();
+            foreach (var item in middles)
+            {
+                MiddleSearchFolderResult middleSearchFolderResult = new MiddleSearchFolderResult
+                {
+                    Name = item.FolderName,
+                    Id = item.Id,
+                    IsDisable = false,
+                    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), "、");
+                    //middleSearchFolderResult.EnjoyUser = StringUtils.ObjectCollectionToString(folderUsers.Select(n => n.UserName), "、");
+                }
+                result.Add(middleSearchFolderResult);
+            }
+            return result;
+        }
         /// <summary> =-
         /// 删除全部
         /// </summary>

+ 6 - 0
gx_api/GxPress/Service/GxPress.Service.Interface/Middle/IMiddleService.cs

@@ -114,5 +114,11 @@ namespace GxPress.Service.Interface.Middle
         /// <param name="request"></param>
         /// <returns></returns>
         Task<MiddleSearchFolderByParendIsResult> SearchFolderAndParentIdAsync(MiddleSearchFolderRequest request);
+        /// <summary>
+        /// 获取话题最近使用的文件夹
+        /// </summary>
+        /// <param name="request"></param>
+        /// <returns></returns>
+        Task<List<MiddleSearchFolderResult>> GetLatelyTopicFolderAsync(int userId);
     }
 }