using Volo.Abp.DependencyInjection; using Volo.Abp.Domain.Entities.Events; using Volo.Abp.EventBus; using Yi.Framework.Bbs.Domain.Entities; using Yi.Framework.Bbs.Domain.Entities.Forum; using Yi.Framework.SqlSugarCore.Abstractions; namespace Yi.Framework.Bbs.Domain.EventHandlers { /// /// 评论创建的领域事件 /// public class CommentCreatedEventHandler : ILocalEventHandler>, ITransientDependency { private ISqlSugarRepository _userRepository; public CommentCreatedEventHandler(ISqlSugarRepository userRepository) { _userRepository = userRepository; } public async Task HandleEventAsync(EntityCreatedEventData eventData) { var commentEntity = eventData.Entity; //给创建者发布数量+1 await _userRepository._Db.Updateable() .SetColumns(it => it.CommentNumber == it.CommentNumber + 1) .Where(it => it.Id == commentEntity.CreatorId) .ExecuteCommandAsync(); } } }