From 5ea6d221e390862a92b7073b73f6f22305880ae4 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Mon, 18 Aug 2025 11:44:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=B4=A6=E6=88=B7=E8=A7=A6?= =?UTF-8?q?=E5=8F=91=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IRaCIS.Core.API/_ServiceExtensions/EFSetup.cs | 3 +- .../IRaCIS.Core.Application.xml | 14 +++ .../Service/Management/_MapConfig.cs | 3 +- .../Visit/DTO/HospitalGroupViewModel.cs | 52 +++++++++++ .../Service/Visit/HospitalGroupService.cs | 88 ++++++++++++++++++ .../Visit/Interface/IHospitalGroupService.cs | 26 ++++++ .../Service/Visit/_MapConfig.cs | 5 + .../IdenttiyUserRoleInfoTrigger.cs | 35 +++++++ .../BeforeSaveTrigger/UserLogTrigger.cs | 91 ++----------------- IRaCIS.Core.Domain.Share/User/UserType.cs | 35 +++---- 10 files changed, 252 insertions(+), 100 deletions(-) create mode 100644 IRaCIS.Core.Application/Service/Visit/DTO/HospitalGroupViewModel.cs create mode 100644 IRaCIS.Core.Application/Service/Visit/HospitalGroupService.cs create mode 100644 IRaCIS.Core.Application/Service/Visit/Interface/IHospitalGroupService.cs create mode 100644 IRaCIS.Core.Application/Triggers/AfterSaveTrigger/IdenttiyUserRoleInfoTrigger.cs diff --git a/IRaCIS.Core.API/_ServiceExtensions/EFSetup.cs b/IRaCIS.Core.API/_ServiceExtensions/EFSetup.cs index 0b7ed2b8b..acbdea6db 100644 --- a/IRaCIS.Core.API/_ServiceExtensions/EFSetup.cs +++ b/IRaCIS.Core.API/_ServiceExtensions/EFSetup.cs @@ -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(); - triggerOptions.AddTrigger(); + triggerOptions.AddTrigger(); diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml index 0bdeb936a..87569ee7c 100644 --- a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml +++ b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml @@ -17348,6 +17348,20 @@ + + + 维护用户角色表中的账户信息 + + + + + + + 维护用户角色表中的账户信息 + + + + 因为可能先一致性核查通过,生成其他标准的任务了,新签名的标准也需要产生任务 diff --git a/IRaCIS.Core.Application/Service/Management/_MapConfig.cs b/IRaCIS.Core.Application/Service/Management/_MapConfig.cs index eb4c972ef..52e2c578d 100644 --- a/IRaCIS.Core.Application/Service/Management/_MapConfig.cs +++ b/IRaCIS.Core.Application/Service/Management/_MapConfig.cs @@ -141,7 +141,8 @@ namespace IRaCIS.Core.Application.Service CreateMap() .ForMember(d => d.IdentityUserId, c => c.MapFrom(t => t.Id)); - + CreateMap() + .ForMember(d => d.UserTypeShortName, c => c.MapFrom(t => t.UserTypeRole.UserTypeShortName)); } diff --git a/IRaCIS.Core.Application/Service/Visit/DTO/HospitalGroupViewModel.cs b/IRaCIS.Core.Application/Service/Visit/DTO/HospitalGroupViewModel.cs new file mode 100644 index 000000000..17cc81945 --- /dev/null +++ b/IRaCIS.Core.Application/Service/Visit/DTO/HospitalGroupViewModel.cs @@ -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; } +} + + + + diff --git a/IRaCIS.Core.Application/Service/Visit/HospitalGroupService.cs b/IRaCIS.Core.Application/Service/Visit/HospitalGroupService.cs new file mode 100644 index 000000000..967b17e4d --- /dev/null +++ b/IRaCIS.Core.Application/Service/Visit/HospitalGroupService.cs @@ -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 _hospitalGroupRepository, + IMapper _mapper, IUserInfo _userInfo, IStringLocalizer _localizer) : BaseService, IHospitalGroupService +{ + + + + + [HttpPost] + public async Task> 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(_mapper.ConfigurationProvider); + + var pageList = await hospitalGroupQueryable.SortToListAsync(inQuery); + + return pageList; + } + + + [HttpPost] + public async Task> 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(_mapper.ConfigurationProvider); + + var pageList = await hospitalGroupQueryable.ToPagedListAsync(inQuery); + + return pageList; + } + + + + public async Task AddOrUpdateHospitalGroup(HospitalGroupAddOrEdit addOrEditHospitalGroup) + { + var verifyExp1 = new EntityVerifyExp() + { + 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 DeleteHospitalGroup(Guid hospitalGroupId) + { + var success = await _hospitalGroupRepository.DeleteFromQueryAsync(t => t.Id == hospitalGroupId, true); + return ResponseOutput.Ok(); + } + +} + + + diff --git a/IRaCIS.Core.Application/Service/Visit/Interface/IHospitalGroupService.cs b/IRaCIS.Core.Application/Service/Visit/Interface/IHospitalGroupService.cs new file mode 100644 index 000000000..afca2de1f --- /dev/null +++ b/IRaCIS.Core.Application/Service/Visit/Interface/IHospitalGroupService.cs @@ -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> GetHospitalGroupList(HospitalGroupQuery inQuery); + + Task> GetHospitalGroupPageList(HospitalGroupQuery inQuery); + + Task AddOrUpdateHospitalGroup(HospitalGroupAddOrEdit addOrEditHospitalGroup); + + Task DeleteHospitalGroup(Guid hospitalGroupId); +} + + diff --git a/IRaCIS.Core.Application/Service/Visit/_MapConfig.cs b/IRaCIS.Core.Application/Service/Visit/_MapConfig.cs index b7bec2939..4f96e4055 100644 --- a/IRaCIS.Core.Application/Service/Visit/_MapConfig.cs +++ b/IRaCIS.Core.Application/Service/Visit/_MapConfig.cs @@ -199,6 +199,11 @@ namespace IRaCIS.Core.Application.Service CreateMap(); CreateMap().ReverseMap(); + + + + CreateMap(); + CreateMap().ReverseMap(); } } diff --git a/IRaCIS.Core.Application/Triggers/AfterSaveTrigger/IdenttiyUserRoleInfoTrigger.cs b/IRaCIS.Core.Application/Triggers/AfterSaveTrigger/IdenttiyUserRoleInfoTrigger.cs new file mode 100644 index 000000000..eee6976d3 --- /dev/null +++ b/IRaCIS.Core.Application/Triggers/AfterSaveTrigger/IdenttiyUserRoleInfoTrigger.cs @@ -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 +{ + + /// + /// 维护用户角色表中的账户信息 + /// + /// + /// + public class IdenttiyUserRoleInfoTrigger(IRepository _identityUserRepository, IRepository _userRoleRepository) : IAfterSaveTrigger + { + public async Task AfterSave(ITriggerContext 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, + }); + } + } + + + +} diff --git a/IRaCIS.Core.Application/Triggers/BeforeSaveTrigger/UserLogTrigger.cs b/IRaCIS.Core.Application/Triggers/BeforeSaveTrigger/UserLogTrigger.cs index ed2bd9d99..4b1887460 100644 --- a/IRaCIS.Core.Application/Triggers/BeforeSaveTrigger/UserLogTrigger.cs +++ b/IRaCIS.Core.Application/Triggers/BeforeSaveTrigger/UserLogTrigger.cs @@ -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 + public class UserLogTrigger : IBeforeSaveTrigger { @@ -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 _userLogReposiotry) : IBeforeSaveTrigger + public class UserAddTrigger(IUserInfo _userInfo, IRepository _userLogReposiotry) : IBeforeSaveTrigger { - public async Task BeforeSave(ITriggerContext context, CancellationToken cancellationToken) + public async Task BeforeSave(ITriggerContext 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 _userReposiotry) : IBeforeSaveTrigger - { - public async Task BeforeSave(ITriggerContext 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 }); - } - - } - - } - } } diff --git a/IRaCIS.Core.Domain.Share/User/UserType.cs b/IRaCIS.Core.Domain.Share/User/UserType.cs index ee05258e0..b42cd328b 100644 --- a/IRaCIS.Core.Domain.Share/User/UserType.cs +++ b/IRaCIS.Core.Domain.Share/User/UserType.cs @@ -60,28 +60,29 @@ Undefined = 0, - - EA=16, - MW=17, + EA = 16, + + MW = 17, - SMM=18, + SMM = 18, - CMM=19, + CMM = 19, - ZYSS=26, + ZYSS = 26, - ZYBS=27, + ZYBS = 27, - MC=30, + MC = 30, - + //课题组管理员 + GA = 35, } @@ -89,16 +90,16 @@ public enum UserTypeSelectEnum { - None=0, + None = 0, - ExternalUser=1, + ExternalUser = 1, - InnerUser=2, + InnerUser = 2, - SiteSurvey=3, + SiteSurvey = 3, - EnrollOrPD_EmailReceive=4, - EnrollOrPD_EMailCopy=5, + EnrollOrPD_EmailReceive = 4, + EnrollOrPD_EMailCopy = 5, //HIR TrialDoc = 6, @@ -106,9 +107,9 @@ public enum UserMFAType { - Login=0, + Login = 0, - Unlock=1, + Unlock = 1, }