fix: 修复评论问题
This commit is contained in:
@@ -34,7 +34,7 @@ namespace Yi.Framework.Bbs.Application.Contracts.Dtos.Discuss
|
|||||||
public string? PrivateCode { get; set; }
|
public string? PrivateCode { get; set; }
|
||||||
public DateTime CreationTime { get; set; }
|
public DateTime CreationTime { get; set; }
|
||||||
public DiscussPermissionTypeEnum PermissionType { get; set; }
|
public DiscussPermissionTypeEnum PermissionType { get; set; }
|
||||||
|
public bool IsAgree { get; set; } = false;
|
||||||
public List<Guid>? PermissionUserIds { get; set; }
|
public List<Guid>? PermissionUserIds { get; set; }
|
||||||
public BbsUserGetListOutputDto User { get; set; }
|
public BbsUserGetListOutputDto User { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,13 +63,17 @@ namespace Yi.Framework.Bbs.Application.Services
|
|||||||
List<CommentGetListOutputDto> outoutDto = await MapToGetListOutputDtosAsync(outPut);
|
List<CommentGetListOutputDto> outoutDto = await MapToGetListOutputDtosAsync(outPut);
|
||||||
|
|
||||||
//同时为所有用户id进行bbs的扩展即可
|
//同时为所有用户id进行bbs的扩展即可
|
||||||
List<Guid> userIds = outoutDto.Select(x => x.CommentedUser.Id).Union(outoutDto.Select(x => x.CreateUser.Id)).ToList();
|
List<Guid> userIds = outoutDto.Where(x => x.CommentedUser is not null).Select(x => x.CommentedUser.Id).Union(outoutDto.Select(x => x.CreateUser.Id)).ToList();
|
||||||
var bbsUserInfoDic = (await _bbsUserManager.GetBbsUserInfoAsync(userIds)).ToDictionary(x => x.Id);
|
var bbsUserInfoDic = (await _bbsUserManager.GetBbsUserInfoAsync(userIds)).ToDictionary(x => x.Id);
|
||||||
|
|
||||||
foreach (var singleOutput in outoutDto)
|
foreach (var singleOutput in outoutDto)
|
||||||
{
|
{
|
||||||
singleOutput.CommentedUser = bbsUserInfoDic[singleOutput.CommentedUser.Id].Adapt<BbsUserGetOutputDto>();
|
if (singleOutput.CommentedUser is not null)
|
||||||
singleOutput.CreateUser = bbsUserInfoDic[singleOutput.CommentedUser.Id].Adapt<BbsUserGetOutputDto>();
|
{
|
||||||
|
singleOutput.CommentedUser = bbsUserInfoDic[singleOutput.CommentedUser.Id].Adapt<BbsUserGetOutputDto>();
|
||||||
|
}
|
||||||
|
|
||||||
|
singleOutput.CreateUser = bbsUserInfoDic[singleOutput.CreateUser.Id].Adapt<BbsUserGetOutputDto>();
|
||||||
}
|
}
|
||||||
//数据查询完成
|
//数据查询完成
|
||||||
|
|
||||||
|
|||||||
@@ -60,6 +60,8 @@ namespace Yi.Framework.Bbs.Application.Services
|
|||||||
.LeftJoin<BbsUserExtraInfoEntity>((discuss, user, info) => user.Id == info.UserId)
|
.LeftJoin<BbsUserExtraInfoEntity>((discuss, user, info) => user.Id == info.UserId)
|
||||||
.Select((discuss, user, info) => new DiscussGetOutputDto
|
.Select((discuss, user, info) => new DiscussGetOutputDto
|
||||||
{
|
{
|
||||||
|
Id=discuss.Id,
|
||||||
|
IsAgree = SqlFunc.Subqueryable<AgreeEntity>().WhereIF(CurrentUser.Id != null, x => x.CreatorId == CurrentUser.Id && x.DiscussId == discuss.Id).Any(),
|
||||||
User = new BbsUserGetListOutputDto()
|
User = new BbsUserGetListOutputDto()
|
||||||
{
|
{
|
||||||
UserName = user.UserName,
|
UserName = user.UserName,
|
||||||
|
|||||||
Reference in New Issue
Block a user