//-------------------------------------------------------------------- // 此代码由T4模板自动生成 byzhouhang 20210918 // 生成时间 2024-07-30 10:39:09 // 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。 //-------------------------------------------------------------------- using IRaCIS.Core.Domain.Models; using Microsoft.AspNetCore.Mvc; using IRaCIS.Core.Application.Interfaces; using IRaCIS.Core.Application.ViewModel; using Newtonsoft.Json; namespace IRaCIS.Core.Application.Service { /// /// UserFeedBackService /// [ApiExplorerSettings(GroupName = "Management")] public class UserFeedBackService : BaseService, IUserFeedBackService { private readonly IRepository _userFeedBackRepository; public UserFeedBackService(IRepository userFeedBackRepository) { _userFeedBackRepository = userFeedBackRepository; } [HttpPost] public async Task> GetUserFeedBackList(UserFeedBackQuery inQuery) { var userFeedBackQueryable = _userFeedBackRepository .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.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) ) .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; } public async Task AddOrUpdateUserFeedBack(UserFeedBackAddOrEdit addOrEditUserFeedBack) { addOrEditUserFeedBack.ScreenshotListStr = JsonConvert.SerializeObject(addOrEditUserFeedBack.ScreenshotList); var entity = await _userFeedBackRepository.InsertOrUpdateAsync(addOrEditUserFeedBack, true); return ResponseOutput.Ok(entity.Id.ToString()); } /// /// 批量更新状态 /// /// /// [HttpPut] public async Task BatchUpdateFeedBackState(BatchUpdateCommand batchUpdateCommand) { await _userFeedBackRepository.BatchUpdateNoTrackingAsync(t => batchUpdateCommand.IdList.Contains(t.Id), u => new UserFeedBack() { State = batchUpdateCommand.State }); return ResponseOutput.Ok(); } [HttpDelete("{userFeedBackId:guid}")] public async Task DeleteUserFeedBack(Guid userFeedBackId) { var success = await _userFeedBackRepository.DeleteFromQueryAsync(t => t.Id == userFeedBackId, true); return ResponseOutput.Ok(); } } }