lihao 4 years ago
parent
commit
6594809559

+ 12 - 14
gx_api/GxPress/Repository/GxPress.Repository.Implement/RecordFolder/RecordFolderRepository.cs

@@ -39,24 +39,22 @@ namespace GxPress.Repository.Implement.RecordFolder
             query.Where(nameof(Entity.RecordFolder.RecordFolder.FolderType), folderType);
             query.OrderByDesc(nameof(Entity.RecordFolder.RecordFolder.CreatedDate));
             var recordFolder = await _repository.GetAsync(query);
-            if (recordFolder == null)
-            {
-                recordFolder = new Entity.RecordFolder.RecordFolder();
-                recordFolder.FolderId = 0;
-            }
+            if (recordFolder != null)
+                return recordFolder;
+            recordFolder = new Entity.RecordFolder.RecordFolder();
             //获取文件夹
-            query = Q.NewQuery();
-            query.Where(nameof(Entity.Middle.Middle.Id), recordFolder.FolderId);
-            query.Where(nameof(Entity.Middle.Middle.IsDelete), false);
+            var middle = new Entity.Middle.Middle();
             if (folderType == GxPress.EnumConst.AllTypeConst.TopicNote.GetHashCode())
-                query.WhereIn(nameof(Entity.Middle.Middle.RoleId), new List<int> { 1, 3 });
-            if (folderType == GxPress.EnumConst.AllTypeConst.Note.GetHashCode())
-                query.Where(nameof(Entity.Middle.Middle.RoleId), 2);
-            var middle = await _middleRepository.GetAsync(query);
-            if (folderType == GxPress.EnumConst.AllTypeConst.TopicNote.GetHashCode() && middle == null)
-                middle = await _middleRepository.GetAsync(Q.Where(nameof(Entity.Middle.Middle.FolderType), folderType).Where(nameof(Entity.Middle.Middle.IsSystemDefault), true));
+            {
+                query = Q.NewQuery();
+                query.Where(nameof(Entity.Middle.Middle.FolderType), folderType);
+                query.Where(nameof(Entity.Middle.Middle.IsSystemDefault), true);
+                query.Where(nameof(Entity.Middle.Middle.UserId), userId);
+                middle = await _middleRepository.GetAsync(query);
+            }
             recordFolder.FolderName = middle != null ? middle.FolderName : "";
             recordFolder.FolderId = middle != null ? middle.Id : 0;
+            recordFolder.FolderType = folderType;
             return recordFolder;
         }
         /// <summary>

+ 0 - 16
gx_api/GxPress/Service/GxPress.Service.Implement/Middle/MiddleService.cs

@@ -820,22 +820,6 @@ namespace GxPress.Service.Implement.Middle
         {
             var recordFolder = await recordFolderRepository.GetAsync(folderType, userId);
             var result = new MiddleDefaultResult();
-            //获取笔记默认
-            if (recordFolder.Id == 0 && folderType == AllTypeConst.TopicNote.GetHashCode())
-            {
-                var query = Q.NewQuery();
-                query.Where(nameof(Entity.Middle.Middle.FolderType), folderType);
-                query.Where(nameof(Entity.Middle.Middle.AttributeValue), 2);
-                query.Where(nameof(Entity.Middle.Middle.IsSystemDefault), true);
-                query.Where(nameof(Entity.Middle.Middle.UserId), userId);
-                var middle = await _middleRepository.GetMiddleAsync(query);
-                result.IsDefault = middle != null ? middle.IsSystemDefault : false;
-                result.FolderName = middle != null ? middle.FolderName : "";
-                result.FolderType = middle != null ? middle.FolderType : 0;
-                result.MiddleId = middle == null ? middle.Id : 0;
-                return result;
-            }
-            result = new MiddleDefaultResult();
             result.IsDefault = recordFolder != null;
             result.FolderName = recordFolder == null ? "" : recordFolder.FolderName;
             result.FolderType = recordFolder == null ? 0 : recordFolder.FolderType;