diff --git a/Tiobon.Core.Services/CommonServices.cs b/Tiobon.Core.Services/CommonServices.cs index 6394b8e5..1fc6f18e 100644 --- a/Tiobon.Core.Services/CommonServices.cs +++ b/Tiobon.Core.Services/CommonServices.cs @@ -3515,7 +3515,17 @@ public partial class CommonServices : BaseServices>, ICommon string json = param.jsonParam.ToString(); var dict = JsonHelper.JsonToObj(json); var staffId = dict.StaffId; - dict.StaffId = GetStaffId(); + + var staff = await Db.Queryable().FirstAsync(x => x.StaffID == staffId); + if (staff != null) + { + dict.TeacherNo = staff.StaffNo; + dict.TeacherName = staff.StaffName; + } + + if (await Db.Queryable().AnyAsync(x => x.StaffId == staffId)) + throw new Exception($"员工【{staff.StaffName}({staff.StaffNo})】已在讲师列表中!"); + //dict.StaffId = GetStaffId(); id = await Db.Insertable(dict).ExecuteReturnSnowflakeIdAsync(); diff --git a/Tiobon.Core.Services/Ghre/Ghre_TeacherServices.cs b/Tiobon.Core.Services/Ghre/Ghre_TeacherServices.cs index 5ab78016..c8794a1f 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_TeacherServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_TeacherServices.cs @@ -190,6 +190,9 @@ FROM (SELECT A.*, entity.TeacherNo = staff.StaffNo; entity.TeacherName = staff.StaffName; } + + if (await base.AnyAsync(x => x.StaffId == entity.StaffId)) + throw new Exception($"员工【{staff.StaffName}({staff.StaffNo})】已在讲师列表中!"); } else {