| | |
| | | using Castle.Core.Resource; |
| | | using MES.Service.DB; |
| | | using MES.Service.DB; |
| | | using MES.Service.Dto.webApi; |
| | | using MES.Service.Modes; |
| | | using SqlSugar; |
| | |
| | | // 插入或更新岗位的方法 |
| | | private bool InsertOrUpdatePosition(SqlSugarScope db, MesPosition entity) |
| | | { |
| | | var exists = db.Queryable<MesPosition>().Any(e => e.Id == entity.Id); |
| | | if (exists) |
| | | { |
| | | var update = db.Updateable(entity).ExecuteCommand(); |
| | | if (update > 0) |
| | | return true; |
| | | } |
| | | else |
| | | { |
| | | var insert = db.Insertable(entity).ExecuteCommand(); |
| | | if (insert > 0) |
| | | return true; |
| | | } |
| | | |
| | | return false; |
| | | db.Deleteable<MesPosition>() |
| | | .Where(s => s.Id == entity.Id).ExecuteCommand(); |
| | | var insert = db.Insertable(entity).ExecuteCommand(); |
| | | return insert > 0; |
| | | } |
| | | |
| | | // 删除岗位的方法 |
| | | private bool DeletePosition(SqlSugarScope db, decimal positionId) |
| | | { |
| | | var deleteById = db.Deleteable<MesPosition>().In(positionId) |
| | | .ExecuteCommand(); |
| | | var deleteById = db.Deleteable<MesPosition>() |
| | | .Where(s => s.Id == positionId).ExecuteCommand(); |
| | | if (deleteById > 0) |
| | | return true; |
| | | |
| | |
| | | List<MesPosition> positionList) |
| | | { |
| | | var ids = positionList.Select(it => it.Id).ToArray(); |
| | | var deleteByIds = db.Deleteable<MesPosition>().In(ids).ExecuteCommand(); |
| | | |
| | | var deleteByIds = db.Deleteable<MesPosition>() |
| | | .Where(s => ids.Contains(s.Id)).ExecuteCommand(); |
| | | |
| | | if (deleteByIds > 0) |
| | | return true; |
| | | |
| | |
| | | private bool InsertOrUpdatePositionBatch(SqlSugarScope db, |
| | | List<MesPosition> positionList) |
| | | { |
| | | foreach (var entity in positionList) |
| | | if (!InsertOrUpdatePosition(db, entity)) |
| | | return false; |
| | | |
| | | return true; |
| | | return positionList.All(entity => InsertOrUpdatePosition(db, entity)); |
| | | } |
| | | } |