From 001f8b6b2f2b1f6a2f90abdbeea95ead794b7b96 Mon Sep 17 00:00:00 2001 From: xiaochanghai Date: Wed, 15 Jan 2025 15:37:07 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E5=9C=BA=E6=99=AF=E4=B8=8B?= =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E6=96=B0=E5=A2=9E=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/Ghre/Ghre_CourseController.cs | 12 +++++++++ .../Ghre/IGhre_CourseServices.cs | 2 ++ .../Ghre/Ghre_CourseServices.cs | 26 +++++++++++++++++++ 3 files changed, 40 insertions(+) diff --git a/Tiobon.Core.Api/Controllers/Ghre/Ghre_CourseController.cs b/Tiobon.Core.Api/Controllers/Ghre/Ghre_CourseController.cs index 5e248573..672f1b41 100644 --- a/Tiobon.Core.Api/Controllers/Ghre/Ghre_CourseController.cs +++ b/Tiobon.Core.Api/Controllers/Ghre/Ghre_CourseController.cs @@ -80,4 +80,16 @@ public class Ghre_CourseController : BaseController>> QueryBySceneId(long courseSceneId) + { + return await _service.QueryBySceneId(courseSceneId); + } + + [HttpPost, Route("ModifyCourseSortNo")] + public async Task ModifyCourseSortNo([FromBody] List courses) + { + return await _service.ModifyCourseSortNo(courses); + } } \ No newline at end of file diff --git a/Tiobon.Core.IServices/Ghre/IGhre_CourseServices.cs b/Tiobon.Core.IServices/Ghre/IGhre_CourseServices.cs index 63e8c0e6..05dd8516 100644 --- a/Tiobon.Core.IServices/Ghre/IGhre_CourseServices.cs +++ b/Tiobon.Core.IServices/Ghre/IGhre_CourseServices.cs @@ -23,5 +23,7 @@ public interface IGhre_CourseServices : IBaseServices> QueryPublicSearchFields(QueryBody body); Task> QueryPublic(QueryBody filter); + Task>> QueryBySceneId(long courseSceneId); + Task ModifyCourseSortNo(List courses); } \ No newline at end of file diff --git a/Tiobon.Core.Services/Ghre/Ghre_CourseServices.cs b/Tiobon.Core.Services/Ghre/Ghre_CourseServices.cs index 61e050b7..41827db2 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_CourseServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_CourseServices.cs @@ -1130,4 +1130,30 @@ public class Ghre_CourseServices : BaseServices(filter.pageNum, totalCount, filter.pageSize, data); } #endregion + + #region 场景ID获取课程 + public async Task>> QueryBySceneId(long courseSceneId) + { + var entitys = await base.Query(x => x.CourseSceneId == courseSceneId); + var courseWareIds = entitys.Select(x => x.CourseWareId).Distinct().ToList(); + var attachments = await Db.Queryable().Where(x => courseWareIds.Contains(x.CourseWareId)).ToListAsync(); + //var attachments = await _ghre_CourseWareAttachmentServices.Query(x => x.CourseWareId != null && attachmentIds.Contains(x.CourseWareId.Value)); + + var entitys1 = Mapper.Map(entitys).ToANew>(); + entitys1.ForEach(x => + { + x.CourseWareName = string.Join(",", attachments.Where(o => o.CourseWareId == x.CourseWareId).OrderBy(x => x.SortNo).Select(o => o.AttachmentName)); + }); + + return ServiceResult>.OprateSuccess("查询成功", entitys1); + } + #endregion + + #region 修改场景下课程顺序 + public async Task ModifyCourseSortNo(List courses) + { + await Db.Updateable(courses).UpdateColumns(it => new { it.SortNo }).ExecuteCommandAsync(); + return ServiceResult.OprateSuccess("执行成功!"); + } + #endregion } \ No newline at end of file