From ea3f5b42de4c80380fd4d8a06ca3b0fbf6f4ee60 Mon Sep 17 00:00:00 2001 From: xiaochanghai Date: Fri, 23 May 2025 17:19:32 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Ghre/Ghre_OpenClassController.cs | 4 +-- .../Ghre/Ghre_OpenClassServices.cs | 36 +++++++++++++++++-- .../Ghre/Ghre_StudyRecordServices.cs | 7 ++-- .../Ghre/Ghre_SurveyServices.cs | 3 ++ 4 files changed, 44 insertions(+), 6 deletions(-) diff --git a/Tiobon.Core.Api/Controllers/Ghre/Ghre_OpenClassController.cs b/Tiobon.Core.Api/Controllers/Ghre/Ghre_OpenClassController.cs index 98af6211..798ade37 100644 --- a/Tiobon.Core.Api/Controllers/Ghre/Ghre_OpenClassController.cs +++ b/Tiobon.Core.Api/Controllers/Ghre/Ghre_OpenClassController.cs @@ -151,10 +151,10 @@ public class Ghre_OpenClassController : BaseController CancelOpening(long Id) => await _service.UpdateStatus([Id], "Publish"); + public async Task CancelOpening(long Id) => await _service.UpdateStatus([Id], "Publish", "CancelOpening"); [HttpPost, Route("CancelOpening")] - public async Task CancelOpening([FromBody] List Ids) => await _service.UpdateStatus(Ids, "Publish"); + public async Task CancelOpening([FromBody] List Ids) => await _service.UpdateStatus(Ids, "Publish", "CancelOpening"); #endregion #region 转入已结案 diff --git a/Tiobon.Core.Services/Ghre/Ghre_OpenClassServices.cs b/Tiobon.Core.Services/Ghre/Ghre_OpenClassServices.cs index 5bbbf020..1e6b2cdf 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_OpenClassServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_OpenClassServices.cs @@ -260,6 +260,14 @@ public class Ghre_OpenClassServices : BaseServices x.OpenClassId == body.id); result.result.DT_TableDataT1[0].Attachments = await Db.Queryable().Where(x => x.TableName == body.id.ObjToString() && x.AttachmentGroupID == 1).ToListAsync(); + + result.result.DT_TableDataT1[0].Attachments?.ForEach(x => + { + x.FileURL = "Advanced/" + x.FileURL; + x.PhysicsPath = "Advanced/" + x.PhysicsPath; + x.RelativePath = "Advanced/" + x.RelativePath; + x.ThumbnailPath = "Advanced/" + x.ThumbnailPath; + }); } return result; } @@ -534,6 +542,29 @@ public class Ghre_OpenClassServices : BaseServices ids.Contains(x.Id)); + for (int i = 0; i < list2.Count; i++) + { + var entity = list2[i]; + if (await Db.Queryable() + .Where(it => it.OpenClassId != null && it.OpenClassId == entity.Id && it.BeginTime != null) + .AnyAsync()) + return ServiceResult.OprateFailed($"开班【{entity.OpenClassName}】,已有人考试,暂不可取消开课!"); + + if (message.IsNullOrEmpty() && await Db.Queryable() + .Where(it => it.OpenClassId != null && it.OpenClassId == entity.Id && it.ActualBeginTime != null) + .AnyAsync()) + return ServiceResult.OprateFailed($"开班【{entity.OpenClassName}】,已有人考试,暂不可取消开课!"); + } + + if (message.IsNotEmptyOrNull()) + throw new Exception(); + + break; case "CancelPublished": var list1 = await Query(x => ids.Contains(x.Id)); @@ -543,13 +574,14 @@ public class Ghre_OpenClassServices : BaseServices() .Where(it => it.OpenClassId != null && it.OpenClassId == entity.Id && it.BeginTime != null) .AnyAsync()) - throw new Exception($"开班【{entity.OpenClassName}】,已有人学习,暂不可取消发布!"); + return ServiceResult.OprateFailed($"开班【{entity.OpenClassName}】,已有人学习,暂不可取消发布!"); if (await Db.Queryable() .Where(it => it.OpenClassId != null && it.OpenClassId == entity.Id && it.ActualBeginTime != null) .AnyAsync()) - throw new Exception($"开班【{entity.OpenClassName}】,已有人考试,暂不可取消发布!"); + return ServiceResult.OprateFailed($"开班【{entity.OpenClassName}】,已有人学习,暂不可取消发布!"); + } await Db.Deleteable() .Where(it => it.OpenClassId != null && ids.Contains(it.OpenClassId.Value)) diff --git a/Tiobon.Core.Services/Ghre/Ghre_StudyRecordServices.cs b/Tiobon.Core.Services/Ghre/Ghre_StudyRecordServices.cs index aa555b53..c09ce922 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_StudyRecordServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_StudyRecordServices.cs @@ -186,8 +186,9 @@ public class Ghre_StudyRecordServices : BaseServices().Where(x => x.CourseSceneId != null && courseSceneIds.Contains(x.CourseSceneId)).ToListAsync(); - entitys.ForEach(async entity => + for (int i = 0; i < entitys.Count; i++) { + var entity = entitys[i]; if (!string.IsNullOrWhiteSpace(entity.Indate)) entity.Indate = DateTimeHelper.ConvertToDayString(entity.Indate); entity.ExamDate = DateTimeHelper.ConvertToDayString(entity.ExamDate); @@ -231,7 +232,9 @@ public class Ghre_StudyRecordServices : BaseServices(filter.pageNum, total, filter.pageSize, entitys); } diff --git a/Tiobon.Core.Services/Ghre/Ghre_SurveyServices.cs b/Tiobon.Core.Services/Ghre/Ghre_SurveyServices.cs index fe46e640..206d53f9 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_SurveyServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_SurveyServices.cs @@ -103,6 +103,9 @@ public class Ghre_SurveyServices : BaseServices().Where(x => x.FeedbackId == id || x.ParentFeedbackId == id).AnyAsync()) + throw new Exception($"问卷【{entity.SurveyName}】已被开班引用,暂不可取消发布!"); entity.UpdateIP = ip; entity.UpdateProg = api; entity.Status = status;