// 大名科技(天津)有限公司版权所有 电话:18020030720 QQ:515096995
//
// 此源代码遵循位于源代码树根目录中的 LICENSE 文件的许可证
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);
}
///
/// 获取打印模板
///
///
///
[DisplayName("获取打印模板")]
public async Task GetPrint(string name)
{
return await _sysPrintRep.GetFirstAsync(u => u.Name == name);
}
///
/// 增加打印模板
///
///
///
[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);
}
}