lihao 4 years ago
parent
commit
870f72dc8b

+ 6 - 15
gx_api/GxPress/Repository/GxPress.Repository.Implement/TopicRepository.cs

@@ -324,11 +324,11 @@ namespace GxPress.Repository.Implement
                                         UserId ={request.UserId} AND TypeValue = {topicConst}
                                             AND SourceId = a.Id
                                             AND AnalyzeType = 4) AS CollectCount,
-                                b.Name,
-                                c.Name,
+                                b.Name as GroupName,
+                                c.Name as UserName,
                                 c.AvatarUrl,
-                                d.Id,
-                                d.Name
+                                d.Id as DepartmentId,
+                                d.Name as DepartmentName
                             FROM
                                 tede_topic a
                                     INNER JOIN
@@ -340,7 +340,7 @@ namespace GxPress.Repository.Implement
                             WHERE
                                 a.GroupId > 0
                                     {sqlStr}
-                            ORDER BY a.CreatedDate DESC";
+                            ORDER BY a.CreatedDate DESC limit @page,@pageSize";
             string countSql = $@"SELECT 
                                 count(1)
                             FROM
@@ -358,16 +358,7 @@ namespace GxPress.Repository.Implement
             var connection = database.GetConnection();
             result.Items =
                  await connection
-                      .QueryAsync<TopicListPageResult, Entity.Group, User, Department, TopicListPageResult>(sql,
-                          (topicListPageResult, group, user, department) =>
-                          {
-                              topicListPageResult.GroupName = group != null ? group.Name : "";
-                              topicListPageResult.DepartmentName = department != null ? department.Name : "";
-                              topicListPageResult.DepartmentId = department != null ? department.Id : 0;
-                              topicListPageResult.UserName = user != null ? user.Name : "";
-                              topicListPageResult.AvatarUrl = user != null ? StringUtils.AddDomainMin(user.AvatarUrl) : "";
-                              return topicListPageResult;
-                          }, new { page = (request.Page - 1) * request.PerPage, pageSize = request.PerPage }, splitOn: "Id,Name,Name,Id");
+                      .QueryAsync<TopicListPageResult>(sql,new { page = (request.Page - 1) * request.PerPage, pageSize = request.PerPage });
             result.Total = await connection.ExecuteScalarAsync<int>(countSql);
             return result;
         }