获取公开课

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 bool? DisableBtn { get; set; }
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)
{
RefAsync<int> 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<Ghre_Course, Ghre_CourseDto, Ins
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))
{
@ -741,6 +694,13 @@ public class Ghre_CourseServices : BaseServices<Ghre_Course, Ghre_CourseDto, Ins
.OrderBy(filter.orderBy)
.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);
}
#endregion

Loading…
Cancel
Save