lihao 4 年之前
父节点
当前提交
2665841b94
共有 1 个文件被更改,包括 12 次插入10 次删除
  1. 12 10
      gx_api/GxPress/Service/GxPress.Service.Implement/Note/NoteService.cs

+ 12 - 10
gx_api/GxPress/Service/GxPress.Service.Implement/Note/NoteService.cs

@@ -296,19 +296,20 @@ namespace GxPress.Service.Implement.Note
                 query.Where(n => n.WhereIn("tede_middle.RoleId", new List<int> { MiddleRoleConst.Publicity.GetHashCode(), MiddleRoleConst.Share.GetHashCode() })
                   .OrWhereIn("tede_middle.AttributeValue", new List<int> { AttributeValueConst.File.GetHashCode(), AttributeValueConst.Folder.GetHashCode() }));
             //判断是否是匿名用户
-            if (request.VisitUserId > 0)
-            {
-                var sqlStr = $"tede_middle.Id";
-                if (request.FolderId > 0)
-                    sqlStr = "tede_middle.ParentId";
-                parameterQuery = new SqlKata.Query("tede_user as c");
-                parameterQuery.WhereColumns("1", "=", "tede_middle.RoleId");
-                parameterQuery.Select("c.Id");
+            if (request.VisitUserId > 0 && request.FolderId == 0)
+            {
+                // var sqlStr = $"tede_middle.Id";
+                // if (request.FolderId > 0)
+                //     sqlStr = "tede_middle.ParentId";
+                // var userIdQuery = new SqlKata.Query("tede_user as c");
+                // userIdQuery.WhereRaw("1=tede_middle.RoleId");
+                // userIdQuery.Select("c.Id");
                 parameterQuery = new SqlKata.Query("tede_folder_user as d");
                 parameterQuery.Where("d.UserId", request.UserId);
-                parameterQuery.WhereColumns("d.MiddleId", "=", sqlStr);
+                parameterQuery.WhereColumns("d.MiddleId", "=", "tede_middle.Id");
                 parameterQuery.Select("MiddleId");
-                query.Where(n => n.WhereIn("tede_middle.UserId", parameterQuery).OrWhereIn(sqlStr, parameterQuery));
+                query.Where(n => n.Where("tede_middle.RoleId", MiddleRoleConst.Publicity.GetHashCode()).OrWhereIn("tede_middle.Id", parameterQuery));
+                query.Where("tede_middle.AttributeValue", AttributeValueConst.Folder.GetHashCode());
             }
             if (request.FolderId == 0 && !string.IsNullOrEmpty(request.SearchKey))
             {
@@ -327,6 +328,7 @@ namespace GxPress.Service.Implement.Note
             else
                 query.Where("tede_middle.ParentId", request.FolderId);
             var countQuery = query;
+            query.OrderByDesc("tede_middle.IsSystemDefault");
             query.OrderByDesc("tede_middle.AttributeValue");
             query.OrderByDesc("tede_middle.IsTop");
             query.OrderByDesc("tede_middle.LastModifiedDate");