diff --git a/ds-wms-service/DS.WMS.Core/Code/Interface/ICodeInvoiceService.cs b/ds-wms-service/DS.WMS.Core/Code/Interface/ICodeInvoiceService.cs new file mode 100644 index 00000000..e066b15b --- /dev/null +++ b/ds-wms-service/DS.WMS.Core/Code/Interface/ICodeInvoiceService.cs @@ -0,0 +1,36 @@ +using DS.Module.Core; +using DS.WMS.Core.Code.Entity; + +namespace DS.WMS.Core.Code.Interface +{ + public interface ICodeInvoiceService + { + /// + /// 列表 + /// + /// + /// + Task>> GetListAsync(PageRequest request); + + /// + /// 获取详情 + /// + /// + /// + Task> GetAsync(long id); + + /// + /// 新增/修改 + /// + /// + /// + Task> EditAsync(CodeInvoice ci); + + /// + /// 删除 + /// + /// + /// + Task DeleteAsync(params long[] ids); + } +} diff --git a/ds-wms-service/DS.WMS.Core/Code/Method/CodeInvoiceService.cs b/ds-wms-service/DS.WMS.Core/Code/Method/CodeInvoiceService.cs new file mode 100644 index 00000000..c25db05a --- /dev/null +++ b/ds-wms-service/DS.WMS.Core/Code/Method/CodeInvoiceService.cs @@ -0,0 +1,74 @@ +using DS.Module.Core; +using DS.Module.Core.Extensions; +using DS.WMS.Core.Code.Entity; +using DS.WMS.Core.Code.Interface; + +namespace DS.WMS.Core.Code.Method +{ + public class CodeInvoiceService : ServiceBase, ICodeInvoiceService + { + /// + /// 初始化 + /// + /// + public CodeInvoiceService(IServiceProvider serviceProvider) : base(serviceProvider) + { + } + + /// + /// 列表 + /// + /// + /// + public async Task>> GetListAsync(PageRequest request) + { + //序列化查询条件 + var whereList = request.GetConditionalModels(Db); + var data = TenantDb.Queryable() + .Where(whereList) + .ToQueryPage(request.PageCondition); + return data; + } + + /// + /// 获取详情 + /// + /// + /// + public async Task> GetAsync(long id) + { + var ci = await TenantDb.Queryable().FirstAsync(x => x.Id == id); + return DataResult.Success(ci); + } + + /// + /// 新增/修改 + /// + /// + /// + public async Task> EditAsync(CodeInvoice ci) + { + try + { + await TenantDb.Storageable(ci).DefaultAddElseUpdate().ExecuteCommandAsync(); + return DataResult.Success(ci); + } + catch (Exception ex) + { + await ex.LogAsync(Db); + return DataResult.FailedWithDesc(nameof(MultiLanguageConst.Operation_Failed)); + } + } + + /// + /// 删除 + /// + /// + /// + public async Task DeleteAsync(params long[] ids) + { + int rows = await TenantDb.Deleteable().Where(x => ids.Contains(x.Id)).ExecuteCommandAsync(); + return rows > 0 ? DataResult.Success : DataResult.FailedWithDesc(nameof(MultiLanguageConst.Operation_Failed)); + } + } +} diff --git a/ds-wms-service/DS.WMS.Core/Info/Method/ClientBankService.cs b/ds-wms-service/DS.WMS.Core/Info/Method/ClientBankService.cs index b94e63f7..f6e531f5 100644 --- a/ds-wms-service/DS.WMS.Core/Info/Method/ClientBankService.cs +++ b/ds-wms-service/DS.WMS.Core/Info/Method/ClientBankService.cs @@ -58,8 +58,8 @@ public class ClientBankService : ServiceBase, IClientBankService { if (req.Id == 0) { - if (await TenantDb.Queryable().Where(x => x.CodeName == req.CodeName).AnyAsync()) - return DataResult.Failed("客户银行信息已存在!", MultiLanguageConst.ClientBankExist); + //if (await TenantDb.Queryable().Where(x => x.CodeName == req.CodeName).AnyAsync()) + // return DataResult.Failed("客户银行信息已存在!", MultiLanguageConst.ClientBankExist); var data = req.Adapt(); var entity = await TenantDb.InsertNav(data).Include(x => x.InvoiceHeaders).ExecuteReturnEntityAsync(); diff --git a/ds-wms-service/DS.WMS.MainApi/Controllers/CodeInvoiceController.cs b/ds-wms-service/DS.WMS.MainApi/Controllers/CodeInvoiceController.cs new file mode 100644 index 00000000..b5d2e032 --- /dev/null +++ b/ds-wms-service/DS.WMS.MainApi/Controllers/CodeInvoiceController.cs @@ -0,0 +1,69 @@ +using DS.Module.Core; +using DS.Module.Core.Data; +using DS.WMS.Core.Code.Entity; +using DS.WMS.Core.Code.Interface; +using Microsoft.AspNetCore.Mvc; + +namespace DS.WMS.MainApi.Controllers +{ + /// + /// 发票代码API + /// + public class CodeInvoiceController : ApiController + { + private readonly ICodeInvoiceService _invokeService; + + /// + /// 构造函数 + /// + /// + public CodeInvoiceController(ICodeInvoiceService invokeService) + { + _invokeService = invokeService; + } + + /// + /// 列表 + /// + /// + /// + [HttpPost, Route("GetList")] + public async Task>> GetListAsync([FromBody] PageRequest request) + { + return await _invokeService.GetListAsync(request); + } + + /// + /// 获取详情 + /// + /// 发票代码ID + /// + [HttpGet, Route("Edit")] + public async Task> GetAsync([FromQuery] long id) + { + return await _invokeService.GetAsync(id); + } + + /// + /// 新增/修改 + /// + /// 发票代码 + /// + [HttpPost, Route("Edit")] + public async Task> EditAsync([FromBody] CodeInvoice ci) + { + return await _invokeService.EditAsync(ci); + } + + /// + /// 删除 + /// + /// + /// + [HttpPost, Route("Delete")] + public async Task DeleteAsync([FromBody] IdModel idModel) + { + return await _invokeService.DeleteAsync(idModel.Ids); + } + } +}