Compare commits
3 Commits
f79c12165e
...
6860f9437b
| Author | SHA1 | Date |
|---|---|---|
|
|
6860f9437b | |
|
|
a06e7a9a2c | |
|
|
ac8875acdf |
|
|
@ -13203,7 +13203,7 @@
|
|||
<param name="_readingConsistentClinicalDataRepository"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:IRaCIS.Core.Application.Service.TestService.UserMutiAccount(IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.IdentityUser})">
|
||||
<member name="M:IRaCIS.Core.Application.Service.TestService.UserMutiAccount(IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.IdentityUser},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.UserPassWordLog})">
|
||||
<summary>
|
||||
用户多账号,初次维护数据
|
||||
</summary>
|
||||
|
|
|
|||
|
|
@ -32,9 +32,9 @@ namespace IRaCIS.Core.Application.Service
|
|||
.ForMember(d => d.SubmitUserName, u => u.MapFrom(s => s.SubmitUser.FullName))
|
||||
.ForMember(d => d.ClinicalInformationTransmissionEnum, u => u.MapFrom(s => s.Trial.ClinicalInformationTransmissionEnum))
|
||||
|
||||
.ForMember(d => d.IsHaveClinicalData, u => u.MapFrom(t => t.IsBaseLine ? t.PreviousHistoryList.Any() || t.PreviousOtherList.Any()
|
||||
.ForMember(d => d.IsHaveClinicalData, u => u.MapFrom(t => t.IsBaseLine ? t.PreviousHistoryList.Any() || t.PreviousOtherList.Any() || t.PreviousSurgeryList.Any()
|
||||
|| t.ReadingClinicalDataList.Any(x => x.ClinicalDataTrialSet.UploadRole == Domain.Share.UploadRole.CRC && x.ReadingClinicalDataPDFList.Count > 0)
|
||||
|| t.PreviousSurgeryList.Any() : false))
|
||||
: false))
|
||||
|
||||
.ForMember(d => d.DicomStudyCount, u => u.MapFrom(t => t.StudyList.Count()))
|
||||
.ForMember(d => d.NoneDicomStudyCount, u => u.MapFrom(t => t.NoneDicomStudyList.Count(t => t.NoneDicomFileList.Any())));
|
||||
|
|
|
|||
|
|
@ -0,0 +1,108 @@
|
|||
using IRaCIS.Core.Domain.Models;
|
||||
using IRaCIS.Core.Infrastructure;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IRaCIS.Core.Application.Service
|
||||
{
|
||||
public class VerifyCodeHelper
|
||||
{
|
||||
|
||||
|
||||
public static async Task<bool> VerifyUserCodeAsync(IRepository<VerificationCode> _verificationCodeRepository, EmailVerifyCodeType verifyCodeType, string email, string code)
|
||||
{
|
||||
return await VerifyUserCodeAsync(_verificationCodeRepository, verifyCodeType, null, email, code);
|
||||
}
|
||||
|
||||
public static async Task<bool> VerifyUserCodeAsync(IRepository<VerificationCode> _verificationCodeRepository, EmailVerifyCodeType verifyCodeType, Guid identityUserId, string code)
|
||||
{
|
||||
return await VerifyUserCodeAsync(_verificationCodeRepository, verifyCodeType, identityUserId, null, code);
|
||||
}
|
||||
|
||||
public static async Task<bool> VerifyUserCodeAsync(IRepository<VerificationCode> _verificationCodeRepository, EmailVerifyCodeType verifyCodeType, Guid? identityUserId, string? email, string code)
|
||||
{
|
||||
|
||||
var verifySuccess = false;
|
||||
|
||||
var verificationRecord = new VerificationCode();
|
||||
|
||||
|
||||
if (identityUserId != null)
|
||||
{
|
||||
verificationRecord = await _verificationCodeRepository.FirstOrDefaultAsync(t => t.UserId == identityUserId && t.Code == code && t.CodeType == 0);
|
||||
|
||||
if (verificationRecord != null)
|
||||
{
|
||||
//删除验证码历史记录
|
||||
await _verificationCodeRepository.BatchDeleteNoTrackingAsync(t => t.UserId == identityUserId && t.CodeType == 0);
|
||||
|
||||
|
||||
if (email != null)
|
||||
{
|
||||
var useEmail = email.Trim();
|
||||
|
||||
if (verificationRecord.EmailOrPhone.Trim() != useEmail)
|
||||
{
|
||||
//发送验证嘛的和提交的邮箱不一致
|
||||
|
||||
throw new BusinessValidationFailedException(I18n.T("User_VerificationEmailNotSameWithBefore"));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (email != null)
|
||||
{
|
||||
|
||||
var useEmail = email.Trim();
|
||||
|
||||
verificationRecord = await _verificationCodeRepository.FirstOrDefaultAsync(t => t.EmailOrPhone == useEmail && t.Code == code && t.CodeType == 0);
|
||||
|
||||
if (verificationRecord != null)
|
||||
{
|
||||
//删除验证码历史记录
|
||||
await _verificationCodeRepository.BatchDeleteNoTrackingAsync(t => t.EmailOrPhone == useEmail && t.CodeType == 0);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new InvalidOperationException("验证码参数不正确");
|
||||
}
|
||||
|
||||
//检查数据库是否存在该验证码
|
||||
if (verificationRecord == null)
|
||||
{
|
||||
//---验证码错误。
|
||||
|
||||
throw new BusinessValidationFailedException(I18n.T("User_VerificationCodeError"));
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
//检查验证码是否失效
|
||||
if (verificationRecord.ExpirationTime < DateTime.Now)
|
||||
{
|
||||
//---验证码已经过期。
|
||||
|
||||
throw new BusinessValidationFailedException(I18n.T("User_VerificationCodeExpired"));
|
||||
|
||||
}
|
||||
else //验证码正确 并且 没有超时
|
||||
{
|
||||
verifySuccess = true;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return verifySuccess;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -160,7 +160,7 @@ namespace IRaCIS.Core.Application.Service
|
|||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[AllowAnonymous]
|
||||
public async Task<IResponseOutput> UserMutiAccount([FromServices] IRepository<IdentityUser> _identityUserRepository)
|
||||
public async Task<IResponseOutput> UserMutiAccount([FromServices] IRepository<IdentityUser> _identityUserRepository, [FromServices] IRepository<UserPassWordLog> _userPasswordLogRepository)
|
||||
{
|
||||
|
||||
if ((await _identityUserRepository.FirstOrDefaultAsync()) == null)
|
||||
|
|
@ -187,6 +187,13 @@ namespace IRaCIS.Core.Application.Service
|
|||
await _identityUserRepository.AddAsync(identityUser);
|
||||
|
||||
await _userRoleRepository.BatchUpdateNoTrackingAsync(t => emailUserIdList.Contains(t.Id), u => new UserRole() { IdentityUserId = identityUserId });
|
||||
|
||||
if (emailUserIdList.Count == 1)
|
||||
{
|
||||
var userRoleId = emailUserIdList.First();
|
||||
|
||||
await _userPasswordLogRepository.BatchUpdateNoTrackingAsync(t => t.UserId == userRoleId, u => new UserPassWordLog() { IdentityUserId = identityUserId });
|
||||
}
|
||||
}
|
||||
|
||||
await _identityUserRepository.SaveChangesAsync();
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ namespace IRaCIS.Core.Application.Triggers
|
|||
}
|
||||
}
|
||||
|
||||
//这里提交事务 多次 会进入多次 导致新生成的裁判任务设置了后,再次进入,又设置为null了
|
||||
//这个放在save 之前,不然可能先执行添加的修改为正确的,再执行修改的,又重置为空了 所以这里需要调整下 (裁判重阅,会修改裁判需要充值, 同时也会新增裁判任务)
|
||||
public async Task BeforeSave(ITriggerContext<VisitTask> context, CancellationToken cancellationToken)
|
||||
{
|
||||
|
|
@ -53,7 +54,13 @@ namespace IRaCIS.Core.Application.Triggers
|
|||
if (find != null)
|
||||
{
|
||||
var ids = new Guid[] { find.TaskIdOne, find.TaskIdTwo };
|
||||
await _visitTaskRepository.BatchUpdateNoTrackingAsync(t => ids.Contains(t.Id), u => new VisitTask() { JudgeVisitTaskId = null });
|
||||
|
||||
if(!_readingJudgeInfoRepository.Any(t=> ids.Contains(t.TaskIdOne) && t.CreateTime > find.CreateTime))
|
||||
{
|
||||
await _visitTaskRepository.BatchUpdateNoTrackingAsync(t => ids.Contains(t.Id), u => new VisitTask() { JudgeVisitTaskId = null });
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,3 +24,17 @@ public class VerificationCode : BaseAddAuditEntity
|
|||
public DateTime ExpirationTime { get; set; }
|
||||
|
||||
}
|
||||
|
||||
public enum EmailVerifyCodeType
|
||||
{
|
||||
|
||||
ModifyEmail = 1,
|
||||
|
||||
SiteSurvey = 2,
|
||||
|
||||
ForgetPassword = 3,
|
||||
|
||||
MFA = 4,
|
||||
|
||||
AdminResetPassword = 5
|
||||
}
|
||||
Loading…
Reference in New Issue