lihao před 4 roky
rodič
revize
56a87fb755

+ 4 - 11
gx_api/GxPress/Repository/GxPress.Repository.Implement/TopicRepository.cs

@@ -352,14 +352,7 @@ namespace GxPress.Repository.Implement
             if (request.IsDraft)
                 sqlStr += $" and a.UserId={request.UserId}";
             if (request.GroupIds.Count() == 0)
-            {
-                sqlStr += $@" AND a.GroupId IN (SELECT 
-                                        GroupId
-                                    FROM
-                                        tede_group_user
-                                    WHERE
-                                        UserId ={request.UserId})";
-            }
+                request.GroupIds.Add(-1);
             if (request.GroupIds.Count > 0)
             {
                 var groupIds = new List<int>();
@@ -369,7 +362,7 @@ namespace GxPress.Repository.Implement
                         groupIds.Add(item);
                     //全网
                     if (item == -1)
-                        groupIds.AddRange(await GetPublicGroupAsync());
+                        groupIds.AddRange(await GetPublicGroupAsync(request.UserId));
                     //我的小组
                     if (item == -2)
                         groupIds.AddRange(await GetIntoGroupAsync(request.UserId));
@@ -510,9 +503,9 @@ namespace GxPress.Repository.Implement
         /// 获取共享小组
         /// </summary>
         /// <returns></returns>
-        public async Task<IEnumerable<int>> GetPublicGroupAsync()
+        public async Task<IEnumerable<int>> GetPublicGroupAsync(int userId)
         {
-            string sql = @"select Id from tede_group where IsShow=1";
+            string sql = $@"select Id from tede_group where (IsShow=1 or id in (select groupId FROM  tede_group_user where userId={userId}))";
             var databaseType = StringUtils.ToEnum<DatabaseType>(_databaseTypeStr, DatabaseType.MySql);
             var database = new Database(databaseType, _connectionString);
             var connection = database.GetConnection();