From 021884c0aa4309f3b2a0c40a6d5300ea9c121eb0 Mon Sep 17 00:00:00 2001 From: xiaochanghai Date: Fri, 2 Aug 2024 16:15: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 --- .../Extend/CoursePublicSearchField.cs | 4 +- .../Ghre/Ghre_CourseServices.cs | 40 ++++++++++++------- 2 files changed, 28 insertions(+), 16 deletions(-) diff --git a/Tiobon.Core.Model/ViewModels/Extend/CoursePublicSearchField.cs b/Tiobon.Core.Model/ViewModels/Extend/CoursePublicSearchField.cs index cdc4d082..8e63d108 100644 --- a/Tiobon.Core.Model/ViewModels/Extend/CoursePublicSearchField.cs +++ b/Tiobon.Core.Model/ViewModels/Extend/CoursePublicSearchField.cs @@ -40,6 +40,8 @@ public class CoursePublic public string BtnActionType { get; set; } = "Add"; public int AfterHowLong { get; set; } - public string ExamDateString { get; set; } + public string ExamDateString { get; set; } + public long? StudyRecordId { get; set; } + } \ 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 bbdf5165..fbcb772e 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_CourseServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_CourseServices.cs @@ -599,33 +599,40 @@ public class Ghre_CourseServices : BaseServices> QueryPublic(QueryBody filter) { + int? staffId = GetStaffId(); RefAsync totalCount = 0; + var dt = DateTime.Now.Date; string sql = @$"SELECT A.Id, A.CoverUrl, A.UseDefaultCoverImage, A.DefaultCoverImageName, A.CourseName + ' (' + A.CourseNo + ')' CourseName, - A.StandardHour, - A.CreditPoints, - NULL - ExamDate, - B.BeginTime - ExamBeginDate, - B.EndTime - ExamEndDate, - CAST ('0' AS BIT) - DisableBtn, + ISNULL (A.StandardHour, 0) StandardHour, + ISNULL (A.CreditPoints, 0) CreditPoints, + NULL ExamDate, + B.BeginTime ExamBeginDate, + B.EndTime ExamEndDate, + CAST ('0' AS BIT) DisableBtn, B.DateType, - B.AfterHowLong + B.AfterHowLong, + C.Id StudyRecordId FROM Ghre_Course A LEFT JOIN Ghre_Exam B ON A.Id = B.CourseId AND B.Status = '{DIC_EXAM_STATUS.RELEASED}' AND ( ( B.DateType = '{DicExamDateType.EXAM_DATE}' - AND B.BeginTime <= '{DateTime.Now.Date}' - AND B.EndTime >= '{DateTime.Now.Date}') + AND B.BeginTime <= '{dt}' + AND B.EndTime >= '{dt}') OR B.DateType = '{DicExamDateType.AFTER_HOW_LONG}') - WHERE A.IsOPen = 'true' AND A.IsEnable = 1 AND A.Status = '{DIC_COURSE_STATUS.RELEASED}'"; + LEFT JOIN Ghre_StudyRecord C + ON A.Id = C.CourseId + AND C.IsEnable = 1 + AND C.StaffId = '{staffId}' + AND C.CourseBeginTime <= '{dt}' + AND C.CourseEndTime >= '{dt}' + WHERE A.IsOPen = 'true' + AND A.IsEnable = 1 + AND A.Status = '{DIC_COURSE_STATUS.RELEASED}'"; if (string.IsNullOrWhiteSpace(filter.orderBy)) filter.orderBy = "CourseName ASC"; @@ -697,8 +704,11 @@ public class Ghre_CourseServices : BaseServices { if (x.ExamBeginDate != null && x.ExamEndDate != null) - x.ExamDateString = DateTimeHelper.ConvertToDayString(x.ExamBeginDate) + "~" + DateTimeHelper.ConvertToDayString(x.ExamEndDate); + x.ExamDateString = DateTimeHelper.ConvertToDayString(x.ExamBeginDate) + " ~ " + DateTimeHelper.ConvertToDayString(x.ExamEndDate); else x.ExamDateString = $"学完{x.AfterHowLong}天"; + + if (!x.StudyRecordId.IsNull()) + x.DisableBtn = true; }); return new ServicePageResult(filter.pageNum, totalCount, filter.pageSize, data);