fix 处理时段星期优化

This commit is contained in:
2024-07-19 17:17:32 +08:00
parent a48e34f999
commit fac83c0922
5 changed files with 69 additions and 19 deletions

View File

@@ -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) });
}
}
}