From c1e41adc6790f5898705abc2eee13a4912e3174f Mon Sep 17 00:00:00 2001 From: xiaochanghai Date: Wed, 15 Jan 2025 18:34:48 +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_CourseWare.Dto.InsertInput.cs | 1 + Tiobon.Core.Services/CommonServices.cs | 2 +- .../Ghre/Ghre_CourseWareServices.cs | 33 +++++++++++-------- .../Ghre/Ghre_QuestionServices.cs | 4 +-- .../Ghre/Ghre_StudyRecordServices.cs | 7 ++-- 5 files changed, 29 insertions(+), 18 deletions(-) diff --git a/Tiobon.Core.Model/Insert/Ghre/Ghre_CourseWare.Dto.InsertInput.cs b/Tiobon.Core.Model/Insert/Ghre/Ghre_CourseWare.Dto.InsertInput.cs index f2e1e017..c0275078 100644 --- a/Tiobon.Core.Model/Insert/Ghre/Ghre_CourseWare.Dto.InsertInput.cs +++ b/Tiobon.Core.Model/Insert/Ghre/Ghre_CourseWare.Dto.InsertInput.cs @@ -32,6 +32,7 @@ public class InsertGhre_CourseWareInput : Ghre_CourseWareBase } public class Ghre_CourseWareLink { + public long Id { get; set; } public string LinkName { get; set; } public string LinkAddress { get; set; } } \ No newline at end of file diff --git a/Tiobon.Core.Services/CommonServices.cs b/Tiobon.Core.Services/CommonServices.cs index 8cb5f9e9..6394b8e5 100644 --- a/Tiobon.Core.Services/CommonServices.cs +++ b/Tiobon.Core.Services/CommonServices.cs @@ -1059,7 +1059,7 @@ public partial class CommonServices : BaseServices>, ICommon fnKey = "TBD4YN", fnTitle = "课程顺序", fnType = "row", - icon = "ghr-publish", + icon = "ghr-drag", position = "left" }); break; diff --git a/Tiobon.Core.Services/Ghre/Ghre_CourseWareServices.cs b/Tiobon.Core.Services/Ghre/Ghre_CourseWareServices.cs index ad975deb..7c375dc7 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_CourseWareServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_CourseWareServices.cs @@ -74,23 +74,30 @@ public class Ghre_CourseWareServices : BaseServices x.CourseWareId == Id); - editModel.Attachments.ForEach(x => + + if (editModel.Source == "Attachments") { - x.CourseWareId = Id; - x.RelativePath = x.RelativePath.Replace("/Advanced", null); - }); - await _ghre_CourseWareAttachmentServices.Add(editModel.Attachments); - if (editModel.Links != null && editModel.Links.Any()) + editModel.Attachments.ForEach(x => + { + x.CourseWareId = Id; + x.RelativePath = x.RelativePath.Replace("/Advanced", null); + }); + await _ghre_CourseWareAttachmentServices.Add(editModel.Attachments); + } + else { - var attachments = editModel.Links.Select(x => new InsertGhre_CourseWareAttachmentInput() + if (editModel.Links != null && editModel.Links.Any()) { - CourseWareId = Id, - AttachmentName = x.LinkName, - RelativePath = x.LinkAddress, - AttachFileExtension = "http" - }).ToList(); - await _ghre_CourseWareAttachmentServices.Add(attachments); + var attachments = editModel.Links.Select(x => new InsertGhre_CourseWareAttachmentInput() + { + CourseWareId = Id, + AttachmentName = x.LinkName, + RelativePath = x.LinkAddress, + AttachFileExtension = "http" + }).ToList(); + await _ghre_CourseWareAttachmentServices.Add(attachments); + } } return await base.Update(Id, editModel); } diff --git a/Tiobon.Core.Services/Ghre/Ghre_QuestionServices.cs b/Tiobon.Core.Services/Ghre/Ghre_QuestionServices.cs index e571e06e..d57f07cd 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_QuestionServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_QuestionServices.cs @@ -1,4 +1,5 @@ -using NPOI.HSSF.UserModel; +using Microsoft.IdentityModel.Tokens; +using NPOI.HSSF.UserModel; using NPOI.SS.UserModel; using NPOI.SS.Util; using NPOI.XSSF.UserModel; @@ -1010,7 +1011,6 @@ public class Ghre_QuestionServices : BaseServices x.RelativePath = "/Advanced" + x.RelativePath); - course.CourseWareList[j].Links = attachments.Where(x => x.AttachFileExtension == "http") + course.CourseWareList[j].Links = attachments + .Where(x => x.AttachFileExtension == "http") + .OrderBy(x => x.SortNo) .Select(x => new Ghre_CourseWareLink() { + Id = x.Id, LinkName = x.AttachmentName, LinkAddress = x.RelativePath, }).ToList(); @@ -1251,7 +1254,7 @@ WHERE A.Id = '{id}'"; if (course.CourseStandardDuration.IsNull()) { - sql = $@"SELECT ISNULL (A.Hours, 0) * 60 + A.Minutes Minutes + sql = $@"SELECT SUM (ISNULL (A.Hours, 0) * 60 + A.Minutes) Minutes FROM Ghre_CourseWare A WHERE A.Id IN (SELECT CourseWareId