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

@ -40,6 +40,8 @@ public class CoursePublic
public string BtnActionType { get; set; } = "Add"; public string BtnActionType { get; set; } = "Add";
public int AfterHowLong { get; set; } public int AfterHowLong { get; set; }
public string ExamDateString { get; set; }
public string ExamDateString { get; set; }
public long? StudyRecordId { get; set; }
} }

@ -599,33 +599,40 @@ public class Ghre_CourseServices : BaseServices<Ghre_Course, Ghre_CourseDto, Ins
#region 获取公开课 #region 获取公开课
public async Task<ServicePageResult<CoursePublic>> QueryPublic(QueryBody filter) public async Task<ServicePageResult<CoursePublic>> QueryPublic(QueryBody filter)
{ {
int? staffId = GetStaffId();
RefAsync<int> totalCount = 0; RefAsync<int> totalCount = 0;
var dt = DateTime.Now.Date;
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.CourseNo + ')' CourseName, A.CourseName + ' (' + A.CourseNo + ')' CourseName,
A.StandardHour, ISNULL (A.StandardHour, 0) StandardHour,
A.CreditPoints, ISNULL (A.CreditPoints, 0) CreditPoints,
NULL NULL ExamDate,
ExamDate, B.BeginTime ExamBeginDate,
B.BeginTime B.EndTime ExamEndDate,
ExamBeginDate, CAST ('0' AS BIT) DisableBtn,
B.EndTime
ExamEndDate,
CAST ('0' AS BIT)
DisableBtn,
B.DateType, B.DateType,
B.AfterHowLong B.AfterHowLong,
C.Id StudyRecordId
FROM Ghre_Course A FROM Ghre_Course A
LEFT JOIN Ghre_Exam B LEFT JOIN Ghre_Exam B
ON A.Id = B.CourseId ON A.Id = B.CourseId
AND B.Status = '{DIC_EXAM_STATUS.RELEASED}' AND B.Status = '{DIC_EXAM_STATUS.RELEASED}'
AND ( ( B.DateType = '{DicExamDateType.EXAM_DATE}' AND ( ( B.DateType = '{DicExamDateType.EXAM_DATE}'
AND B.BeginTime <= '{DateTime.Now.Date}' AND B.BeginTime <= '{dt}'
AND B.EndTime >= '{DateTime.Now.Date}') AND B.EndTime >= '{dt}')
OR B.DateType = '{DicExamDateType.AFTER_HOW_LONG}') 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)) if (string.IsNullOrWhiteSpace(filter.orderBy))
filter.orderBy = "CourseName ASC"; filter.orderBy = "CourseName ASC";
@ -697,8 +704,11 @@ public class Ghre_CourseServices : BaseServices<Ghre_Course, Ghre_CourseDto, Ins
data.ForEach(x => data.ForEach(x =>
{ {
if (x.ExamBeginDate != null && x.ExamEndDate != null) 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}天"; else x.ExamDateString = $"学完{x.AfterHowLong}天";
if (!x.StudyRecordId.IsNull())
x.DisableBtn = true;
}); });
return new ServicePageResult<CoursePublic>(filter.pageNum, totalCount, filter.pageSize, data); return new ServicePageResult<CoursePublic>(filter.pageNum, totalCount, filter.pageSize, data);

Loading…
Cancel
Save