namespace Admin.NET.Core.Service; /// /// 系统打印模板服务 /// [ApiDescriptionSettings(Order = 305)] public class SysPrintService : IDynamicApiController, ITransient { private readonly SqlSugarRepository _sysPrintRep; public SysPrintService(SqlSugarRepository sysPrintRep) { _sysPrintRep = sysPrintRep; } /// /// 获取打印模板列表 /// /// /// [DisplayName("获取打印模板列表")] public async Task> Page(PagePrintInput input) { return await _sysPrintRep.AsQueryable() .WhereIF(!string.IsNullOrWhiteSpace(input.Name), u => u.Name.Contains(input.Name)) .OrderBy(u => u.OrderNo) .ToPagedListAsync(input.Page, input.PageSize); } /// /// 增加打印模板 /// /// /// [ApiDescriptionSettings(Name = "Add"), HttpPost] [DisplayName("增加打印模板")] public async Task AddPrint(AddPrintInput input) { var isExist = await _sysPrintRep.IsAnyAsync(u => u.Name == input.Name); if (isExist) throw Oops.Oh(ErrorCodeEnum.D1800); await _sysPrintRep.InsertAsync(input.Adapt()); } /// /// 更新打印模板 /// /// /// [ApiDescriptionSettings(Name = "Update"), HttpPost] [DisplayName("更新打印模板")] public async Task UpdatePrint(UpdatePrintInput input) { var isExist = await _sysPrintRep.IsAnyAsync(u => u.Name == input.Name && u.Id != input.Id); if (isExist) throw Oops.Oh(ErrorCodeEnum.D1800); await _sysPrintRep.AsUpdateable(input.Adapt()).IgnoreColumns(true).ExecuteCommandAsync(); } /// /// 删除打印模板 /// /// /// [ApiDescriptionSettings(Name = "Delete"), HttpPost] [DisplayName("删除打印模板")] public async Task DeletePrint(DeletePrintInput input) { await _sysPrintRep.DeleteAsync(u => u.Id == input.Id); } }