From bf2b439ce18c4e32bf378841cfb71469f59ebec2 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Tue, 31 Dec 2024 13:12:39 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=B4=A6=E5=8F=B7=E8=A7=92?= =?UTF-8?q?=E8=89=B2=E7=A6=81=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/Common/MailService.cs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/IRaCIS.Core.Application/Service/Common/MailService.cs b/IRaCIS.Core.Application/Service/Common/MailService.cs index 6a130b053..a86c5b2a6 100644 --- a/IRaCIS.Core.Application/Service/Common/MailService.cs +++ b/IRaCIS.Core.Application/Service/Common/MailService.cs @@ -595,13 +595,24 @@ namespace IRaCIS.Core.Application.Service - await _userRoleRepository.SaveChangesAsync(); } else { - sysUserInfo = (await _identityUserRepository.Where(t => t.UserRoleList.Any(t => t.DoctorId == doctorId || t.IdentityUser.EMail == doctor.EMail)).Include(t => t.UserRoleList).FirstOrDefaultAsync()).IfNullThrowException(); + sysUserInfo = (await _identityUserRepository.Where(t => t.UserRoleList.Any(t => t.DoctorId == doctorId || t.IdentityUser.EMail == doctor.EMail), true).Include(t => t.UserRoleList).FirstOrDefaultAsync()).IfNullThrowException(); + + //不存在该角色,那么就加入该角色 + if (!sysUserInfo.UserRoleList.Any(t => t.UserTypeId == userType.Id)) + { + sysUserInfo.UserRoleList.Add(new UserRole() { DoctorId = doctorId, UserTypeEnum = UserTypeEnum.IndependentReviewer, UserTypeId = userType.Id }); + } + + sysUserInfo.Status = UserStateEnum.Enable; + } + + //保证能有userRoleId + await _userRoleRepository.SaveChangesAsync(); }