啊鑫
2024-10-23 729c87c230c6afcd698ead19732420a3195d58ad
MES.Service/service/BasicData/MesPositionManager.cs
@@ -1,5 +1,4 @@
using Castle.Core.Resource;
using MES.Service.DB;
using 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));
    }
}