Commit 9bd4130f authored by 黄奎's avatar 黄奎

新增验证

parent ac578bf7
......@@ -16,5 +16,10 @@ namespace Edu.Model.ViewModel.Course
/// 班级编号【查询使用,逗号分隔】
/// </summary>
public string QClassIds { get; set; }
/// <summary>
/// 上课时间【日期+开始时间】
/// </summary>
public string NewPlanDateTime { get; set; }
}
}
\ No newline at end of file
......@@ -110,5 +110,10 @@ namespace Edu.Model.ViewModel.Course
/// 月份
/// </summary>
public string QMonth { get; set; }
/// <summary>
/// 具体开课时间
/// </summary>
public string NewPlanDateTime { get; set; }
}
}
\ No newline at end of file
......@@ -66,11 +66,15 @@ namespace Edu.Module.Course
var list = classRepository.GetClassPageListRepository(pageIndex, pageSize, out rowsCount, query);
if (list != null && list.Count > 0)
{
string ids = string.Join(",", list.Select(qitem => qitem.CouseId));
var classTimeList = new List<RB_Class_Time_ViewModel>();
string ids = string.Join(",", list.Select(qitem => qitem.ClassId));
if (!string.IsNullOrEmpty(ids))
{
classTimeList = class_TimeRepository.GetClassTimeListRepository(ids);
}
foreach (var item in list)
{
{
item.NewPlanDateTime = classTimeList?.Where(qitem => qitem.ClassId == item.ClassId)?.FirstOrDefault()?.NewPlanDateTime;
}
}
return list;
......
......@@ -68,5 +68,30 @@ WHERE t.ClassId =1 GROUP BY t.ClassId,t.StartTime,t.EndTime";
return Get<RB_Class_Time_ViewModel>(sql).ToList();
}
/// <summary>
/// 获取班级上课时间
/// </summary>
/// <param name="classIds"></param>
/// <returns></returns>
public List<RB_Class_Time_ViewModel> GetClassTimeListRepository(string classIds)
{
StringBuilder builder = new StringBuilder();
builder.AppendFormat(@"
SELECT A.ClassId,DATE_FORMAT(MIN(A.NewPlanDateTime),'%Y-%m-%d %h:%i') AS NewPlanDateTime FROM
(
SELECT A.ClassPlanId,A.ClassId,A.ClassDate,A.`Status`,A.ClassRoomId,A.Group_Id,A.School_Id,A.TeacherId,B.ClassTimeId,B.StartTime,B.EndTime
,CONCAT( DATE_FORMAT(A.ClassDate,'%Y-%m-%d') ,' ',B.StartTime,':00') AS NewPlanDateTime
FROM rb_class_plan AS A INNER JOIN rb_class_time AS B ON A.ClassPlanId=B.ClassPlanId
) AS A
WHERE 1=1
");
if (!string.IsNullOrEmpty(classIds))
{
builder.AppendFormat(" AND A.ClassId IN({0}) ", classIds);
}
builder.AppendFormat(" GROUP BY A.ClassId ");
return Get<RB_Class_Time_ViewModel>(builder.ToString()).ToList();
}
}
}
......@@ -67,6 +67,7 @@ namespace Edu.WebApi.Controllers.Course
OpenTime = Common.ConvertHelper.FormatDate(item.OpenTime),
item.CompleteProgress,
ClassStatusStr = item.ClassStatus.ToName(),
item.NewPlanDateTime,
});
}
pageModel.Count = rowsCount;
......@@ -168,11 +169,15 @@ namespace Edu.WebApi.Controllers.Course
string message = "";
if (!Common.ConvertHelper.IsTime(item.StartTime + ":00"))
{
message = "【" + item.StartTime + "】格式不正确!(格式参考 11:30)";
message = "【" + item.StartTime + "】格式不正确!(参考格式为 00:00)";
}
if (!Common.ConvertHelper.IsTime(item.EndTime + ":00"))
{
message += ",【" + item.EndTime + "】格式不正确!(格式参考 08:10)";
if (!string.IsNullOrEmpty(message))
{
message += ",";
}
message += "【" + item.EndTime + "】格式不正确!(参考格式为 00:00)";
}
if (!string.IsNullOrEmpty(message))
{
......@@ -263,6 +268,29 @@ namespace Edu.WebApi.Controllers.Course
{
Common.Plugin.LogHelper.Write(ex, "SetClassPlan_PlanTimeList");
}
if (extModel.PlanTimeList != null && extModel.PlanTimeList.Count > 0)
{
foreach (var item in extModel.PlanTimeList)
{
string message = "";
if (!Common.ConvertHelper.IsTime(item.StartTime + ":00"))
{
message = "【" + item.StartTime + "】格式不正确!(参考格式为 00:00)";
}
if (!Common.ConvertHelper.IsTime(item.EndTime + ":00"))
{
if (!string.IsNullOrEmpty(message))
{
message += ",";
}
message += "【" + item.EndTime + "】格式不正确!(参考格式为 00:00)";
}
if (!string.IsNullOrEmpty(message))
{
return ApiResult.ParamIsNull(message: message);
}
}
}
var flag = classModule.SetClassPlanModule(extModel);
return flag ? ApiResult.Success() : ApiResult.Failed();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment