From 6ce95023d506f89b9da2fe1479eecc8558c470f3 Mon Sep 17 00:00:00 2001 From: xiaochanghai Date: Fri, 2 Aug 2024 15:45:04 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E5=85=AC=E5=BC=80=E8=AF=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Extend/CoursePublicSearchField.cs | 4 + .../Ghre/Ghre_CourseServices.cs | 106 ++++++------------ 2 files changed, 37 insertions(+), 73 deletions(-) diff --git a/Tiobon.Core.Model/ViewModels/Extend/CoursePublicSearchField.cs b/Tiobon.Core.Model/ViewModels/Extend/CoursePublicSearchField.cs index 5745392e..cdc4d082 100644 --- a/Tiobon.Core.Model/ViewModels/Extend/CoursePublicSearchField.cs +++ b/Tiobon.Core.Model/ViewModels/Extend/CoursePublicSearchField.cs @@ -38,4 +38,8 @@ public class CoursePublic public string ExamEndDate { get; set; } public bool? DisableBtn { get; set; } public string BtnActionType { get; set; } = "Add"; + + public int AfterHowLong { get; set; } + public string ExamDateString { 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 a6a9ea93..bbdf5165 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_CourseServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_CourseServices.cs @@ -600,30 +600,32 @@ public class Ghre_CourseServices : BaseServices> QueryPublic(QueryBody filter) { RefAsync totalCount = 0; - string sql = @"SELECT A.Id, - A.CoverUrl, - A.UseDefaultCoverImage, - A.DefaultCoverImageName, - A.CourseName, - A.StandardHour, - A.CreditPoints, - CONVERT (VARCHAR (10), ISNULL (A.UpdateTime, A.CreateTime), 120) - CourseBeginTIme, - CONVERT - (VARCHAR (10), - dateadd (month, +3, ISNULL (A.UpdateTime, A.CreateTime)), - 120) - CourseEndTIme, - NULL - ExamDate, - NULL - ExamBeginDate, - NULL - ExamEndDate, - CAST('0' AS BIT) - DisableBtn - FROM Ghre_Course A - WHERE A.IsOPen = 'true' AND A.IsEnable = 1"; + 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, + B.DateType, + B.AfterHowLong + 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}') + OR B.DateType = '{DicExamDateType.AFTER_HOW_LONG}') + WHERE A.IsOPen = 'true' AND A.IsEnable = 1 AND A.Status = '{DIC_COURSE_STATUS.RELEASED}'"; if (string.IsNullOrWhiteSpace(filter.orderBy)) filter.orderBy = "CourseName ASC"; @@ -651,55 +653,6 @@ public class Ghre_CourseServices : BaseServices(value); - // conditions += $" AND (Date BETWEEN '{jsonParam.columnValue[0]}' AND '{jsonParam.columnValue[1]}')"; - - // continue; - //} - //if (name == "CreditPoints") - //{ - // var jsonParam = JsonConvert.DeserializeObject(value); - - // switch (jsonParam.operationKey) - // { - // case "Include": - // sql += $" WHERE {name} LIKE '%{jsonParam.columnValue}%'"; - // break; - // case "NotInclude": - // sql += $" WHERE {name} NOT LIKE '%{jsonParam.columnValue}%'"; - // break; - // case "IsNull": - // sql += $" WHERE {name} IS NULL"; - // break; - // case "NotNull": - // sql += $" WHERE {name} IS NOT NULL"; - // break; - // case "Equal": - // sql += $" WHERE {name} ='{jsonParam.columnValue}'"; - // break; - // case "NotEqual": - // sql += $" WHERE {name} !='{jsonParam.columnValue}'"; - // break; - // case "GreaterOrEqual"://大于等于 - // sql += $" WHERE {name} >='{jsonParam.columnValue}'"; - // break; - // case "Greater"://大于 - // sql += $" WHERE {name} >'{jsonParam.columnValue}'"; - // break; - // case "LessOrEqual"://小于等于 - // sql += $" WHERE {name} <='{jsonParam.columnValue}'"; - // break; - // case "Less"://小于 - // sql += $" WHERE {name} <'{jsonParam.columnValue}'"; - // break; - // default: - // break; - // } - - // continue; - //} if (!string.IsNullOrWhiteSpace(value)) { @@ -741,6 +694,13 @@ public class Ghre_CourseServices : BaseServices + { + if (x.ExamBeginDate != null && x.ExamEndDate != null) + x.ExamDateString = DateTimeHelper.ConvertToDayString(x.ExamBeginDate) + "~" + DateTimeHelper.ConvertToDayString(x.ExamEndDate); + else x.ExamDateString = $"学完{x.AfterHowLong}天"; + }); + return new ServicePageResult(filter.pageNum, totalCount, filter.pageSize, data); } #endregion