From 4806eb026025a1fd1654fbc68e6ab8a9f2072dff Mon Sep 17 00:00:00 2001 From: xiaochanghai Date: Fri, 17 Jan 2025 17:41:39 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=B2=E5=B8=88=E6=8F=90=E4=BA=A4=20?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=98=AF=E5=90=A6=E9=87=8D=E5=A4=8D=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Tiobon.Core.Services/CommonServices.cs | 12 +++++++++++- Tiobon.Core.Services/Ghre/Ghre_TeacherServices.cs | 3 +++ 2 files changed, 14 insertions(+), 1 deletion(-) 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 {