SetpointsRequestDto добавил атрибут валидации времени устаревания от 10мин до 4часов

This commit is contained in:
ngfrolov 2024-02-16 11:24:03 +05:00
parent eddac473c8
commit aa002488fe
Signed by untrusted user who does not match committer: ng.frolov
GPG Key ID: E99907A0357B29A7
2 changed files with 2 additions and 8 deletions

View File

@ -39,7 +39,8 @@ namespace AsbCloudApp.Data.SAUB
/// время в секундах актуальности этого запроса /// время в секундах актуальности этого запроса
/// </summary> /// </summary>
[Required] [Required]
public int ObsolescenceSec { get; set; } [Range(10 * 60, 4 * 60 * 60)]
public int ObsolescenceSec { get; set; } = 10 * 60;
/// <summary> /// <summary>
/// набор уставок: {"название переменной панели"; "рекомендуемое значение"} /// набор уставок: {"название переменной панели"; "рекомендуемое значение"}

View File

@ -18,8 +18,6 @@ namespace AsbCloudWebApi.Controllers.SAUB
{ {
private readonly ISetpointsService setpointsService; private readonly ISetpointsService setpointsService;
private readonly IWellService wellService; private readonly IWellService wellService;
private const int ObsolescenceSecMin = 30;
private const int ObsolescenceSecMax = 6 * 60 * 60;
public SetpointsController(ISetpointsService setpointsService, IWellService wellService) public SetpointsController(ISetpointsService setpointsService, IWellService wellService)
{ {
@ -68,11 +66,6 @@ namespace AsbCloudWebApi.Controllers.SAUB
setpoints.IdWell = idWell; setpoints.IdWell = idWell;
setpoints.IdState = 1; setpoints.IdState = 1;
if (setpoints is null
|| setpoints.ObsolescenceSec > ObsolescenceSecMax
|| setpoints.ObsolescenceSec < ObsolescenceSecMin)
return this.ValidationBadRequest(nameof(setpoints.ObsolescenceSec), "Wrong ObsolescenceSec");
if (!setpoints.Setpoints.Any()) if (!setpoints.Setpoints.Any())
return this.ValidationBadRequest(nameof(setpoints.Setpoints), "Wrong setpoints count"); return this.ValidationBadRequest(nameof(setpoints.Setpoints), "Wrong setpoints count");