From 729c87c230c6afcd698ead19732420a3195d58ad Mon Sep 17 00:00:00 2001 From: 啊鑫 <t2856754968@163.com> Date: 星期三, 23 十月 2024 10:43:04 +0800 Subject: [PATCH] 接口调整 --- MES.Service/service/BasicData/MesPositionManager.cs | 37 ++++++++++++------------------------- 1 files changed, 12 insertions(+), 25 deletions(-) diff --git a/MES.Service/service/BasicData/MesPositionManager.cs b/MES.Service/service/BasicData/MesPositionManager.cs index 5cd83e4..f648dca 100644 --- a/MES.Service/service/BasicData/MesPositionManager.cs +++ b/MES.Service/service/BasicData/MesPositionManager.cs @@ -1,5 +1,4 @@ -锘縰sing Castle.Core.Resource; -using MES.Service.DB; +锘縰sing MES.Service.DB; using MES.Service.Dto.webApi; using MES.Service.Modes; using SqlSugar; @@ -64,28 +63,17 @@ // 鎻掑叆鎴栨洿鏂板矖浣嶇殑鏂规硶 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; @@ -200,7 +188,10 @@ 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; @@ -211,10 +202,6 @@ 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)); } } \ No newline at end of file -- Gitblit v1.9.3