//-------------------------------------------------------------------- // 此代码由liquid模板自动生成 byzhouhang 20240909 // 生成时间 2025-02-21 07:47:30Z // 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。 //-------------------------------------------------------------------- using IRaCIS.Core.Domain.Models; using Microsoft.AspNetCore.Mvc; using IRaCIS.Core.Application.Interfaces; using IRaCIS.Core.Application.ViewModel; using IRaCIS.Core.Infrastructure.Extention; using System.Threading.Tasks; using IRaCIS.Core.Infra.EFCore; namespace IRaCIS.Core.Application.Service; /// /// 项目定稿记录 /// /// /// /// /// [ApiExplorerSettings(GroupName = "FileRecord")] public class TrialFinalRecordService(IRepository _trialFinalRecordRepository, IRepository _trialFileRepository, IMapper _mapper, IUserInfo _userInfo, IStringLocalizer _localizer) : BaseService, ITrialFinalRecordService { [HttpPost] public async Task> GetTrialFinalRecordList(TrialFinalRecordQuery inDto) { var trialFinalRecordQueryable = _trialFinalRecordRepository .Where(x=>x.TrialFileTypeId==inDto.TrialFileTypeId) .WhereIf(inDto.Name.IsNotNullOrEmpty(),x=>x.Name.Contains(inDto.Name)) .WhereIf(inDto.Version.IsNotNullOrEmpty(), x => x.Version.Contains(inDto.Version)) .WhereIf(inDto.IsAuthorizedView!=null, x => x.IsAuthorizedView==inDto.IsAuthorizedView) // .Include(x=>x.PDFFileRecord).Include(x => x.WordFileRecord).Include(x => x.SignFileRecord).Include(x => x.HistoryFileRecord) .ProjectTo(_mapper.ConfigurationProvider); var pageList = await trialFinalRecordQueryable.ToPagedListAsync(inDto); return pageList; } /// /// 新增或者修改文档 /// /// /// public async Task AddOrUpdateTrialFinalRecord(TrialFinalRecordAddOrEdit inDto) { // 在此处拷贝automapper 映射 if (inDto.PDFFileRecord != null) inDto.PDFFileRecord.TrialFileTypeId = inDto.TrialFileTypeId; if (inDto.WordFileRecord != null) inDto.WordFileRecord.TrialFileTypeId = inDto.TrialFileTypeId; if (inDto.SignFileRecord != null) inDto.SignFileRecord.TrialFileTypeId = inDto.TrialFileTypeId; if (inDto.HistoryFileRecord != null) inDto.HistoryFileRecord.TrialFileTypeId = inDto.TrialFileTypeId; var verifyExp = new EntityVerifyExp() { VerifyExp = u => u.Name == inDto.Name, // "当前类型启用的文件类型名称重复" VerifyMsg = _localizer["TrialFileType_NameRepeat"], }; if (inDto.Id != null) { var trialFinalRecord = await _trialFinalRecordRepository.Where(x => x.Id == inDto.Id.Value).FirstNotNullAsync(); List ids= new List() { trialFinalRecord.WordFileRecordId, trialFinalRecord.PDFFileRecordId, trialFinalRecord.SignFileRecordId, trialFinalRecord.HistoryFileRecordId }; var fileIds = ids.Where(x => x != null).Select(x => (Guid)x).ToList(); await _trialFileRepository.BatchDeleteNoTrackingAsync(x => fileIds.Contains(x.Id)); } var entity = await _trialFinalRecordRepository.InsertOrUpdateAsync(inDto, true); return ResponseOutput.Ok(entity.Id.ToString()); } /// /// 授权文档 /// /// /// public async Task AuthorizedTrialFinalRecord(AuthorizedTrialFinalRecordInDto inDto) { await _trialFinalRecordRepository.UpdatePartialFromQueryAsync(t =>inDto.Ids.Contains(t.Id), t => new TrialFinalRecord() { IsAuthorizedView = inDto.IsAuthorizedView }); await _trialFinalRecordRepository.SaveChangesAsync(); return ResponseOutput.Ok(); } /// /// 删除文档 /// /// /// [HttpDelete("{trialFinalRecordId:guid}")] public async Task DeleteTrialFinalRecord(Guid trialFinalRecordId) { var success = await _trialFinalRecordRepository.DeleteFromQueryAsync(t => t.Id == trialFinalRecordId, true); return ResponseOutput.Ok(); } }