李昊 пре 4 година
родитељ
комит
957437cb79

+ 10 - 4
gx_api/GxPress/Repository/GxPress.Repository.Implement/Note/NoteRepository.cs

@@ -157,6 +157,9 @@ namespace GxPress.Repository.Implement.Note
             var noteTypeId = request.TypeValue == 0 ? AllTypeConst.Note.GetHashCode() : AllTypeConst.TopicNote.GetHashCode();
             if (request.VisitUserId > 0)
             {
+                var sqlStr = $"a.Id";
+                if (request.FolderId > 0)
+                    sqlStr = "a.ParentId";
                 sql =
                    $@"SELECT  a.Id,a.MiddleId,a.RoleId,a.ParentId,a.AttributeValue,a.UserId,
                       a.CreatedDate,a.IsTop,a.FolderName,a.FolderType,
@@ -261,12 +264,12 @@ namespace GxPress.Repository.Implement.Note
                             tede_user
                         WHERE
                             1 = a.RoleId)
-                        OR a.Id IN (SELECT 
+                        OR {sqlStr} IN (SELECT 
                             MiddleId
                         FROM
                             tede_folder_user
                         WHERE
-                        UserId = {request.UserId}))";
+                        UserId = {request.UserId} AND MiddleId = {sqlStr}))";
                 if (request.TypeValue == 0)
                     sql += "and  (a.RoleId in(2) or a.AttributeValue=1)";
                 else
@@ -410,6 +413,9 @@ namespace GxPress.Repository.Implement.Note
 
             if (request.VisitUserId > 0)
             {
+                var sqlStr = $"a.Id";
+                if (request.FolderId > 0)
+                    sqlStr = "a.ParentId";
                 sql =
                      $@"SELECT  count(1)
                     FROM tede_middle a  LEFT JOIN tede_note b ON a.MiddleId = b.Id 
@@ -424,12 +430,12 @@ namespace GxPress.Repository.Implement.Note
                             tede_user
                         WHERE
                             1 = a.RoleId)
-                        OR a.Id IN (SELECT 
+                        OR {sqlStr} IN (SELECT 
                             MiddleId
                         FROM
                             tede_folder_user
                         WHERE
-                        UserId = {request.UserId}))";
+                        UserId = {request.UserId} AND MiddleId = {sqlStr}))";
                 if (request.TypeValue == 0)
                     sql += "and  (a.RoleId in(2) or a.AttributeValue=1)";
                 else