李昊 4 年之前
父节点
当前提交
f32c1d5939

+ 5 - 0
gx_api/GxPress/Model/GxPress.Request/App/Note/NoteSearchPageListRequest.cs

@@ -27,5 +27,10 @@ namespace GxPress.Request.App.Note
         /// 访问用户ID
         /// </summary>
         public int VisitUserId { get; set; }
+        /// <summary>
+        /// 0 笔记 1 笔记话题
+        /// </summary>
+        /// <value></value>
+        public int TypeValue { get; set; }
     }
 }

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

@@ -182,7 +182,7 @@ namespace GxPress.Repository.Implement.Note
         WHERE
             ParentId = a.Id and IsDelete=0) FileCount, b.Title, b.Content,b.ReadCount,b.MediaId,b.CatalogId,
     b.ChapterId,c.Name,c.AvatarUrl,c.Nick,d.Name FROM tede_middle a LEFT JOIN tede_note b ON a.MiddleId = b.Id left join tede_user c on c.Id=b.UserId left join tede_department d on d.Id=c.DepartmentId
-                        WHERE a.UserId = {request.VisitUserId} AND a.FolderType = 4 AND a.IsDelete = 0";
+                        WHERE a.UserId = {request.VisitUserId} AND a.FolderType ={noteTypeId} AND a.IsDelete = 0";
                 if (request.FolderId == 0)
                     sql += @" AND(a.RoleId = 1 OR a.RoleId = 3) AND a.ParentId = 0";
                 else
@@ -269,7 +269,11 @@ namespace GxPress.Repository.Implement.Note
             tede_middle
         WHERE
             ParentId = a.Id and IsDelete=0) FileCount, b.Title, b.Content,b.ReadCount,b.MediaId,b.CatalogId,
-    b.ChapterId,c.Name,c.AvatarUrl,d.Name FROM tede_middle a  LEFT JOIN tede_note b ON a.MiddleId = b.Id left join tede_user c on c.Id=b.UserId left join tede_department d on d.Id=c.DepartmentId WHERE a.UserId = {request.UserId} AND a.FolderType = {noteTypeId} AND a.IsDelete = 0";
+    b.ChapterId,c.Name,c.AvatarUrl,d.Name FROM tede_middle a  LEFT JOIN tede_note b ON a.MiddleId = b.Id left join tede_user c on c.Id=b.UserId left join tede_department d on d.Id=c.DepartmentId WHERE a.UserId = {request.UserId} AND a.FolderType = {noteTypeId} AND a.IsDelete = 0 ";
+                if (request.TypeValue == 0)
+                    sql += "and  (a.RoleId in(2) or a.AttributeValue=1)";
+                else
+                    sql += "and  (a.RoleId in(1,3) or a.AttributeValue=1)";
                 if (request.FolderId == 0 && !string.IsNullOrEmpty(request.SearchKey))
                     sql += $@"  AND(b.Title LIKE '%{request.SearchKey}%' OR a.FolderName LIKE '%{request.SearchKey}%' or b.Content LIKE '%{request.SearchKey}%' or b.UserId in (select Id from tede_user where name like '%{request.SearchKey}%'))";
                 else if (!string.IsNullOrEmpty(request.SearchKey))
@@ -316,6 +320,10 @@ namespace GxPress.Repository.Implement.Note
             {
                 sql =
                     $@"SELECT  count(1) FROM tede_middle a LEFT JOIN tede_note b ON a.MiddleId = b.Id left join tede_user c on c.Id=b.UserId left join tede_department d on d.Id=c.DepartmentId WHERE a.UserId = {request.UserId} AND a.FolderType = 4 AND a.IsDelete = 0";
+                if (request.TypeValue == 0)
+                    sql += "and  (a.RoleId in(2) or a.AttributeValue=1)";
+                else
+                    sql += "and  (a.RoleId in(1,3) or a.AttributeValue=1)";
                 if (request.FolderId == 0 && !string.IsNullOrEmpty(request.SearchKey))
                     sql += $@"  AND(b.Title LIKE '%{request.SearchKey}%' OR a.FolderName LIKE '%{request.SearchKey}%' or b.Content LIKE '%{request.SearchKey}%' or b.UserId in (select Id from tede_user where name like '%{request.SearchKey}%'))";
                 else if (!string.IsNullOrEmpty(request.SearchKey))