李昊 4 éve
szülő
commit
aefdfb8280

+ 5 - 0
gx_api/GxPress/Model/GxPress.Request/App/Topic/TopicPageSearchRequest.cs

@@ -35,5 +35,10 @@ namespace GxPress.Request.App.Topic
         {
             TopicGroupIds=new List<int>();
         }
+        /// <summary>
+        /// 是否查询自己
+        /// </summary>
+        /// <value></value>
+        public bool IsAdmin{get;set;}
     }
 }

+ 19 - 5
gx_api/GxPress/Repository/GxPress.Repository.Implement/TopicRepository.cs

@@ -296,7 +296,7 @@ namespace GxPress.Repository.Implement
             connection.Dispose();
             return result;
         }
-         
+
         public async Task<PagedList<TopicListPageResult>> GetTopicByGroupAsync(TopicPageSearchRequest request)
         {
             var sql = $@"SELECT 
@@ -361,13 +361,20 @@ namespace GxPress.Repository.Implement
                                     INNER JOIN
                                 tede_user c ON a.UserId = c.Id
                             WHERE
-                                a.GroupId > 0
-                                    AND b.Id IN (SELECT 
+                                a.GroupId > 0";
+            if (request.IsAdmin)
+            {
+                sql += $@" AND a.UserId={request.UserId}";
+            }
+            else
+            {
+                sql += $@" AND b.Id IN (SELECT 
                                         GroupId
                                     FROM
                                         tede_group_user
                                     WHERE
                                         UserId = {request.UserId})";
+            }
             if (!string.IsNullOrWhiteSpace(request.Keyword))
             {
                 sql += $@"  AND (c.Name LIKE '%{request.Keyword}%'
@@ -399,13 +406,20 @@ namespace GxPress.Repository.Implement
                                     INNER JOIN
                                 tede_user c ON a.UserId = c.Id
                             WHERE
-                                a.GroupId > 0
-                                    AND b.Id IN (SELECT 
+                                a.GroupId > 0";
+            if (request.IsAdmin)
+            {
+                sql += $@" AND a.UserId={request.UserId}";
+            }
+            else
+            {
+                sql += $@" AND b.Id IN (SELECT 
                                         GroupId
                                     FROM
                                         tede_group_user
                                     WHERE
                                         UserId = {request.UserId})";
+            }
             if (!string.IsNullOrWhiteSpace(request.Keyword))
             {
                 sql += $@"  AND (c.Name LIKE '%{request.Keyword}%'