diff --git a/IRaCIS.Core.Application/Service/Common/DictionaryService.cs b/IRaCIS.Core.Application/Service/Common/DictionaryService.cs index 26f1e9ed1..2934a28f5 100644 --- a/IRaCIS.Core.Application/Service/Common/DictionaryService.cs +++ b/IRaCIS.Core.Application/Service/Common/DictionaryService.cs @@ -40,7 +40,7 @@ namespace IRaCIS.Application.Services public async Task> GetBasicDicList(BasicDicQuery basicDicQuery) { - var systemBasicDataQueryable = _repository.GetQueryable().Where(t => t.ParentId == null) + var systemBasicDataQueryable = _dicRepository.Where(t => t.ParentId == null) .WhereIf(!string.IsNullOrEmpty(basicDicQuery.Code), t => t.Code.Contains(basicDicQuery.Code!)) .WhereIf(!string.IsNullOrEmpty(basicDicQuery.KeyName), t => t.KeyName.Contains(basicDicQuery.KeyName!)) .WhereIf(basicDicQuery.ConfigTypeId != null, t => t.ConfigTypeId == basicDicQuery.ConfigTypeId!) @@ -75,7 +75,7 @@ namespace IRaCIS.Application.Services [HttpGet("{parentId:guid}")] public async Task> GetChildList(Guid parentId) { - return await _repository.GetQueryable().Where(t => t.ParentId == parentId) + return await _dicRepository.Where(t => t.ParentId == parentId) .OrderBy(t => t.ShowOrder).ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); } @@ -89,7 +89,7 @@ namespace IRaCIS.Application.Services public async Task>> GetBasicDataSelect(string[] searchArray) { - var searchList = await _repository.GetQueryable().Where(t => searchArray.Contains(t.Parent.Code) && t.ParentId != null && t.IsEnable).ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); + var searchList = await _dicRepository.Where(t => searchArray.Contains(t.Parent.Code) && t.ParentId != null && t.IsEnable).ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); return searchList.GroupBy(t => t.ParentCode).ToDictionary(g => g.Key, g => g.ToList()); @@ -97,7 +97,7 @@ namespace IRaCIS.Application.Services public async Task> GetBasicDataSelect(string searchKey) { - var searchList = await _repository.GetQueryable().Where(t => t.Parent.Code== searchKey && t.ParentId != null && t.IsEnable).ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); + var searchList = await _dicRepository.Where(t => t.Parent.Code== searchKey && t.ParentId != null && t.IsEnable).ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); return searchList; } diff --git a/IRaCIS.Core.Application/Service/Common/SystemBasicDataService.cs b/IRaCIS.Core.Application/Service/Common/SystemBasicDataService.cs index ea49519b4..305f0c40c 100644 --- a/IRaCIS.Core.Application/Service/Common/SystemBasicDataService.cs +++ b/IRaCIS.Core.Application/Service/Common/SystemBasicDataService.cs @@ -14,6 +14,11 @@ namespace IRaCIS.Core.Application.Services [ApiExplorerSettings(GroupName = "Common")] public class SystemBasicDataService : BaseService, ISystemBasicDataService { + private readonly IRepository _systemBasicDataRepository; + + public SystemBasicDataService(IRepository systemBasicDataRepository) { + this._systemBasicDataRepository = systemBasicDataRepository; + } /// @@ -24,7 +29,7 @@ namespace IRaCIS.Core.Application.Services [HttpPost] public async Task> GetSystemBasicDataList(SystemBasicDataQuery querySystemBasicData) { - var systemBasicDataQueryable = _repository.GetQueryable().Where(t => t.ParentId == null) + var systemBasicDataQueryable = _systemBasicDataRepository.Where(t => t.ParentId == null) .ProjectTo(_mapper.ConfigurationProvider); return await systemBasicDataQueryable.ToPagedListAsync(querySystemBasicData.PageIndex, querySystemBasicData.PageSize, String.IsNullOrEmpty(querySystemBasicData.SortField) ? "Code" : querySystemBasicData.SortField, querySystemBasicData.Asc); @@ -46,7 +51,7 @@ namespace IRaCIS.Core.Application.Services [HttpGet("{parentId:guid}")] public async Task> GetChildList(Guid parentId) { - return await _repository.GetQueryable().Where(t => t.ParentId == parentId&&t.IsEnable).OrderBy(t => t.Code).ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); + return await _systemBasicDataRepository.Where(t => t.ParentId == parentId&&t.IsEnable).OrderBy(t => t.Code).ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); } @@ -78,7 +83,7 @@ namespace IRaCIS.Core.Application.Services public async Task>> GetBasicDataSelect(string[] searchArray) { - var searchList = await _repository.GetQueryable().Where(t => searchArray.Contains(t.Parent.Code) && t.ParentId != null).ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); + var searchList = await _systemBasicDataRepository.Where(t => searchArray.Contains(t.Parent.Code) && t.ParentId != null).ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); return searchList.GroupBy(t => t.ParentCode).ToDictionary(g => g.Key, g => g.ToList()); diff --git a/IRaCIS.Core.Application/Service/Doctor/AttachmentService.cs b/IRaCIS.Core.Application/Service/Doctor/AttachmentService.cs index 43dbb6439..8f01d41fd 100644 --- a/IRaCIS.Core.Application/Service/Doctor/AttachmentService.cs +++ b/IRaCIS.Core.Application/Service/Doctor/AttachmentService.cs @@ -219,7 +219,7 @@ namespace IRaCIS.Application.Services [HttpPost("{doctorId:guid}/{attachmentId:guid}/{language}")] public async Task SetOfficial(Guid doctorId, Guid attachmentId, int language) { - var resumeList = await _repository.GetQueryable().Where(t => t.DoctorId == doctorId && t.Type == "Resume" && t.Language == language).ToListAsync(); + var resumeList = await _attachmentrepository.Where(t => t.DoctorId == doctorId && t.Type == "Resume" && t.Language == language).ToListAsync(); foreach (var item in resumeList) { if (item.Id == attachmentId) item.IsOfficial = true; diff --git a/IRaCIS.Core.Application/Service/Doctor/DoctorService.cs b/IRaCIS.Core.Application/Service/Doctor/DoctorService.cs index 679aecd82..4a6b25c4f 100644 --- a/IRaCIS.Core.Application/Service/Doctor/DoctorService.cs +++ b/IRaCIS.Core.Application/Service/Doctor/DoctorService.cs @@ -75,7 +75,7 @@ namespace IRaCIS.Application.Services return ResponseOutput.NotOk("The current email already existed!", new DoctorBasicInfoCommand()); } - doctor.Code = await _repository.GetQueryable().MaxAsync(t => t.Code) + 1; + doctor.Code = (await _doctorRepository.MaxAsync(t => t.Code)) + 1; doctor.ReviewerCode = AppSettings.CodePrefix + doctor.Code.ToString("D4"); @@ -425,7 +425,7 @@ namespace IRaCIS.Application.Services { var userId = _userInfo.Id; //判断 合作协议、正式简历 是否有。如果没有,显示提示信息,并且不能保存 - var attachmentList = await _repository.GetQueryable().Where(u => u.DoctorId == auditResumeParam.Id) + var attachmentList = await _attachmentRepository.Where(u => u.DoctorId == auditResumeParam.Id) .Select(u => u.Type).ToListAsync(); if (auditResumeParam.ResumeStatus == ResumeStatusEnum.Pass && ((!attachmentList.Contains("Resume")) || (!attachmentList.Contains("Consultant Agreement")))) { diff --git a/IRaCIS.Core.Application/Service/Doctor/EducationService.cs b/IRaCIS.Core.Application/Service/Doctor/EducationService.cs index a9306dff2..e30859fbe 100644 --- a/IRaCIS.Core.Application/Service/Doctor/EducationService.cs +++ b/IRaCIS.Core.Application/Service/Doctor/EducationService.cs @@ -31,7 +31,7 @@ namespace IRaCIS.Application.Services var educationList = await _educationRepository.Where(o => o.DoctorId == doctorId) .OrderBy(t => t.CreateTime).ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); - var postgraduateList = await _repository.GetQueryable().Where(o => o.DoctorId == doctorId) + var postgraduateList = await _postgraduateRepository.Where(o => o.DoctorId == doctorId) .OrderBy(t => t.CreateTime).ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); diff --git a/IRaCIS.Core.Application/Service/Document/TrialDocumentService.cs b/IRaCIS.Core.Application/Service/Document/TrialDocumentService.cs index dc5ad1b8b..8c77260e3 100644 --- a/IRaCIS.Core.Application/Service/Document/TrialDocumentService.cs +++ b/IRaCIS.Core.Application/Service/Document/TrialDocumentService.cs @@ -22,12 +22,15 @@ namespace IRaCIS.Core.Application.Services private readonly IWebHostEnvironment _hostEnvironment; - private readonly IRepository trialDocumentRepository; + private readonly IRepository _trialDocumentRepository; + private readonly IRepository _systemDocConfirmedUserRepository; - public TrialDocumentService(IWebHostEnvironment hostEnvironment, IRepository trialDocumentRepository) + public TrialDocumentService(IWebHostEnvironment hostEnvironment, IRepository trialDocumentRepository + , IRepository systemDocConfirmedUserRepository) { _hostEnvironment = hostEnvironment; - this.trialDocumentRepository = trialDocumentRepository; + this._trialDocumentRepository = trialDocumentRepository; + this._systemDocConfirmedUserRepository = systemDocConfirmedUserRepository; } /// @@ -39,7 +42,7 @@ namespace IRaCIS.Core.Application.Services public async Task> GetTrialDocumentList(TrialDocumentQuery queryTrialDocument) { - var trialDocumentQueryable = trialDocumentRepository.Where(t => t.TrialId == queryTrialDocument.TrialId) + var trialDocumentQueryable = _trialDocumentRepository.Where(t => t.TrialId == queryTrialDocument.TrialId) .WhereIf(!string.IsNullOrEmpty(queryTrialDocument.Name), t => t.Name.Contains(queryTrialDocument.Name)) .WhereIf(!string.IsNullOrEmpty(queryTrialDocument.Type), t => t.Type.Contains(queryTrialDocument.Type)) .ProjectTo(_mapper.ConfigurationProvider, new { token = _userInfo.UserToken }); @@ -152,7 +155,7 @@ namespace IRaCIS.Core.Application.Services }; //项目文档查询 - var trialDocQueryable = from trialDoc in trialDocumentRepository.Where(t => t.TrialId == querySystemDocument.TrialId) + var trialDocQueryable = from trialDoc in _trialDocumentRepository.Where(t => t.TrialId == querySystemDocument.TrialId) .WhereIf(!_userInfo.IsAdmin, t => t.NeedConfirmedUserTypeList.Any(t => t.NeedConfirmUserTypeId == _userInfo.UserTypeId)) .WhereIf(!_userInfo.IsAdmin, t => t.IsAbandon == false || (t.IsAbandon == true && t.TrialDocConfirmedUserList.Any(t => t.ConfirmUserId == _userInfo.Id))) @@ -218,7 +221,7 @@ namespace IRaCIS.Core.Application.Services }; //项目文档查询 - var trialDocQueryable = from trialDoc in trialDocumentRepository.Where(t => t.TrialId == trialId) + var trialDocQueryable = from trialDoc in _trialDocumentRepository.Where(t => t.TrialId == trialId) .WhereIf(!_userInfo.IsAdmin, t => t.NeedConfirmedUserTypeList.Any(t => t.NeedConfirmUserTypeId == _userInfo.UserTypeId)) .WhereIf(!_userInfo.IsAdmin, t => t.IsAbandon == false || (t.IsAbandon == true && t.TrialDocConfirmedUserList.Any(t => t.ConfirmUserId == _userInfo.Id))) @@ -372,7 +375,7 @@ namespace IRaCIS.Core.Application.Services [HttpGet("{trialId:guid}")] public async Task> GetTrialDocAndSystemDocType(Guid trialId) { - return await trialDocumentRepository.Where(t => t.TrialId == trialId).Select(t => t.Type).Union(_repository.GetQueryable().Select(t => t.Type)).Distinct() + return await _trialDocumentRepository.Where(t => t.TrialId == trialId).Select(t => t.Type).Union(_repository.GetQueryable().Select(t => t.Type)).Distinct() .ToListAsync(); } @@ -384,7 +387,7 @@ namespace IRaCIS.Core.Application.Services var entity = _mapper.Map(addOrEditTrialDocument); - if (await trialDocumentRepository.AnyAsync(t => t.Type == addOrEditTrialDocument.Type && t.Name == addOrEditTrialDocument.Name && t.TrialId == addOrEditTrialDocument.TrialId)) + if (await _trialDocumentRepository.AnyAsync(t => t.Type == addOrEditTrialDocument.Type && t.Name == addOrEditTrialDocument.Name && t.TrialId == addOrEditTrialDocument.TrialId)) { return ResponseOutput.NotOk("同类型已存在该文件名"); } @@ -394,12 +397,12 @@ namespace IRaCIS.Core.Application.Services } else { - if (await trialDocumentRepository.AnyAsync(t => t.Type == addOrEditTrialDocument.Type && t.Name == addOrEditTrialDocument.Name && t.Id != addOrEditTrialDocument.Id && t.TrialId == addOrEditTrialDocument.TrialId)) + if (await _trialDocumentRepository.AnyAsync(t => t.Type == addOrEditTrialDocument.Type && t.Name == addOrEditTrialDocument.Name && t.Id != addOrEditTrialDocument.Id && t.TrialId == addOrEditTrialDocument.TrialId)) { return ResponseOutput.NotOk("同类型已存在该文件名"); } - var document = trialDocumentRepository.Where(t => t.Id == addOrEditTrialDocument.Id, true).Include(t => t.NeedConfirmedUserTypeList).FirstOrDefault(); + var document = _trialDocumentRepository.Where(t => t.Id == addOrEditTrialDocument.Id, true).Include(t => t.NeedConfirmedUserTypeList).FirstOrDefault(); if (document == null) return Null404NotFound(document); @@ -442,12 +445,12 @@ namespace IRaCIS.Core.Application.Services [HttpDelete("{trialId:guid}/{trialDocumentId:guid}")] public async Task DeleteTrialDocument(Guid trialDocumentId, Guid trialId) { - if (await trialDocumentRepository.Where(t => t.Id == trialDocumentId).AnyAsync(t => t.TrialDocConfirmedUserList.Any())) + if (await _trialDocumentRepository.Where(t => t.Id == trialDocumentId).AnyAsync(t => t.TrialDocConfirmedUserList.Any())) { return ResponseOutput.NotOk("该文档,已有用户签名 不允许删除"); } - var success = await trialDocumentRepository.DeleteFromQueryAsync(t => t.Id == trialDocumentId); + var success = await _trialDocumentRepository.DeleteFromQueryAsync(t => t.Id == trialDocumentId); return ResponseOutput.Result(success); } @@ -508,7 +511,7 @@ namespace IRaCIS.Core.Application.Services { return ResponseOutput.NotOk("该文档已经签名"); } - if (!await _repository.AnyAsync(t => t.Id == userConfirmCommand.DocumentId) || await trialDocumentRepository.AnyAsync(t => t.Id == userConfirmCommand.DocumentId && t.IsAbandon)) + if (!await _repository.AnyAsync(t => t.Id == userConfirmCommand.DocumentId) || await _trialDocumentRepository.AnyAsync(t => t.Id == userConfirmCommand.DocumentId && t.IsAbandon)) { return ResponseOutput.NotOk("文件已删除或者废除,签署失败!"); } @@ -522,7 +525,7 @@ namespace IRaCIS.Core.Application.Services return ResponseOutput.NotOk("该文档已经签名"); } - if (!await trialDocumentRepository.AnyAsync(t => t.Id == userConfirmCommand.DocumentId) || await _repository.AnyAsync(t => t.Id == userConfirmCommand.DocumentId && t.IsAbandon)) + if (!await _trialDocumentRepository.AnyAsync(t => t.Id == userConfirmCommand.DocumentId) || await _repository.AnyAsync(t => t.Id == userConfirmCommand.DocumentId && t.IsAbandon)) { return ResponseOutput.NotOk("文件已删除或者废除,签署失败!"); } @@ -551,7 +554,7 @@ namespace IRaCIS.Core.Application.Services } else { - await trialDocumentRepository.UpdateFromQueryAsync(t => t.Id == documentId, u => new TrialDocument() { IsAbandon = true }); + await _trialDocumentRepository.UpdateFromQueryAsync(t => t.Id == documentId, u => new TrialDocument() { IsAbandon = true }); } return ResponseOutput.Ok(); } @@ -612,7 +615,7 @@ namespace IRaCIS.Core.Application.Services DocumentUserCount = t.NeedConfirmedUserTypeList.SelectMany(u => u.UserTypeRole.UserList.SelectMany(b => b.UserTrials.Where(r => r.TrialId == querySystemDocument.TrialId))).Count() }); - var trialDocQueryable = trialDocumentRepository.Where(t => t.TrialId == querySystemDocument.TrialId).Select(t => new DocumentUnionWithUserStatView() + var trialDocQueryable = _trialDocumentRepository.Where(t => t.TrialId == querySystemDocument.TrialId).Select(t => new DocumentUnionWithUserStatView() { Id = t.Id, IsSystemDoc = false, diff --git a/IRaCIS.Core.Application/Service/Inspection/InspectionService.cs b/IRaCIS.Core.Application/Service/Inspection/InspectionService.cs index 4e8e280ab..cb6290a75 100644 --- a/IRaCIS.Core.Application/Service/Inspection/InspectionService.cs +++ b/IRaCIS.Core.Application/Service/Inspection/InspectionService.cs @@ -20,7 +20,7 @@ namespace IRaCIS.Core.Application.Service.Inspection { public InspectionService() { - + } public async Task> GetInspectionData(GetDataInspectionDto dto) { @@ -127,39 +127,7 @@ namespace IRaCIS.Core.Application.Service.Inspection .WhereIf(dto.SiteId != null, x => x.SiteId == dto.SiteId); #endregion - #region 测试 - //var query = from data in _repository.GetQueryable() - - // join parent in _repository.GetQueryable() on data.ParentId equals parent.Id into parenttemp - // from leftparent in parenttemp.DefaultIfEmpty() - // join subjectVisit in _repository.GetQueryable() on data.SubjectVisitId equals subjectVisit.Id into subjectVisittemp - - // from leftsubjectVisit in subjectVisittemp.DefaultIfEmpty() - // select new GetDataInspectionOutDto() - // { - // CreateTime = data.CreateTime, - // CreateUserId = data.CreateUserId, - // ModuleType = data.ModuleType, - // BlindName = data.BlindName, - // TrialId = data.TrialId, - // SiteId = data.SiteId, - // SubjectId = data.SubjectId, - // SubjectVisitId = data.SubjectVisitId, - // OptType = data.OptType, - // IP = data.IP, - // Reason = data.Reason, - // IsSign = data.IsSign, - // SignId = data.SignId, - // ParentId = data.ParentId, - // ChildrenType = data.ChildrenType, - // JsonDetail = data.JsonDetail, - // VisitName = leftsubjectVisit.VisitName, - // Id = data.Id, - // ParentJson = leftparent.JsonDetail, - - // }; - #endregion - + dto.Asc = false; return await query.ToPagedListAsync(dto.PageIndex, dto.PageSize, "CreateTime", dto.Asc); diff --git a/IRaCIS.Core.Application/Service/Institution/CROService.cs b/IRaCIS.Core.Application/Service/Institution/CROService.cs index 441d9b419..6a0308efa 100644 --- a/IRaCIS.Core.Application/Service/Institution/CROService.cs +++ b/IRaCIS.Core.Application/Service/Institution/CROService.cs @@ -9,9 +9,12 @@ namespace IRaCIS.Application.Services public class CroService : BaseService, ICroService { private readonly IRepository _croRepository; - public CroService(IRepository croRepository) + private readonly IRepository _trialRepository; + + public CroService(IRepository croRepository, IRepository trialRepository) { _croRepository = croRepository; + this._trialRepository = trialRepository; } /// 分页获取CRO列表 @@ -59,7 +62,7 @@ namespace IRaCIS.Application.Services [HttpDelete("{croCompanyId:guid}")] public async Task DeleteCro(Guid cROCompanyId) { - if (await _repository.GetQueryable().AnyAsync(t => t.CROId == cROCompanyId)) + if (await _trialRepository.AnyAsync(t => t.CROId == cROCompanyId)) { return ResponseOutput.NotOk("This CRO has participated in the trial and couldn't be deleted."); } diff --git a/IRaCIS.Core.Application/Service/Institution/HospitalService.cs b/IRaCIS.Core.Application/Service/Institution/HospitalService.cs index 8dbbfd275..2fead7eeb 100644 --- a/IRaCIS.Core.Application/Service/Institution/HospitalService.cs +++ b/IRaCIS.Core.Application/Service/Institution/HospitalService.cs @@ -9,10 +9,12 @@ namespace IRaCIS.Application.Services public class HospitalService : BaseService, IHospitalService { private readonly IRepository _hospitalRepository; + private readonly IRepository _doctorRepository; - public HospitalService(IRepository hospitalRepository) + public HospitalService(IRepository hospitalRepository, IRepository doctorRepository) { _hospitalRepository = hospitalRepository; + this._doctorRepository = doctorRepository; } /// 获取所有医院列表 @@ -43,7 +45,7 @@ namespace IRaCIS.Application.Services [HttpDelete("{hospitalId:guid}")] public async Task DeleteHospital(Guid hospitalId) { - if (await _repository.GetQueryable().AnyAsync(t => t.Id == hospitalId)) + if (await _doctorRepository.AnyAsync(t => t.Id == hospitalId)) { return ResponseOutput.NotOk("There are already doctors registered in this hospital,and it couldn't be deleted"); } diff --git a/IRaCIS.Core.Application/Service/Institution/SiteService.cs b/IRaCIS.Core.Application/Service/Institution/SiteService.cs index 2003394ff..1a86b1795 100644 --- a/IRaCIS.Core.Application/Service/Institution/SiteService.cs +++ b/IRaCIS.Core.Application/Service/Institution/SiteService.cs @@ -9,10 +9,12 @@ namespace IRaCIS.Application.Services public class SiteService : BaseService, ISiteService { private readonly IRepository _siteRepository; + private readonly IRepository _trialSiteUserRepository; - public SiteService(IRepository siteRepository) + public SiteService(IRepository siteRepository, IRepository trialSiteUserRepository) { _siteRepository = siteRepository; + this._trialSiteUserRepository = trialSiteUserRepository; } /// 分页获取研究中心列表 @@ -62,7 +64,7 @@ namespace IRaCIS.Application.Services public async Task DeleteSite(Guid siteId) { - if (_repository.GetQueryable().Any(t => t.SiteId == siteId)) + if (await _trialSiteUserRepository.AnyAsync(t => t.SiteId == siteId)) { return ResponseOutput.NotOk("This site has participated in the trial and couldn't be deleted."); } diff --git a/IRaCIS.Core.Application/Service/Institution/SponsorService.cs b/IRaCIS.Core.Application/Service/Institution/SponsorService.cs index 44a1010bd..5d27e2ed5 100644 --- a/IRaCIS.Core.Application/Service/Institution/SponsorService.cs +++ b/IRaCIS.Core.Application/Service/Institution/SponsorService.cs @@ -9,10 +9,12 @@ namespace IRaCIS.Application.Services public class SponsorService : BaseService, ISponsorService { private readonly IRepository _sponsorRepository; + private readonly IRepository _trialRepository; - public SponsorService(IRepository sponsorRepository) + public SponsorService(IRepository sponsorRepository, IRepository trialRepository) { _sponsorRepository = sponsorRepository; + this._trialRepository = trialRepository; } /// 分页获取申办方列表 @@ -63,7 +65,7 @@ namespace IRaCIS.Application.Services public async Task DeleteSponsor(Guid sponsorId) { - if (await _repository.GetQueryable().AnyAsync(t => t.CROId == sponsorId)) + if (await _trialRepository.AnyAsync(t => t.CROId == sponsorId)) { return ResponseOutput.NotOk("This sponsor has participated in the trial and couldn't be deleted."); } diff --git a/IRaCIS.Core.Application/Service/Management/MenuService.cs b/IRaCIS.Core.Application/Service/Management/MenuService.cs index 591f61819..c78901377 100644 --- a/IRaCIS.Core.Application/Service/Management/MenuService.cs +++ b/IRaCIS.Core.Application/Service/Management/MenuService.cs @@ -8,10 +8,12 @@ namespace IRaCIS.Application.Services public class MenuService : BaseService, IMenuService { private readonly IRepository menuRepository; + private readonly IRepository _userTypeMenuRepository; - public MenuService(IRepository menuRepository) + public MenuService(IRepository menuRepository, IRepository userTypeMenuRepository) { this.menuRepository = menuRepository; + this._userTypeMenuRepository = userTypeMenuRepository; } /// @@ -165,7 +167,7 @@ namespace IRaCIS.Application.Services public async Task> GetUserMenuTree() { - var menuFunctionlist = await _repository.GetQueryable() + var menuFunctionlist = await _userTypeMenuRepository .Where(t => t.UserTypeId == _userInfo.UserTypeId && (t.Menu.MenuType == "M" || t.Menu.MenuType == "C") && t.Menu.IsEnable) .ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); @@ -184,7 +186,7 @@ namespace IRaCIS.Application.Services public async Task> GetUserPermissions() { - var list = await _repository.GetQueryable() + var list = await _userTypeMenuRepository .Where(t => t.UserTypeId == _userInfo.UserTypeId && t.Menu.MenuType == "F") .Select(t => t.Menu.PermissionStr).ToListAsync(); diff --git a/IRaCIS.Core.Application/Service/QC/QCOperationService.cs b/IRaCIS.Core.Application/Service/QC/QCOperationService.cs index 851d98995..e527c06df 100644 --- a/IRaCIS.Core.Application/Service/QC/QCOperationService.cs +++ b/IRaCIS.Core.Application/Service/QC/QCOperationService.cs @@ -26,13 +26,16 @@ namespace IRaCIS.Core.Application.Image.QA private readonly DicomFileStoreHelper _dicomFileStoreHelper; private readonly IRepository _subjectVisitRepository; - + private readonly IRepository _trialRepository; private object _locker = new object(); - public QCOperationService(DicomFileStoreHelper dicomFileStoreHelper, IRepository subjectVisitRepository) + public QCOperationService(DicomFileStoreHelper dicomFileStoreHelper, IRepository subjectVisitRepository, + IRepository trialRepository + ) { _dicomFileStoreHelper = dicomFileStoreHelper; _subjectVisitRepository = subjectVisitRepository; + this._trialRepository = trialRepository; } #region QC质疑 以及回复 关闭 @@ -989,7 +992,7 @@ namespace IRaCIS.Core.Application.Image.QA #region 处理验证 - var trialConfig = await _repository.GetQueryable() + var trialConfig = await _trialRepository .Select(t => new { TrialId = t.Id, t.QCProcessEnum, t.IsImageConsistencyVerification }) .FirstOrDefaultAsync(t => t.TrialId == trialId) .IfNullThrowException(); @@ -1086,7 +1089,7 @@ namespace IRaCIS.Core.Application.Image.QA [TypeFilter(typeof(TrialResourceFilter))] public async Task CRCRequestToQC(CRCRequestToQCCommand cRCRequestToQCCommand) { - var trialConfig = await _repository.GetQueryable() + var trialConfig = await _trialRepository .Select(t => new { TrialId = t.Id, t.QCProcessEnum, t.IsImageConsistencyVerification, t.IsUrgent, t.IsHaveFirstGiveMedicineDate, t.ClinicalInformationTransmissionEnum }) .FirstOrDefaultAsync(t => t.TrialId == cRCRequestToQCCommand.TrialId); @@ -1218,7 +1221,7 @@ namespace IRaCIS.Core.Application.Image.QA } - var trialConfig = await _repository.GetQueryable() + var trialConfig = await _trialRepository .Select(t => new { TrialId = t.Id, t.QCProcessEnum, t.IsImageConsistencyVerification }) .FirstOrDefaultAsync(t => t.TrialId == trialId) .IfNullThrowException(); @@ -1506,7 +1509,7 @@ namespace IRaCIS.Core.Application.Image.QA return ResponseOutput.NotOk("重传完成 只允许CRC 设置!"); } - var trialConfig = await _repository.GetQueryable() + var trialConfig = await _trialRepository .Select(t => new { TrialId = t.Id, t.QCProcessEnum, t.IsImageConsistencyVerification, t.IsUrgent, t.IsHaveFirstGiveMedicineDate, t.ClinicalInformationTransmissionEnum }) .FirstOrDefaultAsync(t => t.TrialId == cRCReuploadFinishedCommand.TrialId); diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialService.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialService.cs index 6be1715ed..6e414b604 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialService.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialService.cs @@ -17,13 +17,18 @@ namespace IRaCIS.Application.Services private readonly IEasyCachingProvider _provider; private readonly IRepository _trialRepository; + private readonly IRepository _trialUserRepository; + public bool TrialExpeditedChange { get; set; } = false; - public TrialService(IEasyCachingProvider provider,IRepository trialRepository) + public TrialService(IEasyCachingProvider provider,IRepository trialRepository, + IRepository trialUserRepository + ) { _provider = provider; _trialRepository = trialRepository; + this._trialUserRepository = trialUserRepository; } /// @@ -510,7 +515,7 @@ namespace IRaCIS.Application.Services if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ProjectManager) { //参与者仅有他自己时,可以删除 - if (await _repository.GetQueryable().CountAsync(t => t.TrialId == trialId) == 1) + if (await _trialUserRepository.CountAsync(t => t.TrialId == trialId) == 1) { var success1 = await _repository.DeleteFromQueryAsync(o => o.Id == trialId) || diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialSiteService.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialSiteService.cs index 59783aafe..f2da007d1 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialSiteService.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialSiteService.cs @@ -15,11 +15,14 @@ namespace IRaCIS.Core.Application.Services { private readonly IRepository _trialSiteRepository; private readonly IRepository _trialSiteUserRepository; + private readonly IRepository _siteRepository; - public TrialMaintenanceService(IRepository trialSiteRepository, IRepository trialSiteUserRepository) + public TrialMaintenanceService(IRepository trialSiteRepository, IRepository trialSiteUserRepository + , IRepository siteRepository) { _trialSiteRepository = trialSiteRepository; _trialSiteUserRepository = trialSiteUserRepository; + this._siteRepository = siteRepository; } /// Pannel 进去 SiteTab @@ -87,7 +90,7 @@ namespace IRaCIS.Core.Application.Services // 之前选择了的不能再次出现在列表,做的时候我就不建议这样搞,搞好了 现在又要改回去。。。 瞎折腾。。。。 - var siteQueryable = _repository.GetQueryable() + var siteQueryable = _siteRepository .WhereIf(!string.IsNullOrWhiteSpace(trialSiteQuery.SiteName.Trim()), t => t.SiteName.Contains(trialSiteQuery.SiteName.Trim())) .ProjectTo(_mapper.ConfigurationProvider, new { trialId = trialSiteQuery.TrialId }); diff --git a/IRaCIS.Core.Infra.EFCore/Repository/ICommandRepository.cs b/IRaCIS.Core.Infra.EFCore/Repository/ICommandRepository.cs index c8fcb93e7..04a309726 100644 --- a/IRaCIS.Core.Infra.EFCore/Repository/ICommandRepository.cs +++ b/IRaCIS.Core.Infra.EFCore/Repository/ICommandRepository.cs @@ -25,6 +25,9 @@ namespace IRaCIS.Core.Infra.EFCore Task FirstOrDefaultAsync(Expression> exp = null, bool ignoreQueryFilters = false); Task AnyAsync(Expression> exp,bool ignoreQueryFilters=false); + + Task MaxAsync(Expression> selector); + Task CountAsync(Expression> whereLambda = null, bool ignoreQueryFilters = false); ValueTask AddAsync(TEntity entity, bool autoSave = false, CancellationToken cancellationToken = default); diff --git a/IRaCIS.Core.Infra.EFCore/Repository/Repository.cs b/IRaCIS.Core.Infra.EFCore/Repository/Repository.cs index ce5e62d0b..390b37e1c 100644 --- a/IRaCIS.Core.Infra.EFCore/Repository/Repository.cs +++ b/IRaCIS.Core.Infra.EFCore/Repository/Repository.cs @@ -218,6 +218,12 @@ namespace IRaCIS.Core.Infra.EFCore } } + public async Task MaxAsync(Expression> selector) + { + + return await _dbSet.AsNoTracking().MaxAsync(selector); + } + public async Task AnyAsync(Expression> exp, bool ignoreQueryFilters = false) { var query = _dbSet.AsQueryable();