新增获取公开课接口

master
xiaochanghai 11 months ago
parent b859c0bcd2
commit 6235b62413
  1. 6
      Tiobon.Core.Api/Controllers/Ghre/Ghre_CourseController.cs
  2. 2
      Tiobon.Core.IServices/Ghre/IGhre_CourseServices.cs
  3. 19
      Tiobon.Core.Model/ViewModels/Extend/CoursePublicSearchField.cs
  4. 142
      Tiobon.Core.Services/Ghre/Ghre_CourseServices.cs

@ -73,4 +73,10 @@ public class Ghre_CourseController : BaseController<IGhre_CourseServices, Ghre_C
{
return await _service.QueryPublicSearchFields(body);
}
[HttpPost, Route("QueryPublic")]
public async Task<ServicePageResult<CoursePublic>> QueryPublic([FromBody] QueryBody body)
{
return await _service.QueryPublic(body);
}
}

@ -22,5 +22,7 @@ namespace Tiobon.Core.IServices
Task<ServiceResult<CoursePublicSearch>> QueryPublicSearchFields(QueryBody body);
Task<ServicePageResult<CoursePublic>> QueryPublic(QueryBody filter);
}
}

@ -19,4 +19,23 @@ public class CoursePublicSearchField
public int displayType { get; set; }
public int width { get; set; } = 150;
}
public class CoursePublic
{
public long Id { get; set; }
public string CoverUrl { get; set; }
public string placeholder { get; set; }
public bool? UseDefaultCoverImage { get; set; }
public string DefaultCoverImageName { get; set; }
public string CourseName { get; set; }
public int? StandardHour { get; set; }
public int? CreditPoints { get; set; }
public string CourseBeginTIme { get; set; }
public string CourseEndTIme { get; set; }
public string ExamDate { get; set; }
public string ExamBeginDate { get; set; }
public string ExamEndDate { get; set; }
public string DisableBtn { get; set; }
public string BtnActionType { get; set; } = "Add";
}

@ -473,4 +473,146 @@ public class Ghre_CourseServices : BaseServices<Ghre_Course, Ghre_CourseDto, Ins
return ServiceResult<CoursePublicSearch>.OprateSuccess("", entity);
}
#endregion
#region 获取公开课
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,
'false'
DisableBtn
FROM Ghre_Course A
WHERE A.IsOPen = 'true' AND A.IsEnable = 1";
if (string.IsNullOrWhiteSpace(filter.orderBy))
filter.orderBy = "CourseName ASC";
string conditions = "1=1";
if (filter.jsonParam != null)
foreach (JProperty jProperty in filter.jsonParam.Properties())
{
var name = jProperty.Name;
var value = jProperty.Value.ToString();
if (name == "page" || name == "pageSize")
continue;
//if (name == "Indate")
//{
// var jsonParam = JsonConvert.DeserializeObject<JsonParam1>(value);
// conditions += $" AND (Indate BETWEEN '{jsonParam.columnValue[0]}' AND '{jsonParam.columnValue[1]}')";
// 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))
{
var jsonParam = JsonConvert.DeserializeObject<JsonParam>(value);
switch (jsonParam.operationKey)
{
case "Include":
conditions += $" AND {name} LIKE '%{jsonParam.columnValue}%'";
break;
case "NotInclude":
conditions += $" AND {name} NOT LIKE '%{jsonParam.columnValue}%'";
break;
case "IsNull":
conditions += $" AND {name} IS NULL";
break;
case "NotNull":
conditions += $" AND {name} IS NOT NULL";
break;
case "Equal":
conditions += $" AND {name} ='{jsonParam.columnValue}'";
break;
case "NotEqual":
conditions += $" AND {name} !='{jsonParam.columnValue}'";
break;
default:
break;
}
}
}
//if (ids != null && ids.Any())
// conditions += $" AND Id IN({string.Join(",", ids)})";
sql = string.Format(sql, conditions);
if (filter.pageSize == 0)
filter.pageSize = 10000;
var data = await Db.SqlQueryable<CoursePublic>(sql)
.OrderBy(filter.orderBy)
.ToPageListAsync(filter.pageNum, filter.pageSize, totalCount);
return new ServicePageResult<CoursePublic>(filter.pageNum, totalCount, filter.pageSize, data);
}
#endregion
}
Loading…
Cancel
Save