diff --git a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application.Contracts/Dtos/Comment/CommentGetListOutputDto.cs b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application.Contracts/Dtos/Comment/CommentGetListOutputDto.cs
index a61de041..fc7b23a3 100644
--- a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application.Contracts/Dtos/Comment/CommentGetListOutputDto.cs
+++ b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application.Contracts/Dtos/Comment/CommentGetListOutputDto.cs
@@ -32,6 +32,9 @@ namespace Yi.Framework.Bbs.Application.Contracts.Dtos.Comment
///
public BbsUserGetOutputDto CreateUser { get; set; }
+
+ public Guid? CreatorId { get; set; }
+
///
/// 被评论的用户信息
///
diff --git a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application/Services/CommentService.cs b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application/Services/CommentService.cs
index ce282b63..5cd83247 100644
--- a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application/Services/CommentService.cs
+++ b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application/Services/CommentService.cs
@@ -57,31 +57,37 @@ namespace Yi.Framework.Bbs.Application.Services
.Includes(x => x.CreateUser)
.ToListAsync();
- //缁撴灉鍒濆鍊硷紝绗竴灞傜瓑浜庡叏閮ㄦ牴鑺傜偣
- var outPut = entities.Where(x => x.ParentId == Guid.Empty).OrderByDescending(x => x.CreationTime).ToList();
- //鑾峰彇鍏ㄩ噺涓婚璇勮锛 鍏堣幏鍙栭《绾х殑锛屽皢鍏朵粬瀛愮粍鍚堝埌椤剁骇涓嬶紝褰㈡垚涓涓簩缁,鍏堣浆鎴恉to
- List outoutDto = await MapToGetListOutputDtosAsync(outPut);
+ //璇ュ疄浣撻渶瑕佽繘琛岃浆鎹
//鍚屾椂涓烘墍鏈夌敤鎴穒d杩涜bbs鐨勬墿灞曞嵆鍙
- List userIds = outoutDto.Where(x => x.CommentedUser is not null).Select(x => x.CommentedUser.Id).Union(outoutDto.Select(x => x.CreateUser.Id)).ToList();
+ List userIds = entities.Where(x => x.CreatorId != null).Select(x => x.CreatorId ?? Guid.Empty).ToList();
var bbsUserInfoDic = (await _bbsUserManager.GetBbsUserInfoAsync(userIds)).ToDictionary(x => x.Id);
- foreach (var singleOutput in outoutDto)
- {
- if (singleOutput.CommentedUser is not null)
- {
- singleOutput.CommentedUser = bbsUserInfoDic[singleOutput.CommentedUser.Id].Adapt();
- }
-
- singleOutput.CreateUser = bbsUserInfoDic[singleOutput.CreateUser.Id].Adapt();
- }
- //鏁版嵁鏌ヨ瀹屾垚
+
+
+ //------鏁版嵁鏌ヨ瀹屾垚------
+
+
+
+
+
+ //浠庢牴鐩綍寮濮嬬粍瑁
+ //缁撴灉鍒濆鍊硷紝绗竴灞傜瓑浜庡叏閮ㄦ牴鑺傜偣
+ var allOutPut = entities.OrderByDescending(x => x.CreationTime).ToList();
+
+ //鑾峰彇鍏ㄩ噺涓婚璇勮锛 鍏堣幏鍙栭《绾х殑锛屽皢鍏朵粬瀛愮粍鍚堝埌椤剁骇涓嬶紝褰㈡垚涓涓簩缁,鍏堣浆鎴恉to
+ List allOutoutDto = await MapToGetListOutputDtosAsync(allOutPut);
+
+ //寮濮嬫槧灏勯澶栫敤鎴蜂俊鎭瓧娈
+ allOutoutDto?.ForEach(x => x.CreateUser = bbsUserInfoDic[x.CreatorId ?? Guid.Empty].Adapt());
+
//寮濮嬬粍瑁卍to鐨勫眰绾у叧绯
//灏嗗叏閮ㄦ暟鎹繘琛宧ash
- var dic = outoutDto.ToDictionary(x => x.Id);
- foreach (var comment in outoutDto)
+ var dic = allOutoutDto.ToDictionary(x => x.Id);
+
+ foreach (var comment in allOutoutDto)
{
//涓嶆槸鏍硅妭鐐癸紝闇瑕佽祴鍊 琚瘎璁鸿呯敤鎴蜂俊鎭瓑
if (comment.ParentId != Guid.Empty)
@@ -106,7 +112,8 @@ namespace Yi.Framework.Bbs.Application.Services
}
//瀛愮被闇瑕佹帓搴
- outPut.ForEach(x =>
+ var rootOutoutDto= allOutoutDto.Where(x => x.ParentId == Guid.Empty).ToList();
+ rootOutoutDto?.ForEach(x =>
{
x.Children = x.Children.OrderByDescending(x => x.CreationTime).ToList();
@@ -114,7 +121,7 @@ namespace Yi.Framework.Bbs.Application.Services
- return new PagedResultDto(entities.Count(), outoutDto);
+ return new PagedResultDto(entities.Count(), rootOutoutDto);
}