优化接口

This commit is contained in:
tongfei
2024-01-03 14:25:04 +08:00
parent 9488b88256
commit 8be6864b3c
5 changed files with 83 additions and 3 deletions

View File

@@ -59,6 +59,18 @@ namespace WMS.Web.Repositories
return entitys;
}
/// <summary>
/// 集合根据boxIDS
/// </summary>
/// <param name="boxIds"></param>
/// <returns></returns>
public async Task<List<InStockTaskBox>> GetListBy(List<int> boxIds)
{
var entitys = await _context.InstockTaskBox
.Include(s => s.Details).Where(x => boxIds.Contains(x.BoxId)).ToListAsync();
return entitys;
}
/// <summary>
/// 集合:根据箱号集合
/// </summary>
@@ -112,5 +124,34 @@ namespace WMS.Web.Repositories
return false;
}
}
/// <summary>
/// 批量删除
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public async Task<bool> DeleteRange(List<int> ids, bool isTransaction = false)
{
IDbContextTransaction _transaction = null;
if (isTransaction)
_transaction = _context.Database.BeginTransaction();
try
{
var list = await _context.InstockTaskBox.Include(x => x.Details)
.Where(f => ids.Contains(f.Id)).ToListAsync();
_context.InstockTaskBox.RemoveRange(list);
await _context.SaveChangesAsync();
if (_transaction != null)
_transaction.Commit();
}
catch (Exception ex)
{
if (_transaction != null)
_transaction.Rollback();
return false;
}
return true;
}
}
}