lihao 4 years ago
parent
commit
b0697c66b4

+ 16 - 8
gx_api/GxPress/Repository/GxPress.Repository.Implement/TopicRepository.cs

@@ -449,16 +449,24 @@ namespace GxPress.Repository.Implement
                                 b.Name as GroupName,
                                 c.Name as UserName,
                                 c.AvatarUrl,
-                                d.Id as DepartmentId,
-                                d.Name as DepartmentName
+                                (SELECT 
+                                        Name
+                                    FROM
+                                        tede_department
+                                    WHERE
+                                        Id IN (SELECT 
+                                                DepartmentId
+                                            FROM
+                                                tede_department_user
+                                            WHERE
+                                                userId = a.UserId)
+                                    LIMIT 1) as DepartmentName
                             FROM
                                 tede_topic a
-                                    left JOIN
+                                    inner JOIN
                                 tede_group b ON a.GroupId = b.Id
-                                    left JOIN
+                                    inner JOIN
                                 tede_user c ON c.Id = a.UserId
-                                  left JOIN
-                                tede_department d ON d.Id = c.DepartmentId
                             WHERE
                                 a.GroupId > 0 
                                     {sqlStr}
@@ -467,9 +475,9 @@ namespace GxPress.Repository.Implement
                                 count(1)
                             FROM
                                 tede_topic a
-                                    INNER JOIN
+                                    inner JOIN
                                 tede_group b ON a.GroupId = b.Id
-                                    INNER JOIN
+                                    inner JOIN
                                 tede_user c ON c.Id = a.UserId
                             WHERE
                                 a.GroupId > 0