修改用户日志
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
using AutoMapper.QueryableExtensions;
|
||||
using EntityFrameworkCore.Triggered;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IRaCIS.Core.Application.Triggers.AfterSaveTrigger
|
||||
{
|
||||
public class UserLogAfterTrigger(IRepository<IdentityUser> _identityUserRepository) : IAfterSaveTrigger<UserLog>
|
||||
{
|
||||
public async Task AfterSave(ITriggerContext<UserLog> context, CancellationToken cancellationToken)
|
||||
{
|
||||
var userlog = context.Entity;
|
||||
|
||||
if (context.ChangeType == ChangeType.Added)
|
||||
{
|
||||
|
||||
if (userlog.TargetIdentityUserId != null)
|
||||
{
|
||||
var obj = await _identityUserRepository.Where(t => t.Id == userlog.TargetIdentityUserId).Select(t => new UserLogJsonObj()
|
||||
{
|
||||
DepartmentName = t.DepartmentName,
|
||||
EMail = t.EMail,
|
||||
FirstName = t.FirstName,
|
||||
LastName = t.LastName,
|
||||
OrganizationName = t.OrganizationName,
|
||||
Phone = t.Phone,
|
||||
PositionName = t.PositionName,
|
||||
Sex = t.Sex,
|
||||
Status = t.Status,
|
||||
UserCode = t.UserCode,
|
||||
UserName = t.UserName,
|
||||
UserRoleList = t.UserRoleList.Select(t => new UserRoleLogObj()
|
||||
{
|
||||
IsUserRoleDisabled = t.IsUserRoleDisabled,
|
||||
UserTypeEnum = t.UserTypeEnum,
|
||||
UserTypeShortName = t.UserTypeRole.UserTypeShortName
|
||||
}).ToList()
|
||||
|
||||
}).FirstOrDefaultAsync();
|
||||
|
||||
userlog.JsonObj = obj;
|
||||
|
||||
await _identityUserRepository.SaveChangesAsync();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user