培训记录被删除后对应的考试管理里面也要删除人员信息,以及考试记录

master
xiaochanghai 3 months ago
parent 6ae681190a
commit 0f49212b80
  1. 46
      Tiobon.Core.Common/DB/Aop/SqlsugarAop.cs
  2. 41
      Tiobon.Core.Services/Ghre/Ghre_StudyRecordServices.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;
}
}

@ -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 批量删除
/// <summary>
/// 删除指定ID集合的数据(批量删除)
/// </summary>
/// <param name="ids">主键ID集合</param>
/// <returns></returns>
public override async Task<bool> DeleteByIds1(long[] ids)
{
var examRecords = await Db.Queryable<Ghre_ExamRecord>()
.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<Ghre_ExamRecord>()
.SetColumns(it => new Ghre_ExamRecord() { IsEnable = 0 }, true)
.Where(it => examRecordIds.Contains(it.Id))
.ExecuteCommandAsync();
await Db.Updateable<Ghre_ExamStaff>()
.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<Ghre_StudyRecord>()
.SetColumns(it => new Ghre_StudyRecord() { IsEnable = 0 }, true)
.Where(it => ids.Contains(it.Id))
.ExecuteCommandAsync();
return true;
}
#endregion
}
Loading…
Cancel
Save