lihao 4 years ago
parent
commit
ab25e23f63

+ 3 - 17
gx_api/GxPress/Repository/GxPress.Repository.Implement/NoticeRepository.cs

@@ -537,7 +537,7 @@ namespace GxPress.Repository.Implement
                 FROM
                 FROM
                     tede_addressee
                     tede_addressee
                 WHERE
                 WHERE
-    SourceId = a.MiddleId AND IsRead = 1 and UserId={request.UserId} limit 0,1) as IsRead, b.*, c.Name, c.AvatarUrl, d.Id,d.SourceId
+    SourceId = a.MiddleId AND IsRead = 1 and UserId={request.UserId} limit 0,1) as IsRead, b.*, c.AvatarUrl, d.Id as NoticeAddresseeId,d.SourceId as NoticeId
                                     FROM
                                     FROM
                                         tede_middle a
                                         tede_middle a
                                             left   JOIN
                                             left   JOIN
@@ -567,24 +567,10 @@ namespace GxPress.Repository.Implement
             var databaseType = StringUtils.ToEnum<DatabaseType>(_databaseTypeStr, DatabaseType.MySql);
             var databaseType = StringUtils.ToEnum<DatabaseType>(_databaseTypeStr, DatabaseType.MySql);
             var database = new Database(databaseType, _connectionString);
             var database = new Database(databaseType, _connectionString);
             var connection = database.GetConnection();
             var connection = database.GetConnection();
-            var items = await connection
-                .QueryAsync<NoticeListPageResult, Notice, User, Addressee, NoticeListPageResult>(sql,
-                    (noticeListPageResult, notice, user, noticeAddressee) =>
-                    {
-                        noticeListPageResult.Title = notice != null ? notice.Title : "";
-                        noticeListPageResult.TypeValue = notice != null ? notice.TypeValue : 0;
-                        noticeListPageResult.SonId = notice != null ? notice.SonId : 0;
-                        noticeListPageResult.Content = notice != null ? notice.Content : "[]";
-                        noticeListPageResult.UserName = user != null ? user.Name : "";
-                        noticeListPageResult.SourceId = notice != null ? notice.SourceId : 0;
-                        noticeListPageResult.AvatarUrl = user != null ? StringUtils.AddDomainMin(user.AvatarUrl) : "";
-                        noticeListPageResult.NoticeAddresseeId = noticeAddressee?.Id ?? 0;
-                        noticeListPageResult.NoticeId = noticeAddressee?.SourceId ?? 0;
-                        return noticeListPageResult;
-                    },
-                    splitOn: "Id,Id,Name,Id");
+            var items = await connection.QueryAsync<NoticeListPageResult>(sql);
             foreach (var item in items)
             foreach (var item in items)
             {
             {
+                item.AvatarUrl = StringUtils.AddDomainMin(item.AvatarUrl);
                 if (item.AttributeValue == 3)
                 if (item.AttributeValue == 3)
                 {
                 {
                     var query = Q.NewQuery();
                     var query = Q.NewQuery();