获取公开课

master
xiaochanghai 11 months ago
parent ceab9d19da
commit 6ce95023d5
  1. 4
      Tiobon.Core.Model/ViewModels/Extend/CoursePublicSearchField.cs
  2. 106
      Tiobon.Core.Services/Ghre/Ghre_CourseServices.cs

@ -38,4 +38,8 @@ public class CoursePublic
public string ExamEndDate { get; set; } public string ExamEndDate { get; set; }
public bool? DisableBtn { get; set; } public bool? DisableBtn { get; set; }
public string BtnActionType { get; set; } = "Add"; public string BtnActionType { get; set; } = "Add";
public int AfterHowLong { get; set; }
public string ExamDateString { get; set; }
} }

@ -600,30 +600,32 @@ public class Ghre_CourseServices : BaseServices<Ghre_Course, Ghre_CourseDto, Ins
public async Task<ServicePageResult<CoursePublic>> QueryPublic(QueryBody filter) public async Task<ServicePageResult<CoursePublic>> QueryPublic(QueryBody filter)
{ {
RefAsync<int> totalCount = 0; RefAsync<int> totalCount = 0;
string sql = @"SELECT A.Id, string sql = @$"SELECT A.Id,
A.CoverUrl, A.CoverUrl,
A.UseDefaultCoverImage, A.UseDefaultCoverImage,
A.DefaultCoverImageName, A.DefaultCoverImageName,
A.CourseName, A.CourseName + ' (' + A.CourseNo + ')' CourseName,
A.StandardHour, A.StandardHour,
A.CreditPoints, A.CreditPoints,
CONVERT (VARCHAR (10), ISNULL (A.UpdateTime, A.CreateTime), 120) NULL
CourseBeginTIme, ExamDate,
CONVERT B.BeginTime
(VARCHAR (10), ExamBeginDate,
dateadd (month, +3, ISNULL (A.UpdateTime, A.CreateTime)), B.EndTime
120) ExamEndDate,
CourseEndTIme, CAST ('0' AS BIT)
NULL DisableBtn,
ExamDate, B.DateType,
NULL B.AfterHowLong
ExamBeginDate, FROM Ghre_Course A
NULL LEFT JOIN Ghre_Exam B
ExamEndDate, ON A.Id = B.CourseId
CAST('0' AS BIT) AND B.Status = '{DIC_EXAM_STATUS.RELEASED}'
DisableBtn AND ( ( B.DateType = '{DicExamDateType.EXAM_DATE}'
FROM Ghre_Course A AND B.BeginTime <= '{DateTime.Now.Date}'
WHERE A.IsOPen = 'true' AND A.IsEnable = 1"; 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)) if (string.IsNullOrWhiteSpace(filter.orderBy))
filter.orderBy = "CourseName ASC"; filter.orderBy = "CourseName ASC";
@ -651,55 +653,6 @@ public class Ghre_CourseServices : BaseServices<Ghre_Course, Ghre_CourseDto, Ins
continue; continue;
} }
//if (name == "Date")
//{
// var jsonParam = JsonConvert.DeserializeObject<JsonParam1>(value);
// conditions += $" AND (Date BETWEEN '{jsonParam.columnValue[0]}' AND '{jsonParam.columnValue[1]}')";
// continue;
//}
//if (name == "CreditPoints")
//{
// var jsonParam = JsonConvert.DeserializeObject<JsonParam>(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)) if (!string.IsNullOrWhiteSpace(value))
{ {
@ -741,6 +694,13 @@ public class Ghre_CourseServices : BaseServices<Ghre_Course, Ghre_CourseDto, Ins
.OrderBy(filter.orderBy) .OrderBy(filter.orderBy)
.ToPageListAsync(filter.pageNum, filter.pageSize, totalCount); .ToPageListAsync(filter.pageNum, filter.pageSize, totalCount);
data.ForEach(x =>
{
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<CoursePublic>(filter.pageNum, totalCount, filter.pageSize, data); return new ServicePageResult<CoursePublic>(filter.pageNum, totalCount, filter.pageSize, data);
} }
#endregion #endregion

Loading…
Cancel
Save