//-------------------------------------------------------------------- // 此代码由T4模板自动生成 byzhouhang 20210918 // 生成时间 2022-03-31 13:18:56 // 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。 //-------------------------------------------------------------------- using IRaCIS.Core.Domain.Models; using Microsoft.AspNetCore.Mvc; using IRaCIS.Core.Application.Interfaces; using IRaCIS.Core.Application.ViewModel; namespace IRaCIS.Core.Application.Service { /// /// 系统模板文档配置表 /// [ApiExplorerSettings(GroupName = "Common")] public class CommonDocumentService : BaseService, ICommonDocumentService { private readonly IRepository _commonDocumentRepository; public CommonDocumentService(IRepository commonDocumentRepository) { _commonDocumentRepository = commonDocumentRepository; } [HttpPost] public async Task> GetCommonDocumentList(CommonDocumentQuery queryCommonDocument) { var commonDocumentQueryable = _commonDocumentRepository.AsQueryable(true) .WhereIf( queryCommonDocument.ModuleTypeId!=null ,t=>t.ModuleTypeId == queryCommonDocument.ModuleTypeId) .WhereIf(queryCommonDocument.FileTypeId != null, t => t.FileTypeId == queryCommonDocument.FileTypeId) .WhereIf( string.IsNullOrEmpty(queryCommonDocument.Code) , t => t.Code.Contains(queryCommonDocument.Code) ) .WhereIf(string.IsNullOrEmpty(queryCommonDocument.Name), t => t.Name.Contains(queryCommonDocument.Name)) .ProjectTo(_mapper.ConfigurationProvider,new { token = _userInfo.UserToken, userId = _userInfo.Id }); return await commonDocumentQueryable.ToPagedListAsync(queryCommonDocument.PageIndex, queryCommonDocument.PageSize, String.IsNullOrEmpty(queryCommonDocument.SortField) ? nameof(CommonDocument.Code) : queryCommonDocument.SortField, queryCommonDocument.Asc); ; } public async Task AddOrUpdateCommonDocument(CommonDocumentAddOrEdit addOrEditCommonDocument) { var verifyExp1 = new EntityVerifyExp() { VerifyExp = t => t.Code == addOrEditCommonDocument.Code, VerifyMsg = "Document Code Can not Repeat." }; var entity = await _commonDocumentRepository.InsertOrUpdateAsync(addOrEditCommonDocument, true, verifyExp1); return ResponseOutput.Ok(entity.Id.ToString()); } } }