Commit cc604b4a authored by 黄奎's avatar 黄奎

新增重复验证

parent 0af0c655
......@@ -189,6 +189,16 @@ namespace Edu.Module.Duty
return list;
}
/// <summary>
/// 检查值班计划是否存在
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public bool CheckExistsDutyPlanModule(RB_Duty_Plan_ViewModel query)
{
return duty_PlanRepository.CheckExistsDutyPlanRepository(query);
}
/// <summary>
/// 新增修改值班计划
/// </summary>
......
......@@ -128,5 +128,40 @@ WHERE 1=1 AND A.`Status`=0
builder.AppendFormat(" ORDER BY A.Date ASC ");
return GetPage<RB_Duty_Plan_ViewModel>(pageIndex, pageSize, out rowsCount, builder.ToString()).ToList();
}
/// <summary>
/// 检查值班计划是否存在
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public bool CheckExistsDutyPlanRepository(RB_Duty_Plan_ViewModel query)
{
int result = 0;
StringBuilder builder = new StringBuilder();
builder.Append(@" SELECT COUNT(1) FROM RB_Duty_Plan AS A WHERE 1=1 AND A.Status=0 ");
if (query.Group_Id > 0)
{
builder.AppendFormat(@" AND A.{0}={1} ", nameof(RB_Duty_Plan_ViewModel.Group_Id), query.Group_Id);
}
if (query.School_Id >= 0)
{
builder.AppendFormat(@" AND A.{0}={1} ", nameof(RB_Duty_Plan_ViewModel.School_Id), query.School_Id);
}
if (query.Date != null)
{
builder.AppendFormat(@" AND A.{0}='{1}' ", nameof(RB_Duty_Plan_ViewModel.Date), query.Date);
}
if (query.Id >= 0)
{
builder.AppendFormat(@" AND A.{0}<>{1} ", nameof(RB_Duty_Plan_ViewModel.Id), query.Id);
}
var obj = base.ExecuteScalar(builder.ToString());
if (obj != null)
{
Int32.TryParse(obj.ToString(), out result);
}
return result > 0;
}
}
}
......@@ -199,6 +199,10 @@ namespace Edu.WebApi.Controllers.Duty
model.CreateTime = DateTime.Now;
model.UpdateBy = base.UserInfo.Id;
model.UpdateTime = DateTime.Now;
if (dutyPlanModule.CheckExistsDutyPlanModule(model))
{
return ApiResult.Failed(string.Format("已经存在【{0}】的值班计划!请直接修改!", Common.ConvertHelper.FormatDate(model.Date)));
}
bool flag = dutyPlanModule.SetDutyPlanModule(model, base.UserInfo);
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