修改 创建账号仅仅记录一条
continuous-integration/drone/push Build is passing

This commit is contained in:
2025-02-17 17:15:25 +08:00
parent 4555997957
commit fed2cbe043
4 changed files with 44 additions and 22 deletions
@@ -54,6 +54,7 @@ namespace IRaCIS.Core.Application.Contracts
ITokenService _tokenService,
IRepository<UserType> _userTypeRepository,
IMailVerificationService _mailVerificationService,
IRepository<UserLog> _userLogRepository,
IOptionsMonitor<SystemEmailSendConfig> systemEmailConfig, IMapper _mapper, IUserInfo _userInfo, IStringLocalizer _localizer) : BaseService, ITrialSiteSurveyService
{
private readonly SystemEmailSendConfig _systemEmailConfig = systemEmailConfig.CurrentValue;
@@ -672,7 +673,7 @@ namespace IRaCIS.Core.Application.Contracts
TrialSiteSurveyId = currentEntity!.Id,
Token = _tokenService.GetToken(new UserTokenInfo()
{
IdentityUserId=Guid.NewGuid(),
IdentityUserId = Guid.NewGuid(),
UserRoleId = Guid.NewGuid(),
UserName = "SiteSurvey",
UserTypeEnum = UserTypeEnum.Undefined,
@@ -871,6 +872,8 @@ namespace IRaCIS.Core.Application.Contracts
#region
//需要创建新的账户
var isNeedCreateNewUser = existSysUser == null;
if (existSysUser != null)
{
@@ -949,11 +952,12 @@ namespace IRaCIS.Core.Application.Contracts
}
#endregion
await _identityUserRepository.SaveChangesAsync();
var identityUserId = existSysUser.Id;
#region
@@ -1048,12 +1052,18 @@ namespace IRaCIS.Core.Application.Contracts
if (isNeedSendEmail)
{
//创建账号 和创建角色 一条,更新的时候才记录更新角色
if (isNeedCreateNewUser == false)
{
await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, ActionIdentityUserId = _userInfo.IdentityUserId, ActionUserName = _userInfo.UserName, TargetIdentityUserId = identityUserId, OptType = UserOptType.UpdateUserRole });
}
var dbUserType = _userTypeRepository.Where(t => userTypeIdList.Contains(t.Id)).ToList();
var usertyps = string.Join(',', dbUserType.Select(t => t.UserTypeName));
await _mailVerificationService.SiteSurveyUserJoinEmail(trialId, identityUserId, usertyps, baseUrl, routeUrl);
}
var userJoinIdList = item.Select(t => t.Id).ToList();
@@ -1104,6 +1114,9 @@ namespace IRaCIS.Core.Application.Contracts
var existSysUser = await _identityUserRepository.Where(t => t.EMail == userEmail, true).Include(t => t.UserRoleList).FirstOrDefaultAsync();
//需要创建新的账户
var isNeedCreateNewUser = existSysUser == null;
if (existSysUser != null)
{
@@ -1288,9 +1301,17 @@ namespace IRaCIS.Core.Application.Contracts
if (isNeedSendEmail)
{
//创建账号 和创建角色 一条,更新的时候才记录更新角色
if (isNeedCreateNewUser == false)
{
await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, ActionIdentityUserId = _userInfo.IdentityUserId, ActionUserName = _userInfo.UserName, TargetIdentityUserId = identityUserId, OptType = UserOptType.UpdateUserRole });
}
var dbUserType = _userTypeRepository.Where(t => userTypeIdList.Contains(t.Id)).ToList();
var usertyps = string.Join(',', dbUserType.Select(t => t.UserTypeName));
await _mailVerificationService.SiteSurveyUserJoinEmail(trialId, identityUserId, usertyps, baseUrl, routeUrl);
}
await _trialSiteUserRoleRepository.SaveChangesAsync();