cjy 1 month ago
commit ea2939dab1

@ -0,0 +1,36 @@
using DS.Module.Core;
using DS.WMS.Core.Code.Entity;
namespace DS.WMS.Core.Code.Interface
{
public interface ICodeInvoiceService
{
/// <summary>
/// 列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
Task<DataResult<List<CodeInvoice>>> GetListAsync(PageRequest request);
/// <summary>
/// 获取详情
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
Task<DataResult<CodeInvoice>> GetAsync(long id);
/// <summary>
/// 新增/修改
/// </summary>
/// <param name="ci"></param>
/// <returns></returns>
Task<DataResult<CodeInvoice>> EditAsync(CodeInvoice ci);
/// <summary>
/// 删除
/// </summary>
/// <param name="ids"></param>
/// <returns></returns>
Task<DataResult> DeleteAsync(params long[] ids);
}
}

@ -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
{
/// <summary>
/// 初始化
/// </summary>
/// <param name="serviceProvider"></param>
public CodeInvoiceService(IServiceProvider serviceProvider) : base(serviceProvider)
{
}
/// <summary>
/// 列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public async Task<DataResult<List<CodeInvoice>>> GetListAsync(PageRequest request)
{
//序列化查询条件
var whereList = request.GetConditionalModels(Db);
var data = TenantDb.Queryable<CodeInvoice>()
.Where(whereList)
.ToQueryPage(request.PageCondition);
return data;
}
/// <summary>
/// 获取详情
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public async Task<DataResult<CodeInvoice>> GetAsync(long id)
{
var ci = await TenantDb.Queryable<CodeInvoice>().FirstAsync(x => x.Id == id);
return DataResult<CodeInvoice>.Success(ci);
}
/// <summary>
/// 新增/修改
/// </summary>
/// <param name="ci"></param>
/// <returns></returns>
public async Task<DataResult<CodeInvoice>> EditAsync(CodeInvoice ci)
{
try
{
await TenantDb.Storageable(ci).DefaultAddElseUpdate().ExecuteCommandAsync();
return DataResult<CodeInvoice>.Success(ci);
}
catch (Exception ex)
{
await ex.LogAsync(Db);
return DataResult<CodeInvoice>.FailedWithDesc(nameof(MultiLanguageConst.Operation_Failed));
}
}
/// <summary>
/// 删除
/// </summary>
/// <param name="ids"></param>
/// <returns></returns>
public async Task<DataResult> DeleteAsync(params long[] ids)
{
int rows = await TenantDb.Deleteable<CodeInvoice>().Where(x => ids.Contains(x.Id)).ExecuteCommandAsync();
return rows > 0 ? DataResult.Success : DataResult.FailedWithDesc(nameof(MultiLanguageConst.Operation_Failed));
}
}
}

@ -58,8 +58,8 @@ public class ClientBankService : ServiceBase, IClientBankService
{
if (req.Id == 0)
{
if (await TenantDb.Queryable<InfoClientBank>().Where(x => x.CodeName == req.CodeName).AnyAsync())
return DataResult.Failed("客户银行信息已存在!", MultiLanguageConst.ClientBankExist);
//if (await TenantDb.Queryable<InfoClientBank>().Where(x => x.CodeName == req.CodeName).AnyAsync())
// return DataResult.Failed("客户银行信息已存在!", MultiLanguageConst.ClientBankExist);
var data = req.Adapt<InfoClientBank>();
var entity = await TenantDb.InsertNav(data).Include(x => x.InvoiceHeaders).ExecuteReturnEntityAsync();

@ -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
{
/// <summary>
/// 发票代码API
/// </summary>
public class CodeInvoiceController : ApiController
{
private readonly ICodeInvoiceService _invokeService;
/// <summary>
/// 构造函数
/// </summary>
/// <param name="invokeService"></param>
public CodeInvoiceController(ICodeInvoiceService invokeService)
{
_invokeService = invokeService;
}
/// <summary>
/// 列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost, Route("GetList")]
public async Task<DataResult<List<CodeInvoice>>> GetListAsync([FromBody] PageRequest request)
{
return await _invokeService.GetListAsync(request);
}
/// <summary>
/// 获取详情
/// </summary>
/// <param name="id">发票代码ID</param>
/// <returns></returns>
[HttpGet, Route("Edit")]
public async Task<DataResult<CodeInvoice>> GetAsync([FromQuery] long id)
{
return await _invokeService.GetAsync(id);
}
/// <summary>
/// 新增/修改
/// </summary>
/// <param name="ci">发票代码</param>
/// <returns></returns>
[HttpPost, Route("Edit")]
public async Task<DataResult<CodeInvoice>> EditAsync([FromBody] CodeInvoice ci)
{
return await _invokeService.EditAsync(ci);
}
/// <summary>
/// 删除
/// </summary>
/// <param name="idModel"></param>
/// <returns></returns>
[HttpPost, Route("Delete")]
public async Task<DataResult> DeleteAsync([FromBody] IdModel idModel)
{
return await _invokeService.DeleteAsync(idModel.Ids);
}
}
}
Loading…
Cancel
Save