Merge branch 'refs/heads/abp' into digital-collectibles

This commit is contained in:
橙子
2025-01-18 01:09:42 +08:00
4 changed files with 26 additions and 14 deletions

View File

@@ -154,9 +154,10 @@ public class DefaultSqlSugarDbContext : SqlSugarDbContext
break;
case DataFilterType.DeleteByObject:
if (entityInfo.PropertyName == nameof(IEntity<object>.Id))
{
// if (entityInfo.PropertyName == nameof(IEntity<object>.Id))
// {
//这里sqlsugar有个特殊删除会返回批量的结果
//这里sqlsugar有第二个特殊删除事件是行级事件
if (entityInfo.EntityValue is IEnumerable entityValues)
{
foreach (var entityValue in entityValues)
@@ -164,7 +165,7 @@ public class DefaultSqlSugarDbContext : SqlSugarDbContext
EntityChangeEventHelper.PublishEntityDeletedEvent(entityValue);
}
}
}
// }
break;
}

View File

@@ -76,7 +76,6 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
var entities = await _articleRepository.GetTreeAsync(x => x.DiscussId == discussId);
//var result = entities.Tile();
var items = entities.Adapt<List<ArticleAllOutputDto>>();
return items;
}

View File

@@ -72,8 +72,7 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
.Select((discuss, user, info, plate) => new DiscussGetOutputDto
{
Id = discuss.Id,
IsAgree = SqlFunc.Subqueryable<AgreeEntity>().WhereIF(CurrentUser.Id != null,
x => x.CreatorId == CurrentUser.Id && x.DiscussId == discuss.Id).Any(),
IsAgree = false,
User = new BbsUserGetListOutputDto()
{
UserName = user.UserName,
@@ -94,15 +93,25 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
Logo = plate.Logo
}
}, true)
.SingleAsync(discuss => discuss.Id == id);
.FirstAsync(discuss => discuss.Id == id);
if (item is not null)
if (item is null)
{
await VerifyDiscussPermissionAsync(item.Id);
await _localEventBus.PublishAsync(new SeeDiscussEventArgs
{ DiscussId = item.Id, OldSeeNum = item.SeeNum });
throw new UserFriendlyException("该主题不存在", "404");
}
//组装点赞
var agreeCreatorList =
(await _agreeRepository._DbQueryable.Where(x => x.DiscussId == item.Id).Select(x=>x.CreatorId).ToListAsync());
//已登录
if (CurrentUser.Id is not null)
{
item.IsAgree = agreeCreatorList.Contains(CurrentUser.Id);
}
await VerifyDiscussPermissionAsync(item.Id);
await _localEventBus.PublishAsync(new SeeDiscussEventArgs
{ DiscussId = item.Id, OldSeeNum = item.SeeNum });
return item;
}

View File

@@ -8,9 +8,12 @@ namespace Yi.Framework.Bbs.Domain.Entities.Forum
{
[SugarTable("Discuss")]
[SugarIndex($"index_{nameof(Title)}", nameof(Title), OrderByType.Asc)]
[SugarIndex($"index_{nameof(PlateId)}", nameof(PlateId), OrderByType.Asc)]
[SugarIndex($"index_{nameof(CreatorId)}", nameof(CreatorId), OrderByType.Asc)]
[SugarIndex($"index_{nameof(CreationTime)}", nameof(CreationTime), OrderByType.Desc)]
[SugarIndex($"index_{nameof(IsDeleted)}_{nameof(PlateId)}_{nameof(CreatorId)}",
nameof(IsDeleted), OrderByType.Asc,
nameof(PlateId), OrderByType.Asc,
nameof(CreatorId), OrderByType.Asc
)]
public class DiscussAggregateRoot : AggregateRoot<Guid>, ISoftDelete, IAuditedObject
{
public DiscussAggregateRoot()