diff --git a/Tiobon.Core.Api/Tiobon.Core.Model.xml b/Tiobon.Core.Api/Tiobon.Core.Model.xml
index 486ca850..c40489f9 100644
--- a/Tiobon.Core.Api/Tiobon.Core.Model.xml
+++ b/Tiobon.Core.Api/Tiobon.Core.Model.xml
@@ -12592,6 +12592,46 @@
全局常量
+
+
+ 课程管理-状态
+
+
+
+
+ 草稿箱
+
+
+
+
+ 已发布
+
+
+
+
+ 已停用
+
+
+
+
+ 考试管理-状态
+
+
+
+
+ 草稿箱
+
+
+
+
+ 已发布
+
+
+
+
+ 已停用
+
+
考试管理-状态
diff --git a/Tiobon.Core.Model/Consts.cs b/Tiobon.Core.Model/Consts.cs
index 33601aa0..c0ec4cdb 100644
--- a/Tiobon.Core.Model/Consts.cs
+++ b/Tiobon.Core.Model/Consts.cs
@@ -5,7 +5,54 @@
///
public class Consts
{
- #region 考试管理-日期类型
+
+ #region 课程管理
+ ///
+ /// 课程管理-状态
+ ///
+ public static class DIC_COURSE_STATUS
+ {
+ ///
+ /// 草稿箱
+ ///
+ public const string DRAFT = "Draft";
+ ///
+ /// 已发布
+ ///
+ public const string RELEASED = "Released";
+
+ ///
+ /// 已停用
+ ///
+ public const string DISABLED = "Disabled";
+
+ }
+ #endregion
+
+ #region 考试管理
+ ///
+ /// 考试管理-状态
+ ///
+ public static class DIC_EXAM_PAPER_STATUS
+ {
+ ///
+ /// 草稿箱
+ ///
+ public const string DRAFT = "Draft";
+ ///
+ /// 已发布
+ ///
+ public const string RELEASED = "Released";
+
+ ///
+ /// 已停用
+ ///
+ public const string DISABLED = "Disabled";
+
+ }
+ #endregion
+
+ #region 考试管理
#region 考试管理-状态
///
@@ -78,7 +125,6 @@ public class Consts
#endregion
-
#region 培训记录-课程状态
///
diff --git a/Tiobon.Core.Services/Ghre/Ghre_CourseServices.cs b/Tiobon.Core.Services/Ghre/Ghre_CourseServices.cs
index 6a083e8a..aa163495 100644
--- a/Tiobon.Core.Services/Ghre/Ghre_CourseServices.cs
+++ b/Tiobon.Core.Services/Ghre/Ghre_CourseServices.cs
@@ -14,6 +14,7 @@ using Microsoft.AspNetCore.Http;
using Tiobon.Core.Common.UserManager;
using Tiobon.Core.Common.Helper;
using AgileObjects.AgileMapper;
+using static Tiobon.Core.Model.Consts;
namespace Tiobon.Core.Services;
@@ -266,7 +267,7 @@ public class Ghre_CourseServices : BaseServices UpdateStatus(long[] ids, string status)
{
- if (status != "Released" && status != "Disabled" && status != "Draft")
+ if (status != Consts.DIC_COURSE_STATUS.RELEASED && status != Consts.DIC_COURSE_STATUS.DISABLED && status != Consts.DIC_COURSE_STATUS.DRAFT)
throw new Exception("无效的状态");
HttpRequest request = UserContext.Context.Request;
@@ -281,25 +282,60 @@ public class Ghre_CourseServices : BaseServices().FirstAsync(x => x.LinkId == id && x.LinkType == "CourseId" && x.Status != "Disabled");
+ if (!entity.CourseClassId.IsNull())
+ {
+ var CourseClassIds = JsonConvert.DeserializeObject>(entity.CourseClassId);
+ if (CourseClassIds != null && CourseClassIds.Any())
+ {
+ for (int i = 0; i < CourseClassIds.Count; i++)
+ {
+ if (!await Db.Queryable().AnyAsync(x => x.Id == CourseClassIds[i]))
+ throw new Exception($"课程关联的课程分类已失效,请修正数据后继续发布!");
+ }
+ }
+ }
+
+ if (!entity.CourseSceneId.IsNull())
+ if (!await Db.Queryable().AnyAsync(x => x.Id == entity.CourseSceneId))
+ return ServiceResult.OprateFailed($"课程关联的课程场景已失效,请修正数据后继续发布!");
+
+ if (!entity.ExamPaperId.IsNull())
+ {
+ var ExamPaperIds = JsonConvert.DeserializeObject>(entity.ExamPaperId);
+ if (ExamPaperIds != null && ExamPaperIds.Any())
+ {
+ for (int i = 0; i < ExamPaperIds.Count; i++)
+ {
+ if (!await Db.Queryable().AnyAsync(x => x.Id == ExamPaperIds[0] && x.Status == DIC_EXAM_PAPER_STATUS.RELEASED))
+ return ServiceResult.OprateFailed($"课程关联的试卷已失效,请修正数据后继续发布!");
+ }
+ }
+ }
+ }
+ #endregion
+
+ if (entity.Status == Consts.DIC_COURSE_STATUS.RELEASED)
+ {
+ var examPaper = await Db.Queryable().FirstAsync(x => x.LinkId == id && x.LinkType == "CourseId" && x.Status != Consts.DIC_COURSE_STATUS.DISABLED);
if (examPaper != null)
- return ServiceResult.OprateFailed($"课程【{entity.CourseName}({entity.CourseNo})】已与试卷【{examPaper.PaperName}({examPaper.PaperName})】关联,暂不可{(status == "Draft" ? "取消发布" : "停用")}");
+ return ServiceResult.OprateFailed($"课程【{entity.CourseName}({entity.CourseNo})】已与试卷【{examPaper.PaperName}({examPaper.PaperName})】关联,暂不可{(status == Consts.DIC_COURSE_STATUS.DRAFT ? "取消发布" : "停用")}");
}
BasePoco ent = entity;
ent.UpdateIP = ip;
ent.UpdateProg = api;
- if (status == "Released" || status == "Disabled" || status == "Draft")
+ if (status == Consts.DIC_COURSE_STATUS.RELEASED || status == Consts.DIC_COURSE_STATUS.DISABLED || status == Consts.DIC_COURSE_STATUS.DRAFT)
{
entity.Status = status;
entities.Add(entity);
}
#region 生成课程快照
- if (status == "Released")
+ if (status == Consts.DIC_COURSE_STATUS.RELEASED)
{
var sql = $"UPDATE Ghre_CourseSnap SET IsEnable = 0 WHERE CourseId = '{id}' AND IsEnable = 1";
await Db.Ado.ExecuteCommandAsync(sql);
@@ -315,9 +351,9 @@ public class Ghre_CourseServices : BaseServices>(editModel.CourseClassId);
+ if (CourseClassIds != null && CourseClassIds.Any())
+ {
+ for (int i = 0; i < CourseClassIds.Count; i++)
+ {
+ if (!await Db.Queryable().AnyAsync(x => x.Id == CourseClassIds[i]))
+ throw new Exception($"课程关联的课程分类已失效,请修正数据后继续发布!");
+ }
+ }
+ }
+
+ if (!editModel.CourseSceneId.IsNull())
+ if (!await Db.Queryable().AnyAsync(x => x.Id == editModel.CourseSceneId))
+ throw new Exception($"课程关联的课程场景已失效,请修正数据后继续发布!");
+
+ if (!editModel.ExamPaperId.IsNull())
+ {
+ var ExamPaperIds = JsonConvert.DeserializeObject>(editModel.ExamPaperId);
+ if (ExamPaperIds != null && ExamPaperIds.Any())
+ {
+ for (int i = 0; i < ExamPaperIds.Count; i++)
+ {
+ if (!await Db.Queryable().AnyAsync(x => x.Id == ExamPaperIds[i] && x.Status == DIC_EXAM_PAPER_STATUS.RELEASED))
+ throw new Exception($"课程关联的试卷已失效,请修正数据后继续发布!");
+ }
+ }
+ }
+
return await base.Update(Id, editModel);
}
@@ -370,7 +438,7 @@ public class Ghre_CourseServices : BaseServices
+
+
+ 课程管理-状态
+
+
+
+
+ 草稿箱
+
+
+
+
+ 已发布
+
+
+
+
+ 已停用
+
+
+
+
+ 考试管理-状态
+
+
+
+
+ 草稿箱
+
+
+
+
+ 已发布
+
+
+
+
+ 已停用
+
+
考试管理-状态