From b8e0c74d451e52ff48342febb110f45b40026fa1 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Thu, 1 Aug 2024 10:50:11 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=8F=8D=E9=A6=88=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Management/DTO/UserFeedBackViewModel.cs | 10 ++++ .../Service/Management/UserFeedBackService.cs | 60 +++++++++++++++++-- IRaCIS.Core.Domain/Management/UserFeedBack.cs | 6 ++ 3 files changed, 71 insertions(+), 5 deletions(-) diff --git a/IRaCIS.Core.Application/Service/Management/DTO/UserFeedBackViewModel.cs b/IRaCIS.Core.Application/Service/Management/DTO/UserFeedBackViewModel.cs index 5635af438..b3c1098b2 100644 --- a/IRaCIS.Core.Application/Service/Management/DTO/UserFeedBackViewModel.cs +++ b/IRaCIS.Core.Application/Service/Management/DTO/UserFeedBackViewModel.cs @@ -35,6 +35,14 @@ namespace IRaCIS.Core.Application.ViewModel public UserTypeEnum UserTypeEnum { get; set; } } + + public class GetUserFeedBackQuery + { + public Guid? Id { get; set; } + + public Guid? VisitTaskId { get; set; } + } + ///UserFeedBackQuery 列表查询参数模型 public class UserFeedBackQuery : PageInput { @@ -78,6 +86,8 @@ namespace IRaCIS.Core.Application.ViewModel [NotDefault] public Guid TrialId { get; set; } + public Guid? VisitTaskId { get; set; } + public List ScreenshotList { get; set; } [JsonIgnore] diff --git a/IRaCIS.Core.Application/Service/Management/UserFeedBackService.cs b/IRaCIS.Core.Application/Service/Management/UserFeedBackService.cs index e21a818fe..f24fd97c7 100644 --- a/IRaCIS.Core.Application/Service/Management/UserFeedBackService.cs +++ b/IRaCIS.Core.Application/Service/Management/UserFeedBackService.cs @@ -9,6 +9,8 @@ using Microsoft.AspNetCore.Mvc; using IRaCIS.Core.Application.Interfaces; using IRaCIS.Core.Application.ViewModel; using Newtonsoft.Json; +using IRaCIS.Core.Domain.Share; +using IRaCIS.Core.Infrastructure; namespace IRaCIS.Core.Application.Service { /// @@ -29,33 +31,81 @@ namespace IRaCIS.Core.Application.Service public async Task> GetUserFeedBackList(UserFeedBackQuery inQuery) { + var isCRCOrIR = _userInfo.UserTypeEnumInt == (int)UserTypeEnum.ClinicalResearchCoordinator || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.CRA || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.IndependentReviewer; + var userFeedBackQueryable = _userFeedBackRepository + .WhereIf(isCRCOrIR, t => t.CreateUserId == _userInfo.Id) .WhereIf(inQuery.State != null, t => t.State == inQuery.State) .WhereIf(inQuery.QuestionType != null, t => t.QuestionType == inQuery.QuestionType) .WhereIf(inQuery.BeginCreatime != null, t => t.CreateTime >= inQuery.BeginCreatime) - + .WhereIf(inQuery.EndCreatime != null, t => t.CreateTime == inQuery.EndCreatime) .WhereIf(inQuery.UserTypeEnum != null, t => t.CreateUser.UserTypeEnum == inQuery.UserTypeEnum) - .WhereIf(!string.IsNullOrEmpty(inQuery.QuestionDescription), t => t.QuestionDescription.Contains(inQuery.QuestionDescription) ) + .WhereIf(!string.IsNullOrEmpty(inQuery.QuestionDescription), t => t.QuestionDescription.Contains(inQuery.QuestionDescription)) .WhereIf(!string.IsNullOrEmpty(inQuery.TrialKeyInfo), t => t.Trial.ExperimentName.Contains(inQuery.TrialKeyInfo) || t.Trial.TrialCode.Contains(inQuery.TrialKeyInfo)) .WhereIf(!string.IsNullOrEmpty(inQuery.SubejctAndVisitKeyInfo), t => t.Subject.Code.Contains(inQuery.SubejctAndVisitKeyInfo) || t.SubjectVisit.VisitName.Contains(inQuery.SubejctAndVisitKeyInfo)) - .WhereIf(!string.IsNullOrEmpty(inQuery.TrialSiteCode), t => t.TrialSite.TrialSiteCode.Contains(inQuery.TrialSiteCode) ) - + .WhereIf(!string.IsNullOrEmpty(inQuery.TrialSiteCode), t => t.TrialSite.TrialSiteCode.Contains(inQuery.TrialSiteCode)) + .ProjectTo(_mapper.ConfigurationProvider); var pageList = await userFeedBackQueryable - + .ToPagedListAsync(inQuery.PageIndex, inQuery.PageSize, string.IsNullOrWhiteSpace(inQuery.SortField) ? nameof(UserFeedBackView.Id) : inQuery.SortField, inQuery.Asc); return pageList; } + [HttpPost] + public async Task GetUserFeedBackInfo(GetUserFeedBackQuery inQuery) + { + if (inQuery.Id == null && inQuery.VisitTaskId == null) + { + throw new BusinessValidationFailedException("Id 或者VisitTaskId 必传一个"); + } + + var result = _userFeedBackRepository.WhereIf(inQuery.Id == null, t => t.VisitTaskId == inQuery.VisitTaskId) + .WhereIf(inQuery.VisitTaskId == null, t => t.Id == inQuery.Id).ProjectTo(_mapper.ConfigurationProvider).FirstOrDefaultAsync(); + + return ResponseOutput.Ok(result); + } + public async Task AddOrUpdateUserFeedBack(UserFeedBackAddOrEdit addOrEditUserFeedBack) { addOrEditUserFeedBack.ScreenshotListStr = JsonConvert.SerializeObject(addOrEditUserFeedBack.ScreenshotList); + if (addOrEditUserFeedBack.VisitTaskId != null) + { + var info = await _repository.Where(t => t.Id == addOrEditUserFeedBack.VisitTaskId).Select(t => new { t.SubjectId, t.SourceSubjectVisitId, t.Subject.TrialSiteId }).FirstOrDefaultAsync(); + + if (info != null) + { + addOrEditUserFeedBack.SubjectId = info.SubjectId; + addOrEditUserFeedBack.TrialSiteId = info.TrialSiteId; + addOrEditUserFeedBack.SubjectVisitId = info.SourceSubjectVisitId; + } + } + + else if (addOrEditUserFeedBack.SubjectVisitId != null) + { + var info = await _repository.Where(t => t.Id == addOrEditUserFeedBack.SubjectVisitId).Select(t => new { t.TrialSiteId, t.SubjectId }).FirstOrDefaultAsync(); + + if (info != null) + { + addOrEditUserFeedBack.TrialSiteId = info.TrialSiteId; + addOrEditUserFeedBack.SubjectId = info.SubjectId; + } + } + else if (addOrEditUserFeedBack.SubjectId != null) + { + var info = await _repository.Where(t => t.Id == addOrEditUserFeedBack.SubjectId).Select(t => new { t.TrialSiteId }).FirstOrDefaultAsync(); + + if (info != null) + { + addOrEditUserFeedBack.TrialSiteId = info.TrialSiteId; + } + } var entity = await _userFeedBackRepository.InsertOrUpdateAsync(addOrEditUserFeedBack, true); diff --git a/IRaCIS.Core.Domain/Management/UserFeedBack.cs b/IRaCIS.Core.Domain/Management/UserFeedBack.cs index d9ec5f7bb..999a4c04e 100644 --- a/IRaCIS.Core.Domain/Management/UserFeedBack.cs +++ b/IRaCIS.Core.Domain/Management/UserFeedBack.cs @@ -27,6 +27,12 @@ namespace IRaCIS.Core.Domain.Models [JsonIgnore] public User CreateUser { get; set; } + [JsonIgnore] + + public VisitTask VisitTask { get; set; } + + public Guid? VisitTaskId { get; set; } + public Guid? SubjectId { get; set; }