diff --git a/Tiobon.Core.Common/DB/Aop/SqlsugarAop.cs b/Tiobon.Core.Common/DB/Aop/SqlsugarAop.cs
index a00cfc53..890b1bce 100644
--- a/Tiobon.Core.Common/DB/Aop/SqlsugarAop.cs
+++ b/Tiobon.Core.Common/DB/Aop/SqlsugarAop.cs
@@ -1,7 +1,9 @@
+using Microsoft.AspNetCore.Http;
using Serilog;
using SqlSugar;
using StackExchange.Profiling;
using Tiobon.Core.Common.LogHelper;
+using Tiobon.Core.Common.UserManager;
using Tiobon.Core.Model;
using Tiobon.Core.Model.Models.RootTkey;
using Tiobon.Core.Model.Tenants;
@@ -113,25 +115,45 @@ public static class SqlSugarAop
break;
case DataFilterType.UpdateByObject:
- var UpdateBy = getType.GetProperty("UpdateBy");
- var dyModifyTime = getType.GetProperty("UpdateTime");
-
- if (App.User?.ID > 0 && UpdateBy != null)
+ if (entityInfo.PropertyName == "UpdateBy")
{
- try
+ var UpdateBy = getType.GetProperty("UpdateBy");
+ if (App.User?.ID > 0 && UpdateBy != null)
{
- UpdateBy.SetValue(entityInfo.EntityValue, Convert.ToInt32(App.User.ID));
+ try
+ {
+ UpdateBy.SetValue(entityInfo.EntityValue, Convert.ToInt32(App.User.ID));
- }
- catch (Exception)
- {
- UpdateBy.SetValue(entityInfo.EntityValue, App.User.ID);
+ }
+ catch (Exception)
+ {
+ UpdateBy.SetValue(entityInfo.EntityValue, App.User.ID);
+ }
}
}
+ else if (entityInfo.PropertyName == "UpdateTime")
+ {
+
+ var dyModifyTime = getType.GetProperty("UpdateTime");
+
+ if (dyModifyTime != null)
+ dyModifyTime.SetValue(entityInfo.EntityValue, DateTime.Now);
+ }
+ //else if (entityInfo.PropertyName == "UpdateTime")
+ //{
+
+ // HttpRequest request = UserContext.Context.Request;
+ // var api = request.Path.ObjToString().TrimEnd('/').ToLower();
+ //}
+ //else if (entityInfo.PropertyName == "UpdateTime")
+ //{
+
+ // var dyModifyTime = getType.GetProperty("UpdateTime");
- if (dyModifyTime != null)
- dyModifyTime.SetValue(entityInfo.EntityValue, DateTime.Now);
+ // if (dyModifyTime != null)
+ // dyModifyTime.SetValue(entityInfo.EntityValue, DateTime.Now);
+ //}
break;
}
}
diff --git a/Tiobon.Core.Services/Ghre/Ghre_StudyRecordServices.cs b/Tiobon.Core.Services/Ghre/Ghre_StudyRecordServices.cs
index cd0596a1..8696a42c 100644
--- a/Tiobon.Core.Services/Ghre/Ghre_StudyRecordServices.cs
+++ b/Tiobon.Core.Services/Ghre/Ghre_StudyRecordServices.cs
@@ -1,5 +1,4 @@
-using MathNet.Numerics.Distributions;
-using MongoDB.Driver.Linq;
+using MongoDB.Driver.Linq;
using NPOI.HSSF.UserModel;
using NPOI.SS.UserModel;
using NPOI.SS.Util;
@@ -1880,5 +1879,41 @@ ORDER BY {filter.orderBy}";
}
- #endregion
+ #endregion
+
+ #region 批量删除
+ ///
+ /// 删除指定ID集合的数据(批量删除)
+ ///
+ /// 主键ID集合
+ ///
+ public override async Task DeleteByIds1(long[] ids)
+ {
+
+ var examRecords = await Db.Queryable()
+ .Where(it => it.StudyRecordId != null && ids.Contains(it.StudyRecordId.Value))
+ .Select(x => new { x.Id, x.StaffId, x.ExamId }).ToListAsync();
+
+ var examIds = examRecords.Select(x => x.ExamId).ToList();
+ var staffIds = examRecords.Select(x => x.StaffId).ToList();
+ var examRecordIds = examRecords.Select(x => x.Id).ToList();
+
+ await Db.Updateable()
+ .SetColumns(it => new Ghre_ExamRecord() { IsEnable = 0 }, true)
+ .Where(it => examRecordIds.Contains(it.Id))
+ .ExecuteCommandAsync();
+
+ await Db.Updateable()
+ .SetColumns(it => new Ghre_ExamStaff() { IsEnable = 0 }, true)
+ .Where(it => staffIds.Contains(it.StaffId) && it.StaffId != null && it.ExamId != null && examIds.Contains(it.ExamId))
+ .ExecuteCommandAsync();
+
+ await Db.Updateable()
+ .SetColumns(it => new Ghre_StudyRecord() { IsEnable = 0 }, true)
+ .Where(it => ids.Contains(it.Id))
+ .ExecuteCommandAsync();
+
+ return true;
+ }
+ #endregion
}
\ No newline at end of file