fix 处理时段星期优化
This commit is contained in:
@@ -1,10 +1,9 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Dlhis.Entity.Device.Enums;
|
||||
using Dlhis.Entity.Device.Models;
|
||||
|
||||
namespace Dlhis.Basic.Device.Request;
|
||||
|
||||
public class DeviceTimePeriodSaveRequest
|
||||
public class DeviceTimePeriodSaveRequest : IValidatableObject
|
||||
{
|
||||
public long? Id { get; set; }
|
||||
|
||||
@@ -31,5 +30,14 @@ public class DeviceTimePeriodSaveRequest
|
||||
/// </summary>
|
||||
[MinLength(7, ErrorMessage = "配置有误")]
|
||||
[MaxLength(7, ErrorMessage = "配置有误")]
|
||||
public List<DeviceWeekDayTimePeriod> Sections { get; set; }
|
||||
public List<DeviceTimePeriodSectionRequest> Sections { get; set; }
|
||||
|
||||
|
||||
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
||||
{
|
||||
if (Sections.DistinctBy(x => x.DayOfWeek).Count() != Sections.Count)
|
||||
{
|
||||
yield return new ValidationResult("星期配置重复", new[] { nameof(Sections) });
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user