调整接口

This commit is contained in:
18942506660
2024-10-21 14:32:22 +08:00
parent 2b56446765
commit 7ee8c65806
5 changed files with 85 additions and 3 deletions

View File

@@ -19,6 +19,8 @@ using WMS.Web.Core.Dto.OutStockTask;
using WMS.Web.Domain.Values.Single;
using WMS.Web.Core;
using NPOI.SS.Formula.Functions;
using WMS.Web.Domain.Mappers;
using WMS.Web.Core.Help;
namespace WMS.Web.Repositories
{
@@ -173,5 +175,50 @@ namespace WMS.Web.Repositories
var (list, count, qty) = await GetListAsync(dto, companyId);
return (list, count);
}
/// <summary>
/// 批量修改
/// </summary>
/// <param name="entitys"></param>
/// <param name="isTransaction"></param>
/// <returns></returns>
public async Task<bool> EditEntityList(List<ProductInventory> entitys, bool isTransaction = true)
{
IDbContextTransaction _transaction = null;
if (isTransaction)
_transaction = _context.Database.BeginTransaction();
try
{
List<int> list = entitys.Select(s => s.Id).ToList();
var res = await _context.ProductInventory
.Where(f => list.Contains(f.Id)).ToListAsync();
_mapper.ToMapList(entitys, res);
await _context.SaveChangesAsync();
if (_transaction != null)
_transaction.Commit();
}
catch (Exception ex)
{
if (_transaction != null)
_transaction.Rollback();
return false;
}
return true;
}
/// <summary>
/// 获取数据
/// </summary>
/// <param name="ids"></param>
/// <returns></returns>
public async Task<List<ProductInventory>> GetEntityList(ProductInventoryType type)
{
var res = await _context.ProductInventory
.Where(f => f.Type==type)
.ToListAsync();
return res.Clone();
}
}
}