| | |
| | | if (UpdateItemStatus(db, entity.Id, "B")) |
| | | return 1; |
| | | break; |
| | | case "2": |
| | | if (InsertItem(db, entity)) |
| | | return 1; |
| | | break; |
| | | case "3": |
| | | if (DeleteItem(db, entity.Id)) |
| | | return 1; |
| | | break; |
| | | case "2": |
| | | case "4": |
| | | if (InsertOrUpdate(db, entity)) |
| | | return 1; |
| | |
| | | if (!UpdateItemStatusBatch(db, itemGroup.Value, "B")) |
| | | throw new NotImplementedException("禁用失败"); |
| | | break; |
| | | case "2": |
| | | if (!InsertItemBatch(db, itemGroup.Value)) |
| | | throw new NotImplementedException("插入失败"); |
| | | break; |
| | | case "3": |
| | | if (!DeleteItemBatch(db, itemGroup.Value)) |
| | | throw new NotImplementedException("删除失败"); |
| | | break; |
| | | case "2": |
| | | case "4": |
| | | if (!InsertOrUpdateBatch(db, itemGroup.Value)) |
| | | throw new NotImplementedException("同步失败"); |
| | |
| | | |
| | | private bool DeleteItem(SqlSugarScope db, decimal itemId) |
| | | { |
| | | var deleteById = db.Deleteable<MesItems>().In(itemId).ExecuteCommand(); |
| | | var deleteById = db.Deleteable<MesItems>() |
| | | .Where(s => s.Id == itemId).ExecuteCommand(); |
| | | if (deleteById > 0) |
| | | return true; |
| | | |
| | |
| | | private bool DeleteItemBatch(SqlSugarScope db, List<MesItems> itemList) |
| | | { |
| | | var ids = itemList.Select(it => it.Id).ToArray(); |
| | | var deleteByIds = db.Deleteable<MesItems>().In(ids).ExecuteCommand(); |
| | | var deleteByIds = db.Deleteable<MesItems>() |
| | | .Where(s => ids.Contains(s.Id)).ExecuteCommand(); |
| | | if (deleteByIds > 0) |
| | | return true; |
| | | |
| | |
| | | |
| | | private bool InsertOrUpdateBatch(SqlSugarScope db, List<MesItems> itemList) |
| | | { |
| | | foreach (var entity in itemList) |
| | | if (!InsertOrUpdate(db, entity)) |
| | | return false; |
| | | |
| | | return true; |
| | | return itemList.All(entity => InsertOrUpdate(db, entity)); |
| | | } |
| | | } |