李昊 4 years ago
parent
commit
3f52823282

+ 16 - 1
gx_api/GxPress/Repository/GxPress.Repository.Implement/GroupChatUserRepository.cs

@@ -252,7 +252,22 @@ namespace GxPress.Repository.Implement
         /// <returns></returns>
         public async Task<int> GetUserIntoGroupChatUserCountAsync(int userId)
         {
-            string sql = $"select count(1) from tede_group_chat_user where GroupChatId in(select GroupChatId from tede_group_chat_user where UserId={userId})";
+            string sql = $@"SELECT 
+                                COUNT(1)
+                            FROM
+                                tede_user
+                            WHERE
+                                Id IN (SELECT 
+                                    UserId
+                                    FROM
+                                        tede_group_chat_user
+                                    WHERE
+                                        GroupChatId IN (SELECT 
+                                                GroupChatId
+                                            FROM
+                                                tede_group_chat_user
+                                            WHERE
+                                                UserId ={userId}))";
             var databaseType = StringUtils.ToEnum<DatabaseType>(_databaseTypeStr, DatabaseType.MySql);
             var database = new Database(databaseType, _connectionString);
             var connection = database.GetConnection();

+ 16 - 1
gx_api/GxPress/Repository/GxPress.Repository.Implement/GroupUserRepository.cs

@@ -162,7 +162,22 @@ namespace GxPress.Repository.Implement
         /// <returns></returns>
         public async Task<int> GetUserIntoGroupUserCountAsync(int userId)
         {
-            string sql = $"select count(1) from tede_group_user where GroupId in(select groupId from tede_group_user where userId={userId})";
+            string sql = $@"SELECT 
+                                COUNT(1)
+                            FROM
+                                tede_user
+                            WHERE
+                                Id IN (SELECT 
+                                        UserId
+                                    FROM
+                                        tede_group_user
+                                    WHERE
+                                        GroupId 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();