修改账户触发日志
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
30edf87bc0
commit
5ea6d221e3
|
|
@ -1,5 +1,6 @@
|
|||
using EntityFramework.Exceptions.SqlServer;
|
||||
using IRaCIS.Core.Application.Triggers;
|
||||
using IRaCIS.Core.Application.Triggers.AfterSaveTrigger;
|
||||
using IRaCIS.Core.Domain.Share;
|
||||
using IRaCIS.Core.Infra.EFCore;
|
||||
using IRaCIS.Core.Infra.EFCore.Interceptor;
|
||||
|
|
@ -81,7 +82,7 @@ namespace IRaCIS.Core.API
|
|||
|
||||
triggerOptions.AddTrigger<UserAddTrigger>();
|
||||
|
||||
triggerOptions.AddTrigger<UserModifyTrigger>();
|
||||
triggerOptions.AddTrigger<IdenttiyUserRoleInfoTrigger>();
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -17348,6 +17348,20 @@
|
|||
<param name="_qcChallengeRepository"></param>
|
||||
<param name="_subjectVisitRepository"></param>
|
||||
</member>
|
||||
<member name="T:IRaCIS.Core.Application.Triggers.AfterSaveTrigger.IdenttiyUserRoleInfoTrigger">
|
||||
<summary>
|
||||
维护用户角色表中的账户信息
|
||||
</summary>
|
||||
<param name="_identityUserRepository"></param>
|
||||
<param name="_userRoleRepository"></param>
|
||||
</member>
|
||||
<member name="M:IRaCIS.Core.Application.Triggers.AfterSaveTrigger.IdenttiyUserRoleInfoTrigger.#ctor(IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.IdentityUser},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.UserRole})">
|
||||
<summary>
|
||||
维护用户角色表中的账户信息
|
||||
</summary>
|
||||
<param name="_identityUserRepository"></param>
|
||||
<param name="_userRoleRepository"></param>
|
||||
</member>
|
||||
<member name="T:IRaCIS.Core.Application.Triggers.TrialCriterionSignTrigger">
|
||||
<summary>
|
||||
因为可能先一致性核查通过,生成其他标准的任务了,新签名的标准也需要产生任务
|
||||
|
|
|
|||
|
|
@ -141,7 +141,8 @@ namespace IRaCIS.Core.Application.Service
|
|||
CreateMap<IdentityUser, UserBasicInfo>()
|
||||
.ForMember(d => d.IdentityUserId, c => c.MapFrom(t => t.Id));
|
||||
|
||||
|
||||
CreateMap<UserRole, IdentityUserTypeDTO>()
|
||||
.ForMember(d => d.UserTypeShortName, c => c.MapFrom(t => t.UserTypeRole.UserTypeShortName));
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,52 @@
|
|||
|
||||
//--------------------------------------------------------------------
|
||||
// 此代码由liquid模板自动生成 byzhouhang 20240909
|
||||
// 生成时间 2025-08-18 03:23:09Z
|
||||
// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。
|
||||
//--------------------------------------------------------------------
|
||||
using System;
|
||||
using IRaCIS.Core.Domain.Share;
|
||||
using System.Collections.Generic;
|
||||
namespace IRaCIS.Core.Application.ViewModel;
|
||||
|
||||
public class HospitalGroupView : HospitalGroupAddOrEdit
|
||||
{
|
||||
|
||||
public DateTime CreateTime { get; set; }
|
||||
|
||||
public DateTime UpdateTime { get; set; }
|
||||
|
||||
}
|
||||
|
||||
|
||||
public class HospitalGroupAddOrEdit
|
||||
{
|
||||
public Guid? Id { get; set; }
|
||||
|
||||
public string Affiliation { get; set; }
|
||||
|
||||
public string Code { get; set; }
|
||||
|
||||
public string ContactName { get; set; }
|
||||
|
||||
public string ContactPhone { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
}
|
||||
|
||||
public class HospitalGroupQuery : PageInput
|
||||
{
|
||||
public string? Affiliation { get; set; }
|
||||
|
||||
public string? Code { get; set; }
|
||||
|
||||
public string? ContactName { get; set; }
|
||||
|
||||
public string? ContactPhone { get; set; }
|
||||
|
||||
public string? Name { get; set; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,88 @@
|
|||
|
||||
//--------------------------------------------------------------------
|
||||
// 此代码由liquid模板自动生成 byzhouhang 20240909
|
||||
// 生成时间 2025-08-18 03:23:01Z
|
||||
// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。
|
||||
//--------------------------------------------------------------------
|
||||
using IRaCIS.Core.Domain.Models;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using IRaCIS.Core.Application.Interfaces;
|
||||
using IRaCIS.Core.Application.ViewModel;
|
||||
using IRaCIS.Core.Infrastructure.Extention;
|
||||
using System.Threading.Tasks;
|
||||
using IRaCIS.Core.Infra.EFCore;
|
||||
using IRaCIS.Application.Contracts;
|
||||
namespace IRaCIS.Core.Application.Service;
|
||||
|
||||
[ApiExplorerSettings(GroupName = "Test")]
|
||||
public class HospitalGroupService(IRepository<HospitalGroup> _hospitalGroupRepository,
|
||||
IMapper _mapper, IUserInfo _userInfo, IStringLocalizer _localizer) : BaseService, IHospitalGroupService
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
[HttpPost]
|
||||
public async Task<List<HospitalGroupView>> GetHospitalGroupList(HospitalGroupQuery inQuery)
|
||||
{
|
||||
|
||||
var hospitalGroupQueryable = _hospitalGroupRepository
|
||||
.WhereIf(!string.IsNullOrWhiteSpace(inQuery.Code), t => t.Code.Contains(inQuery.Code))
|
||||
.WhereIf(!string.IsNullOrWhiteSpace(inQuery.Name), t => t.Name.Contains(inQuery.Name))
|
||||
.WhereIf(!string.IsNullOrWhiteSpace(inQuery.Affiliation), t => t.Affiliation.Contains(inQuery.Affiliation))
|
||||
.WhereIf(!string.IsNullOrWhiteSpace(inQuery.ContactPhone), t => t.ContactPhone.Contains(inQuery.ContactPhone))
|
||||
.WhereIf(!string.IsNullOrWhiteSpace(inQuery.ContactName), t => t.ContactName.Contains(inQuery.ContactName))
|
||||
.ProjectTo<HospitalGroupView>(_mapper.ConfigurationProvider);
|
||||
|
||||
var pageList = await hospitalGroupQueryable.SortToListAsync(inQuery);
|
||||
|
||||
return pageList;
|
||||
}
|
||||
|
||||
|
||||
[HttpPost]
|
||||
public async Task<PageOutput<HospitalGroupView>> GetHospitalGroupPageList(HospitalGroupQuery inQuery)
|
||||
{
|
||||
|
||||
var hospitalGroupQueryable = _hospitalGroupRepository
|
||||
.WhereIf(!string.IsNullOrWhiteSpace(inQuery.Code), t => t.Code.Contains(inQuery.Code))
|
||||
.WhereIf(!string.IsNullOrWhiteSpace(inQuery.Name), t => t.Name.Contains(inQuery.Name))
|
||||
.WhereIf(!string.IsNullOrWhiteSpace(inQuery.Affiliation), t => t.Affiliation.Contains(inQuery.Affiliation))
|
||||
.WhereIf(!string.IsNullOrWhiteSpace(inQuery.ContactPhone), t => t.ContactPhone.Contains(inQuery.ContactPhone))
|
||||
.WhereIf(!string.IsNullOrWhiteSpace(inQuery.ContactName), t => t.ContactName.Contains(inQuery.ContactName))
|
||||
.ProjectTo<HospitalGroupView>(_mapper.ConfigurationProvider);
|
||||
|
||||
var pageList = await hospitalGroupQueryable.ToPagedListAsync(inQuery);
|
||||
|
||||
return pageList;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public async Task<IResponseOutput> AddOrUpdateHospitalGroup(HospitalGroupAddOrEdit addOrEditHospitalGroup)
|
||||
{
|
||||
var verifyExp1 = new EntityVerifyExp<HospitalGroup>()
|
||||
{
|
||||
VerifyExp = u => u.Code == addOrEditHospitalGroup.Code,
|
||||
VerifyMsg = _localizer["HospitalGroup_DuplicateCode"]
|
||||
};
|
||||
|
||||
|
||||
var entity = await _hospitalGroupRepository.InsertOrUpdateAsync(addOrEditHospitalGroup, true, verifyExp1);
|
||||
|
||||
return ResponseOutput.Ok(entity.Id.ToString());
|
||||
|
||||
}
|
||||
|
||||
|
||||
[HttpDelete("{hospitalGroupId:guid}")]
|
||||
public async Task<IResponseOutput> DeleteHospitalGroup(Guid hospitalGroupId)
|
||||
{
|
||||
var success = await _hospitalGroupRepository.DeleteFromQueryAsync(t => t.Id == hospitalGroupId, true);
|
||||
return ResponseOutput.Ok();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
|
||||
//--------------------------------------------------------------------
|
||||
// 此代码由liquid模板自动生成 byzhouhang 20240909
|
||||
// 生成时间 2025-08-18 03:23:09Z
|
||||
// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。
|
||||
//--------------------------------------------------------------------
|
||||
using System;
|
||||
using IRaCIS.Core.Infrastructure.Extention;
|
||||
using System.Threading.Tasks;
|
||||
using IRaCIS.Core.Application.ViewModel;
|
||||
namespace IRaCIS.Core.Application.Interfaces;
|
||||
|
||||
public interface IHospitalGroupService
|
||||
{
|
||||
|
||||
|
||||
Task<List<HospitalGroupView>> GetHospitalGroupList(HospitalGroupQuery inQuery);
|
||||
|
||||
Task<PageOutput<HospitalGroupView>> GetHospitalGroupPageList(HospitalGroupQuery inQuery);
|
||||
|
||||
Task<IResponseOutput> AddOrUpdateHospitalGroup(HospitalGroupAddOrEdit addOrEditHospitalGroup);
|
||||
|
||||
Task<IResponseOutput> DeleteHospitalGroup(Guid hospitalGroupId);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -199,6 +199,11 @@ namespace IRaCIS.Core.Application.Service
|
|||
|
||||
CreateMap<HIRHospital, HIRHospitalView>();
|
||||
CreateMap<HIRHospital, HIRHospitalAddOrEdit>().ReverseMap();
|
||||
|
||||
|
||||
|
||||
CreateMap<HospitalGroup, HospitalGroupView>();
|
||||
CreateMap<HospitalGroup, HospitalGroupAddOrEdit>().ReverseMap();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,35 @@
|
|||
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
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 维护用户角色表中的账户信息
|
||||
/// </summary>
|
||||
/// <param name="_identityUserRepository"></param>
|
||||
/// <param name="_userRoleRepository"></param>
|
||||
public class IdenttiyUserRoleInfoTrigger(IRepository<IdentityUser> _identityUserRepository, IRepository<UserRole> _userRoleRepository) : IAfterSaveTrigger<IdentityUser>
|
||||
{
|
||||
public async Task AfterSave(ITriggerContext<IdentityUser> context, CancellationToken cancellationToken)
|
||||
{
|
||||
var identityUser = context.Entity;
|
||||
|
||||
//保持用户角色表和用户表信息一致
|
||||
await _userRoleRepository.BatchUpdateNoTrackingAsync(t => t.IdentityUserId == identityUser.Id, u => new UserRole()
|
||||
{
|
||||
UserName = identityUser.UserName,
|
||||
FirstName = identityUser.FirstName,
|
||||
LastName = identityUser.LastName,
|
||||
EMail = identityUser.EMail,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
using EntityFrameworkCore.Triggered;
|
||||
using IP2Region.Net.Abstractions;
|
||||
using IRaCIS.Core.Application.Helper;
|
||||
|
||||
namespace IRaCIS.Core.Application.Triggers
|
||||
{
|
||||
public class UserLogTrigger(
|
||||
ISearcher _searcher) : IBeforeSaveTrigger<UserLog>
|
||||
public class UserLogTrigger : IBeforeSaveTrigger<UserLog>
|
||||
{
|
||||
|
||||
|
||||
|
|
@ -18,102 +18,31 @@ namespace IRaCIS.Core.Application.Triggers
|
|||
if (context.ChangeType == ChangeType.Added)
|
||||
{
|
||||
|
||||
var ipinfo = _searcher.Search(userLog.IP);
|
||||
//var ipinfo = _searcher.Search(userLog.IP);
|
||||
|
||||
userLog.IPRegion = string.Join('|', ipinfo.Split('|').TakeLast(3));
|
||||
//userLog.IPRegion = string.Join('|', ipinfo.Split('|').TakeLast(3));
|
||||
|
||||
userLog.IPRegion = IPCityHelper.GetCityResponse(userLog.IP);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class UserAddTrigger(IUserInfo _userInfo, IRepository<UserLog> _userLogReposiotry) : IBeforeSaveTrigger<UserRole>
|
||||
public class UserAddTrigger(IUserInfo _userInfo, IRepository<UserLog> _userLogReposiotry) : IBeforeSaveTrigger<IdentityUser>
|
||||
{
|
||||
public async Task BeforeSave(ITriggerContext<UserRole> context, CancellationToken cancellationToken)
|
||||
public async Task BeforeSave(ITriggerContext<IdentityUser> context, CancellationToken cancellationToken)
|
||||
{
|
||||
var user = context.Entity;
|
||||
|
||||
if (context.ChangeType == ChangeType.Added)
|
||||
{
|
||||
await _userLogReposiotry.AddAsync(new UserLog() { OptType = UserOptType.AddUser, OptUserId = user.Id, LoginUserId = _userInfo.UserRoleId, IP = _userInfo.IP });
|
||||
await _userLogReposiotry.AddAsync(new UserLog() { IP = _userInfo.IP, ActionIdentityUserId = _userInfo.IdentityUserId, ActionUserName = _userInfo.UserName, TargetIdentityUserId = user.Id, OptType = UserOptType.AddUser }, true);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public class UserModifyTrigger(IUserInfo _userInfo, IRepository<UserRole> _userReposiotry) : IBeforeSaveTrigger<UserRole>
|
||||
{
|
||||
public async Task BeforeSave(ITriggerContext<UserRole> context, CancellationToken cancellationToken)
|
||||
{
|
||||
var user = context.Entity;
|
||||
|
||||
var beforeUser = context.UnmodifiedEntity;
|
||||
|
||||
if (context.ChangeType == ChangeType.Modified)
|
||||
{
|
||||
|
||||
if (beforeUser.IsFirstAdd == false && user.IsFirstAdd == true)
|
||||
{
|
||||
|
||||
await _userReposiotry.BatchUpdateNoTrackingAsync(t => t.EMail == user.EMail, u => new UserRole() { IsFirstAdd = true });
|
||||
}
|
||||
|
||||
//只用初始化其中一个
|
||||
if (beforeUser.IsFirstAdd == true && user.IsFirstAdd == false)
|
||||
{
|
||||
|
||||
await _userReposiotry.BatchUpdateNoTrackingAsync(t => t.EMail == user.EMail, u => new UserRole() { IsFirstAdd = false });
|
||||
}
|
||||
|
||||
if (beforeUser.Password != user.Password)
|
||||
{
|
||||
await _userReposiotry.BatchUpdateNoTrackingAsync(t => t.EMail == user.EMail, u => new UserRole() { Password = user.Password });
|
||||
}
|
||||
|
||||
|
||||
if (beforeUser.EMail != user.EMail)
|
||||
{
|
||||
await _userReposiotry.BatchUpdateNoTrackingAsync(t => t.EMail == beforeUser.EMail, u => new UserRole() { EMail = user.EMail });
|
||||
}
|
||||
|
||||
if (beforeUser.CheckCode != user.CheckCode)
|
||||
{
|
||||
await _userReposiotry.BatchUpdateNoTrackingAsync(t => t.EMail == user.EMail, u => new UserRole() { CheckCode = user.CheckCode });
|
||||
}
|
||||
|
||||
if (beforeUser.FirstName != user.FirstName || beforeUser.LastName != user.LastName)
|
||||
{
|
||||
await _userReposiotry.BatchUpdateNoTrackingAsync(t => t.EMail == user.EMail, u => new UserRole() { FirstName = user.FirstName, LastName = user.LastName });
|
||||
}
|
||||
|
||||
if (beforeUser.Phone != user.Phone)
|
||||
{
|
||||
await _userReposiotry.BatchUpdateNoTrackingAsync(t => t.EMail == user.EMail, u => new UserRole() { Phone = user.Phone });
|
||||
}
|
||||
|
||||
if (beforeUser.Sex != user.Sex)
|
||||
{
|
||||
await _userReposiotry.BatchUpdateNoTrackingAsync(t => t.EMail == user.EMail, u => new UserRole() { Sex = user.Sex });
|
||||
}
|
||||
|
||||
if (beforeUser.IsZhiZhun != user.IsZhiZhun)
|
||||
{
|
||||
await _userReposiotry.BatchUpdateNoTrackingAsync(t => t.EMail == user.EMail, u => new UserRole() { IsZhiZhun = user.IsZhiZhun, OrganizationName = user.OrganizationName });
|
||||
}
|
||||
|
||||
if (beforeUser.OrganizationName != user.OrganizationName)
|
||||
{
|
||||
await _userReposiotry.BatchUpdateNoTrackingAsync(t => t.EMail == user.EMail, u => new UserRole() { OrganizationName = user.OrganizationName });
|
||||
}
|
||||
|
||||
if (beforeUser.DepartmentName != user.DepartmentName || beforeUser.PositionName != user.PositionName)
|
||||
{
|
||||
await _userReposiotry.BatchUpdateNoTrackingAsync(t => t.EMail == user.EMail, u => new UserRole() { DepartmentName = user.DepartmentName, PositionName = user.PositionName });
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -81,7 +81,8 @@
|
|||
|
||||
MC = 30,
|
||||
|
||||
|
||||
//课题组管理员
|
||||
GA = 35,
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue