feat: 完善实体追踪审计日志

This commit is contained in:
陈淳
2024-01-27 17:42:09 +08:00
parent b6d35a88db
commit 7969a75a19
15 changed files with 185 additions and 12 deletions

View File

@@ -1,24 +0,0 @@
using Volo.Abp.DependencyInjection;
using Volo.Abp.EventBus;
using Yi.Framework.Bbs.Domain.Entities;
using Yi.Framework.Bbs.Domain.Shared.Etos;
using Yi.Framework.SqlSugarCore.Abstractions;
namespace Yi.Framework.Bbs.Application.EventHandlers
{
public class MoneyChangeEventHandler : ILocalEventHandler<MoneyChangeEventArgs>, ITransientDependency
{
private ISqlSugarRepository<BbsUserExtraInfoEntity> _userInfoRepository;
public MoneyChangeEventHandler(ISqlSugarRepository<BbsUserExtraInfoEntity> userInfoRepository)
{
_userInfoRepository = userInfoRepository;
}
public async Task HandleEventAsync(MoneyChangeEventArgs eventData)
{
//原子性sql
await _userInfoRepository._Db.Updateable<BbsUserExtraInfoEntity>()
.SetColumns(it => it.Money == it.Money + eventData.Number)
.Where(x => x.UserId == eventData.UserId).ExecuteCommandAsync();
}
}
}

View File

@@ -1,35 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.EventBus;
using Yi.Framework.Bbs.Domain.Entities.Forum;
using Yi.Framework.Bbs.Domain.Shared.Etos;
namespace Yi.Framework.Bbs.Application.EventHandlers
{
public class SeeDiscussEventHandler : ILocalEventHandler<SeeDiscussEventArgs>, ITransientDependency
{
private IRepository<DiscussEntity, Guid> _repository;
public SeeDiscussEventHandler(IRepository<DiscussEntity, Guid> repository)
{
_repository = repository;
}
public async Task HandleEventAsync(SeeDiscussEventArgs eventData)
{
var entity = await _repository.GetAsync(eventData.DiscussId);
if (entity is not null)
{
entity.SeeNum += 1;
await _repository.UpdateAsync(entity);
}
}
}
}

View File

@@ -1,27 +0,0 @@
using Volo.Abp.DependencyInjection;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.EventBus;
using Yi.Framework.Bbs.Domain.Entities;
using Yi.Framework.Bbs.Domain.Shared.Enums;
using Yi.Framework.Rbac.Domain.Shared.Etos;
namespace Yi.Framework.Bbs.Application.EventHandlers
{
public class UserCreateEventHandler : ILocalEventHandler<UserCreateEventArgs>, ITransientDependency
{
private IRepository<BbsUserExtraInfoEntity> _repository;
public UserCreateEventHandler(IRepository<BbsUserExtraInfoEntity> repository)
{
_repository = repository;
}
public async Task HandleEventAsync(UserCreateEventArgs eventData)
{
//创建主表
var bbsUser = new BbsUserExtraInfoEntity(eventData.UserId)
{
};
await _repository.InsertAsync(bbsUser);
}
}
}