李昊 4 years ago
parent
commit
52fec41839

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

@@ -179,7 +179,7 @@ namespace GxPress.Repository.Implement.Note
                 if (!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}%'))";
                 sql +=
-                    $@" OR a.id IN(SELECT MiddleId FROM tede_folder_user WHERE UserId = {request.UserId}) AND a.FolderType = 4 AND a.UserId = {request.VisitUserId}";
+                    $@" OR a.id IN(SELECT MiddleId FROM tede_folder_user WHERE UserId = {request.UserId}) AND a.FolderType ={noteTypeId} AND a.UserId = {request.VisitUserId}";
                 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))
@@ -194,12 +194,12 @@ namespace GxPress.Repository.Implement.Note
             else
             {
                 sql =
-                    $@"SELECT  a.*,(SELECT GROUP_CONCAT(SourceName Separator'、') from tede_user_middle where MiddleType=4 and DataSourceId=a.MiddleSonId) as EnjoyUser,(SELECT 
+                    $@"SELECT  a.*,(SELECT GROUP_CONCAT(SourceName Separator'、') from tede_user_middle where MiddleType={noteTypeId} and DataSourceId=a.MiddleSonId) as EnjoyUser,(SELECT 
             COUNT(1)
         FROM
             tede_analyze
         WHERE
-            UserId = {request.UserId} AND TypeValue = 3
+            UserId = {request.UserId} AND TypeValue = {noteTypeId}
                 AND SourceId = a.MiddleId
                 AND AnalyzeType = 1) AS PraiseCount,
     (SELECT 
@@ -207,7 +207,7 @@ namespace GxPress.Repository.Implement.Note
         FROM
             tede_analyze
         WHERE
-            UserId = {request.UserId} AND TypeValue = 3
+            UserId = {request.UserId} AND TypeValue ={noteTypeId}
                 AND SourceId = a.MiddleId
                 AND AnalyzeType = 1
         LIMIT 0 , 1) AS IsPraise,
@@ -217,13 +217,13 @@ namespace GxPress.Repository.Implement.Note
             tede_comment
         WHERE
             UserId = {request.UserId} AND ArticleId =  a.MiddleId
-                AND TypeValue = 3) AS CommentCount,
+                AND TypeValue = {noteTypeId}) AS CommentCount,
     (SELECT 
             COUNT(1)
         FROM
             tede_analyze
         WHERE
-            UserId = {request.UserId} AND TypeValue = 3
+            UserId = {request.UserId} AND TypeValue = {noteTypeId}
                 AND SourceId = a.MiddleId
                 AND AnalyzeType = 4) AS RetransmissionCount,
     (SELECT 
@@ -231,7 +231,7 @@ namespace GxPress.Repository.Implement.Note
         FROM
             tede_analyze
         WHERE
-            UserId = {request.UserId} AND TypeValue = 3
+            UserId = {request.UserId} AND TypeValue = {noteTypeId}
                 AND SourceId = a.MiddleId
                 AND AnalyzeType = 4
         LIMIT 0 , 1) AS IsRetransmission,
@@ -240,7 +240,7 @@ namespace GxPress.Repository.Implement.Note
         FROM
             tede_analyze
         WHERE
-            UserId = {request.UserId} AND TypeValue = 3
+            UserId = {request.UserId} AND TypeValue ={noteTypeId}
                 AND SourceId = a.MiddleId
                 AND AnalyzeType = 4
         LIMIT 0 , 1) AS IsCollect,
@@ -249,7 +249,7 @@ namespace GxPress.Repository.Implement.Note
         FROM
             tede_analyze
         WHERE
-            UserId = {request.UserId} AND TypeValue = 3
+            UserId = {request.UserId} AND TypeValue = {noteTypeId}
                 AND SourceId = a.MiddleId
                 AND AnalyzeType = 4) AS IsCollect,
     (SELECT 
@@ -258,7 +258,7 @@ 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 = 4 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.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))