feat(api): Изменена валидация JobRequest, фильтры аттрибутов могут быть пустыми
This commit is contained in:
@@ -33,10 +33,7 @@ namespace PARR.API.Controllers.V1
|
|||||||
private readonly IUriService uriService;
|
private readonly IUriService uriService;
|
||||||
private readonly IJobService jobService;
|
private readonly IJobService jobService;
|
||||||
private readonly ITemplateService templateService;
|
private readonly ITemplateService templateService;
|
||||||
private readonly IJobGroupService jobGroupService;
|
|
||||||
private readonly IValidator<JobRequest> jobValidator;
|
private readonly IValidator<JobRequest> jobValidator;
|
||||||
private readonly IUnitFilterService unitFilterService;
|
|
||||||
private readonly IUnitService unitService;
|
|
||||||
|
|
||||||
public JobController(
|
public JobController(
|
||||||
ILogger<JobController> logger,
|
ILogger<JobController> logger,
|
||||||
@@ -55,10 +52,7 @@ namespace PARR.API.Controllers.V1
|
|||||||
this.uriService = uriService;
|
this.uriService = uriService;
|
||||||
this.jobService = jobService;
|
this.jobService = jobService;
|
||||||
this.templateService = templateService;
|
this.templateService = templateService;
|
||||||
this.jobGroupService = jobGroupService;
|
|
||||||
this.jobValidator = jobValidator;
|
this.jobValidator = jobValidator;
|
||||||
this.unitFilterService = unitFilterService;
|
|
||||||
this.unitService = unitService;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -88,10 +82,10 @@ namespace PARR.API.Controllers.V1
|
|||||||
|
|
||||||
query = query
|
query = query
|
||||||
.Include(t => t.UnitFilters)
|
.Include(t => t.UnitFilters)
|
||||||
.ThenInclude(t => t.FieldFilters.OrderBy(o => o.UnitField!.AihitName))
|
.ThenInclude(t => t.FieldFilters)
|
||||||
.ThenInclude(t => t.UnitField)
|
.ThenInclude(t => t.UnitField)
|
||||||
.Include(t => t.UnitFilters)
|
.Include(t => t.UnitFilters)
|
||||||
.ThenInclude(t => t.RelationshipFilters.OrderBy(o => o.UnitField!.AihitName))
|
.ThenInclude(t => t.RelationshipFilters)
|
||||||
.ThenInclude(t => t.UnitField);
|
.ThenInclude(t => t.UnitField);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -186,10 +180,10 @@ namespace PARR.API.Controllers.V1
|
|||||||
.Include(t => t.Tnk)
|
.Include(t => t.Tnk)
|
||||||
.Include(t => t.Group)
|
.Include(t => t.Group)
|
||||||
.Include(t => t.UnitFilters)
|
.Include(t => t.UnitFilters)
|
||||||
.ThenInclude(t => t.FieldFilters.OrderBy(o => o.UnitField!.AihitName))
|
.ThenInclude(t => t.FieldFilters)
|
||||||
.ThenInclude(t => t.UnitField)
|
.ThenInclude(t => t.UnitField)
|
||||||
.Include(t => t.UnitFilters)
|
.Include(t => t.UnitFilters)
|
||||||
.ThenInclude(t => t.RelationshipFilters.OrderBy(o => o.UnitField!.AihitName))
|
.ThenInclude(t => t.RelationshipFilters)
|
||||||
.FirstOrDefaultAsync(t => t.Id == job.Id);
|
.FirstOrDefaultAsync(t => t.Id == job.Id);
|
||||||
|
|
||||||
var locationUri = uriService.GetUri(ApiRoutes.Job.Get, ApiRoutes.Job.getParam, createdJob!.Id);
|
var locationUri = uriService.GetUri(ApiRoutes.Job.Get, ApiRoutes.Job.getParam, createdJob!.Id);
|
||||||
|
|||||||
@@ -62,17 +62,18 @@ namespace PARR.API.Validators
|
|||||||
if (string.IsNullOrEmpty(unitFilter.UnitFilterMask))
|
if (string.IsNullOrEmpty(unitFilter.UnitFilterMask))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (unitFilter.FieldFilters == null || !unitFilter.FieldFilters.Any())
|
//if (unitFilter.FieldFilters == null || !unitFilter.FieldFilters.Any())
|
||||||
return false;
|
// return false;
|
||||||
|
|
||||||
foreach (var fieldFilter in unitFilter.FieldFilters)
|
if (unitFilter.FieldFilters != null && unitFilter.FieldFilters.Any())
|
||||||
{
|
foreach (var fieldFilter in unitFilter.FieldFilters)
|
||||||
var fieldId = fieldFilter.FieldId;
|
{
|
||||||
if (await unitFieldService.GetAsync(fieldId) == null)
|
var fieldId = fieldFilter.FieldId;
|
||||||
return false;
|
if (await unitFieldService.GetAsync(fieldId) == null)
|
||||||
}
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (unitFilter.RelationshipFilters != null || unitFilter.FieldFilters.Any())
|
if (unitFilter.RelationshipFilters != null && unitFilter.RelationshipFilters.Any())
|
||||||
foreach (var relationshipFilter in unitFilter.RelationshipFilters!)
|
foreach (var relationshipFilter in unitFilter.RelationshipFilters!)
|
||||||
{
|
{
|
||||||
var fieldId = relationshipFilter.FieldId;
|
var fieldId = relationshipFilter.FieldId;
|
||||||
|
|||||||
Reference in New Issue
Block a user