fix 修复已知问题
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Dlhis.Entity.Basic.Enums;
|
||||
using Kurisu.AspNetCore.Utils.Extensions;
|
||||
|
||||
namespace Dlhis.Basic.WorkGrids.Request;
|
||||
|
||||
public class WorkGridTimePeriodSaveRequest
|
||||
public class WorkGridTimePeriodSaveRequest : IValidatableObject
|
||||
{
|
||||
public long? Id { get; set; }
|
||||
|
||||
@@ -33,4 +34,22 @@ public class WorkGridTimePeriodSaveRequest
|
||||
/// 结束时间
|
||||
/// </summary>
|
||||
public TimeOnly End { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
||||
{
|
||||
if (Type != WorkGridTimePeriodEnumType.Day)
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
|
||||
var today = DateTime.Today;
|
||||
var start = today.Add(Start.AddMinutes(-Before).ToTimeSpan());
|
||||
var end = today.Add(End.AddMinutes(After).ToTimeSpan());
|
||||
|
||||
if (start.Date != end.Date)
|
||||
{
|
||||
yield return new ValidationResult(WorkGridTimePeriodEnumType.Day.GetDescription() + "禁止跨天", new[] { nameof(Type) });
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user