用户反馈增加字段

IRC_NewDev
hang 2024-08-01 10:50:11 +08:00
parent e3ee1a42fb
commit b8e0c74d45
3 changed files with 71 additions and 5 deletions

View File

@ -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; }
}
///<summary>UserFeedBackQuery 列表查询参数模型</summary>
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<string> ScreenshotList { get; set; }
[JsonIgnore]

View File

@ -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
{
/// <summary>
@ -29,33 +31,81 @@ namespace IRaCIS.Core.Application.Service
public async Task<PageOutput<UserFeedBackView>> 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<UserFeedBackView>(_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<IResponseOutput> 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<UserFeedBackView>(_mapper.ConfigurationProvider).FirstOrDefaultAsync();
return ResponseOutput.Ok(result);
}
public async Task<IResponseOutput> AddOrUpdateUserFeedBack(UserFeedBackAddOrEdit addOrEditUserFeedBack)
{
addOrEditUserFeedBack.ScreenshotListStr = JsonConvert.SerializeObject(addOrEditUserFeedBack.ScreenshotList);
if (addOrEditUserFeedBack.VisitTaskId != null)
{
var info = await _repository.Where<VisitTask>(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<SubjectVisit>(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<Subject>(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);

View File

@ -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; }