feat: 完善实体追踪审计日志
This commit is contained in:
@@ -49,6 +49,22 @@ namespace Yi.Framework.Bbs.Domain.Entities
|
||||
/// 经验
|
||||
/// </summary>
|
||||
public long Experience { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 发表主题数
|
||||
/// </summary>
|
||||
public int DiscussNumber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 发表主题数
|
||||
/// </summary>
|
||||
public int CommentNumber { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 被点赞数
|
||||
/// </summary>
|
||||
public int AgreeNumber { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
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
|
||||
{
|
||||
/// <summary>
|
||||
/// 被点赞
|
||||
/// </summary>
|
||||
public class AgreeCreatedEventHandler : ILocalEventHandler<EntityCreatedEventData<AgreeEntity>>,
|
||||
ITransientDependency
|
||||
{
|
||||
private ISqlSugarRepository<BbsUserExtraInfoEntity> _userRepository;
|
||||
private ISqlSugarRepository<AgreeEntity> _agreeRepository;
|
||||
public AgreeCreatedEventHandler(ISqlSugarRepository<BbsUserExtraInfoEntity> userRepository, ISqlSugarRepository<AgreeEntity> agreeRepository)
|
||||
{
|
||||
_userRepository = userRepository;
|
||||
_agreeRepository = agreeRepository;
|
||||
}
|
||||
public async Task HandleEventAsync(EntityCreatedEventData<AgreeEntity> eventData)
|
||||
{
|
||||
var agreeEntity = eventData.Entity;
|
||||
var userId = await _agreeRepository._DbQueryable.LeftJoin<DiscussEntity>((agree, discuss) => agree.DiscussId == discuss.Id)
|
||||
.Select((agree, discuss) => discuss.CreatorId).FirstAsync();
|
||||
|
||||
//给创建者发布数量+1
|
||||
await _userRepository._Db.Updateable<BbsUserExtraInfoEntity>()
|
||||
.SetColumns(it => it.DiscussNumber == it.DiscussNumber + 1)
|
||||
.Where(it => it.Id == userId)
|
||||
.ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取消点赞
|
||||
/// </summary>
|
||||
public class AgreeDeletedEventHandler : ILocalEventHandler<EntityCreatedEventData<AgreeEntity>>,
|
||||
ITransientDependency
|
||||
{
|
||||
private ISqlSugarRepository<BbsUserExtraInfoEntity> _userRepository;
|
||||
private ISqlSugarRepository<AgreeEntity> _agreeRepository;
|
||||
public AgreeDeletedEventHandler(ISqlSugarRepository<BbsUserExtraInfoEntity> userRepository, ISqlSugarRepository<AgreeEntity> agreeRepository)
|
||||
{
|
||||
_userRepository = userRepository;
|
||||
_agreeRepository = agreeRepository;
|
||||
}
|
||||
public async Task HandleEventAsync(EntityCreatedEventData<AgreeEntity> eventData)
|
||||
{
|
||||
var agreeEntity = eventData.Entity;
|
||||
var userId = await _agreeRepository._DbQueryable.LeftJoin<DiscussEntity>((agree, discuss) => agree.DiscussId == discuss.Id)
|
||||
.Select((agree, discuss) => discuss.CreatorId).FirstAsync();
|
||||
|
||||
//给创建者发布数量-1
|
||||
await _userRepository._Db.Updateable<BbsUserExtraInfoEntity>()
|
||||
.SetColumns(it => it.DiscussNumber == it.DiscussNumber - 1)
|
||||
.Where(it => it.Id == userId)
|
||||
.ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
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
|
||||
{
|
||||
/// <summary>
|
||||
/// 评论创建的领域事件
|
||||
/// </summary>
|
||||
public class CommentCreatedEventHandler : ILocalEventHandler<EntityCreatedEventData<CommentEntity>>,
|
||||
ITransientDependency
|
||||
{
|
||||
private ISqlSugarRepository<BbsUserExtraInfoEntity> _userRepository;
|
||||
public CommentCreatedEventHandler(ISqlSugarRepository<BbsUserExtraInfoEntity> userRepository)
|
||||
{
|
||||
_userRepository = userRepository;
|
||||
}
|
||||
public async Task HandleEventAsync(EntityCreatedEventData<CommentEntity> eventData)
|
||||
{
|
||||
var commentEntity = eventData.Entity;
|
||||
|
||||
//给创建者发布数量+1
|
||||
await _userRepository._Db.Updateable<BbsUserExtraInfoEntity>()
|
||||
.SetColumns(it => it.CommentNumber == it.CommentNumber + 1)
|
||||
.Where(it => it.Id == commentEntity.CreatorId)
|
||||
.ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
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
|
||||
{
|
||||
/// <summary>
|
||||
/// 主题创建的领域事件
|
||||
/// </summary>
|
||||
public class DiscussCreatedEventHandler : ILocalEventHandler<EntityCreatedEventData<DiscussEntity>>,
|
||||
ITransientDependency
|
||||
{
|
||||
private ISqlSugarRepository<BbsUserExtraInfoEntity> _userRepository;
|
||||
public DiscussCreatedEventHandler(ISqlSugarRepository<BbsUserExtraInfoEntity> userRepository)
|
||||
{
|
||||
_userRepository = userRepository;
|
||||
}
|
||||
public async Task HandleEventAsync(EntityCreatedEventData<DiscussEntity> eventData)
|
||||
{
|
||||
var disucussEntity = eventData.Entity;
|
||||
|
||||
//给创建者发布数量+1
|
||||
await _userRepository._Db.Updateable<BbsUserExtraInfoEntity>()
|
||||
.SetColumns(it => it.DiscussNumber == it.DiscussNumber + 1)
|
||||
.Where(it => it.Id == disucussEntity.CreatorId)
|
||||
.ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@ using Yi.Framework.Bbs.Domain.Entities;
|
||||
using Yi.Framework.Bbs.Domain.Shared.Etos;
|
||||
using Yi.Framework.SqlSugarCore.Abstractions;
|
||||
|
||||
namespace Yi.Framework.Bbs.Application.EventHandlers
|
||||
namespace Yi.Framework.Bbs.Domain.EventHandlers
|
||||
{
|
||||
public class MoneyChangeEventHandler : ILocalEventHandler<MoneyChangeEventArgs>, ITransientDependency
|
||||
{
|
||||
@@ -9,7 +9,7 @@ using Volo.Abp.EventBus;
|
||||
using Yi.Framework.Bbs.Domain.Entities.Forum;
|
||||
using Yi.Framework.Bbs.Domain.Shared.Etos;
|
||||
|
||||
namespace Yi.Framework.Bbs.Application.EventHandlers
|
||||
namespace Yi.Framework.Bbs.Domain.EventHandlers
|
||||
{
|
||||
public class SeeDiscussEventHandler : ILocalEventHandler<SeeDiscussEventArgs>, ITransientDependency
|
||||
{
|
||||
@@ -5,7 +5,7 @@ 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
|
||||
namespace Yi.Framework.Bbs.Domain.EventHandlers
|
||||
{
|
||||
public class UserCreateEventHandler : ILocalEventHandler<UserCreateEventArgs>, ITransientDependency
|
||||
{
|
||||
@@ -31,7 +31,10 @@ namespace Yi.Framework.Bbs.Domain.Managers
|
||||
Level=info.Level,
|
||||
UserLimit=info.UserLimit,
|
||||
Money = info.Money,
|
||||
Experience = info.Experience
|
||||
Experience = info.Experience,
|
||||
AgreeNumber=info.AgreeNumber,
|
||||
CommentNumber=info.CommentNumber,
|
||||
DiscussNumber=info.DiscussNumber
|
||||
}, true)
|
||||
.FirstAsync(user => user.Id==userId);
|
||||
}
|
||||
@@ -43,7 +46,10 @@ namespace Yi.Framework.Bbs.Domain.Managers
|
||||
.LeftJoin<BbsUserExtraInfoEntity>((user, info) => user.Id == info.UserId)
|
||||
.Select((user, info) => new BbsUserInfoDto { Id = user.Id , Icon = user.Icon , Level = info.Level, UserLimit = info.UserLimit,
|
||||
Money = info.Money,
|
||||
Experience = info.Experience
|
||||
Experience = info.Experience,
|
||||
AgreeNumber = info.AgreeNumber,
|
||||
CommentNumber = info.CommentNumber,
|
||||
DiscussNumber = info.DiscussNumber
|
||||
},true)
|
||||
|
||||
.ToListAsync();
|
||||
@@ -90,5 +96,18 @@ namespace Yi.Framework.Bbs.Domain.Managers
|
||||
/// </summary>
|
||||
public long Experience { get; set; }
|
||||
|
||||
public int DiscussNumber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 发表主题数
|
||||
/// </summary>
|
||||
public int CommentNumber { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 被点赞数
|
||||
/// </summary>
|
||||
public int AgreeNumber { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ using Volo.Abp.EventBus;
|
||||
using Yi.Framework.Rbac.Domain.Entities;
|
||||
using Yi.Framework.Rbac.Domain.Shared.Etos;
|
||||
|
||||
namespace Yi.Framework.Rbac.Application.EventHandlers
|
||||
namespace Yi.Framework.Rbac.Domain.EventHandlers
|
||||
{
|
||||
public class LoginEventHandler : ILocalEventHandler<LoginEventArgs>,
|
||||
ITransientDependency
|
||||
@@ -3,7 +3,7 @@ using Volo.Abp.Domain.Entities.Events;
|
||||
using Volo.Abp.EventBus;
|
||||
using Yi.Framework.Rbac.Domain.Entities;
|
||||
|
||||
namespace Yi.Framework.Rbac.Application.EventHandlers
|
||||
namespace Yi.Framework.Rbac.Domain.EventHandlers
|
||||
{
|
||||
public class StudentEventHandler : ILocalEventHandler<EntityCreatedEventData<StudentEntity>>, ITransientDependency
|
||||
{
|
||||
Reference in New Issue
Block a user