feat(api): Отключена ручаня валидация в контроллере

This commit is contained in:
Mikhail Trubnikov
2026-05-19 16:52:33 +10:00
parent d8af0253b1
commit 8f61bbb73e
13 changed files with 102 additions and 99 deletions

View File

@@ -24,7 +24,7 @@ namespace PARR.API.Controllers.V1
/// </summary> /// </summary>
public class AgentHistoryController : BaseApiController public class AgentHistoryController : BaseApiController
{ {
private readonly IValidator<AgentHistoryRequest> validator; //private readonly IValidator<AgentHistoryRequest> validator;
private readonly IAgentHistoryRepository agentHistoryService; private readonly IAgentHistoryRepository agentHistoryService;
private readonly IUriService uriService; private readonly IUriService uriService;
private readonly IMapper mapper; private readonly IMapper mapper;
@@ -34,7 +34,7 @@ namespace PARR.API.Controllers.V1
private readonly ILogger<AgentHistoryController> logger; private readonly ILogger<AgentHistoryController> logger;
public AgentHistoryController( public AgentHistoryController(
IValidator<AgentHistoryRequest> validator, //IValidator<AgentHistoryRequest> validator,
IAgentHistoryRepository agentHistoryService, IAgentHistoryRepository agentHistoryService,
IUriService uriService, IUriService uriService,
IMapper mapper, IMapper mapper,
@@ -44,7 +44,7 @@ namespace PARR.API.Controllers.V1
ILogger<AgentHistoryController> logger ILogger<AgentHistoryController> logger
) )
{ {
this.validator = validator; //this.validator = validator;
this.agentHistoryService = agentHistoryService; this.agentHistoryService = agentHistoryService;
this.uriService = uriService; this.uriService = uriService;
this.mapper = mapper; this.mapper = mapper;
@@ -119,9 +119,9 @@ namespace PARR.API.Controllers.V1
[HttpPost(ApiRoutes.AgentHistory.Create)] [HttpPost(ApiRoutes.AgentHistory.Create)]
public async Task<IActionResult> Create([FromBody] AgentHistoryRequest request) public async Task<IActionResult> Create([FromBody] AgentHistoryRequest request)
{ {
var resultValidate = await validator.ValidateAsync(request); //var resultValidate = await validator.ValidateAsync(request);
if (!resultValidate.IsValid) //if (!resultValidate.IsValid)
return BadRequest(new Response(resultValidate.Errors)); // return BadRequest(new Response(resultValidate.Errors));
var clientIp = clientService.GetClientIp()?.ToString(); var clientIp = clientService.GetClientIp()?.ToString();

View File

@@ -23,19 +23,19 @@ namespace PARR.API.Controllers.V1
{ {
private readonly IRabbitService mqService; private readonly IRabbitService mqService;
private readonly MqSettings mqSettings; private readonly MqSettings mqSettings;
private readonly IValidator<DistributeRequest> validator; //private readonly IValidator<DistributeRequest> validator;
private readonly IClientService clientService; private readonly IClientService clientService;
public DistributorController( public DistributorController(
IRabbitService mqService, IRabbitService mqService,
MqSettings mqSettings, MqSettings mqSettings,
IValidator<DistributeRequest> validator, //IValidator<DistributeRequest> validator,
IClientService clientService IClientService clientService
) )
{ {
this.mqService = mqService; this.mqService = mqService;
this.mqSettings = mqSettings; this.mqSettings = mqSettings;
this.validator = validator; //this.validator = validator;
this.clientService = clientService; this.clientService = clientService;
} }
@@ -47,9 +47,9 @@ namespace PARR.API.Controllers.V1
[HttpPost(ApiRoutes.Distributor.Distribute)] [HttpPost(ApiRoutes.Distributor.Distribute)]
public async Task<IActionResult> Distribute([FromBody] DistributeRequest request) public async Task<IActionResult> Distribute([FromBody] DistributeRequest request)
{ {
var resultValidate = await validator.ValidateAsync(request); //var resultValidate = await validator.ValidateAsync(request);
if (!resultValidate.IsValid) //if (!resultValidate.IsValid)
return BadRequest(new Response(resultValidate.Errors)); // return BadRequest(new Response(resultValidate.Errors));
var requestToMq = new TemplateDistributorMq var requestToMq = new TemplateDistributorMq
{ {

View File

@@ -40,7 +40,7 @@ namespace PARR.API.Controllers.V1
private readonly IUriService uriService; private readonly IUriService uriService;
private readonly IJobRepository jobService; private readonly IJobRepository jobService;
private readonly ITemplateRepository templateService; private readonly ITemplateRepository templateService;
private readonly IValidator<JobRequest> jobValidator; //private readonly IValidator<JobRequest> jobValidator;
private readonly IRabbitService mqService; private readonly IRabbitService mqService;
private readonly MqSettings mqSettings; private readonly MqSettings mqSettings;
private readonly IClientService clientService; private readonly IClientService clientService;
@@ -54,7 +54,7 @@ namespace PARR.API.Controllers.V1
IJobRepository jobService, IJobRepository jobService,
ITemplateRepository templateService, ITemplateRepository templateService,
IJobGroupRepository jobGroupService, IJobGroupRepository jobGroupService,
IValidator<JobRequest> jobValidator, //IValidator<JobRequest> jobValidator,
IUnitFilterService unitFilterService, IUnitFilterService unitFilterService,
IUnitRepository unitService, IUnitRepository unitService,
IRabbitService mqService, IRabbitService mqService,
@@ -69,7 +69,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.jobValidator = jobValidator; //this.jobValidator = jobValidator;
this.mqService = mqService; this.mqService = mqService;
this.mqSettings = mqSettings; this.mqSettings = mqSettings;
this.clientService = clientService; this.clientService = clientService;
@@ -188,12 +188,12 @@ namespace PARR.API.Controllers.V1
[HttpPost(ApiRoutes.Job.Create)] [HttpPost(ApiRoutes.Job.Create)]
public async Task<IActionResult> Create([FromBody] JobRequest request) public async Task<IActionResult> Create([FromBody] JobRequest request)
{ {
#region Валидация //#region Валидация
var jobValidateResult = await jobValidator.ValidateAsync(request);//Валидация параметров самого задания //var jobValidateResult = await jobValidator.ValidateAsync(request);//Валидация параметров самого задания
if (!jobValidateResult.IsValid) //if (!jobValidateResult.IsValid)
return BadRequest(new Response(jobValidateResult.Errors)); // return BadRequest(new Response(jobValidateResult.Errors));
#endregion //#endregion
//TODO: !!!!!!! проверить, если тип ЗОНТИК или ГРУППИРОВКА, то обязательно должны быть заполнены поля min max //TODO: !!!!!!! проверить, если тип ЗОНТИК или ГРУППИРОВКА, то обязательно должны быть заполнены поля min max
@@ -262,9 +262,9 @@ namespace PARR.API.Controllers.V1
[HttpPut(ApiRoutes.Job.Update)] [HttpPut(ApiRoutes.Job.Update)]
public async Task<IActionResult> Update([FromRoute] Guid id, [FromBody] JobRequest request) public async Task<IActionResult> Update([FromRoute] Guid id, [FromBody] JobRequest request)
{ {
var resultValidate = await jobValidator.ValidateAsync(request); //var resultValidate = await jobValidator.ValidateAsync(request);
if (!resultValidate.IsValid) //if (!resultValidate.IsValid)
return BadRequest(new Response(resultValidate.Errors)); // return BadRequest(new Response(resultValidate.Errors));
var orig = await jobService.Get() var orig = await jobService.Get()
.Include(t => t.Tnk) .Include(t => t.Tnk)

View File

@@ -39,7 +39,7 @@ namespace PARR.API.Controllers.V1
private readonly IJobGroupRepository groupService; private readonly IJobGroupRepository groupService;
private readonly IJobRepository jobService; private readonly IJobRepository jobService;
private readonly IEsppSchTypeConfigRepository esppConfigService; private readonly IEsppSchTypeConfigRepository esppConfigService;
private readonly IValidator<JobGroupRequest> validator; //private readonly IValidator<JobGroupRequest> validator;
private readonly IJobGroupTypeRepository jobGroupTypeService; private readonly IJobGroupTypeRepository jobGroupTypeService;
private readonly IMatchingStatusService matchingStatusService; private readonly IMatchingStatusService matchingStatusService;
private readonly IScheduleResponseAreaTimeOffsetRepository scheduleResponseAreaTimeOffsetService; private readonly IScheduleResponseAreaTimeOffsetRepository scheduleResponseAreaTimeOffsetService;
@@ -53,7 +53,7 @@ namespace PARR.API.Controllers.V1
IJobGroupRepository groupService, IJobGroupRepository groupService,
IJobRepository jobService, IJobRepository jobService,
IEsppSchTypeConfigRepository esppConfigService, IEsppSchTypeConfigRepository esppConfigService,
IValidator<JobGroupRequest> validator, //IValidator<JobGroupRequest> validator,
IJobGroupTypeRepository jobGroupTypeService, IJobGroupTypeRepository jobGroupTypeService,
IMatchingStatusService matchingStatusService, IMatchingStatusService matchingStatusService,
IScheduleResponseAreaTimeOffsetRepository scheduleResponseAreaTimeOffsetService, IScheduleResponseAreaTimeOffsetRepository scheduleResponseAreaTimeOffsetService,
@@ -67,7 +67,7 @@ namespace PARR.API.Controllers.V1
this.groupService = groupService; this.groupService = groupService;
this.jobService = jobService; this.jobService = jobService;
this.esppConfigService = esppConfigService; this.esppConfigService = esppConfigService;
this.validator = validator; //this.validator = validator;
this.jobGroupTypeService = jobGroupTypeService; this.jobGroupTypeService = jobGroupTypeService;
this.matchingStatusService = matchingStatusService; this.matchingStatusService = matchingStatusService;
this.scheduleResponseAreaTimeOffsetService = scheduleResponseAreaTimeOffsetService; this.scheduleResponseAreaTimeOffsetService = scheduleResponseAreaTimeOffsetService;
@@ -156,10 +156,10 @@ namespace PARR.API.Controllers.V1
[HttpPost(ApiRoutes.JobGroup.Create)] [HttpPost(ApiRoutes.JobGroup.Create)]
public async Task<IActionResult> Create([FromBody] JobGroupRequest request) public async Task<IActionResult> Create([FromBody] JobGroupRequest request)
{ {
var resultValidate = await validator.ValidateAsync(request); //var resultValidate = await validator.ValidateAsync(request);
if (!resultValidate.IsValid) //if (!resultValidate.IsValid)
return BadRequest(new Response(resultValidate.Errors)); // return BadRequest(new Response(resultValidate.Errors));
var jobGroup = new JobGroup var jobGroup = new JobGroup
{ {
@@ -242,10 +242,10 @@ namespace PARR.API.Controllers.V1
[HttpPut(ApiRoutes.JobGroup.Update)] [HttpPut(ApiRoutes.JobGroup.Update)]
public async Task<IActionResult> Update([FromRoute] Guid id, [FromBody] JobGroupRequest request) public async Task<IActionResult> Update([FromRoute] Guid id, [FromBody] JobGroupRequest request)
{ {
var resultValidate = await validator.ValidateAsync(request); //var resultValidate = await validator.ValidateAsync(request);
if (!resultValidate.IsValid) //if (!resultValidate.IsValid)
return BadRequest(new Response(resultValidate.Errors)); // return BadRequest(new Response(resultValidate.Errors));
var orig = await groupService.Get() var orig = await groupService.Get()
.Include(t => t.Jobs) .Include(t => t.Jobs)

View File

@@ -24,7 +24,7 @@ namespace PARR.API.Controllers.V1
{ {
private readonly ILogger<JobUnitPreviewController> logger; private readonly ILogger<JobUnitPreviewController> logger;
private readonly IUnitFilterService unitFilterService; private readonly IUnitFilterService unitFilterService;
private readonly IValidator<JobRequest> jobValidator; //private readonly IValidator<JobRequest> jobValidator;
private readonly IUnitRepository unitService; private readonly IUnitRepository unitService;
private readonly IJobGroupRepository jobGroupService; private readonly IJobGroupRepository jobGroupService;
private readonly IMapper mapper; private readonly IMapper mapper;
@@ -32,7 +32,7 @@ namespace PARR.API.Controllers.V1
public JobUnitPreviewController( public JobUnitPreviewController(
ILogger<JobUnitPreviewController> logger, ILogger<JobUnitPreviewController> logger,
IUnitFilterService unitFilterService, IUnitFilterService unitFilterService,
IValidator<JobRequest> jobValidator, //IValidator<JobRequest> jobValidator,
IUnitRepository unitService, IUnitRepository unitService,
IJobGroupRepository jobGroupService, IJobGroupRepository jobGroupService,
IMapper mapper IMapper mapper
@@ -40,7 +40,7 @@ namespace PARR.API.Controllers.V1
{ {
this.logger = logger; this.logger = logger;
this.unitFilterService = unitFilterService; this.unitFilterService = unitFilterService;
this.jobValidator = jobValidator; //this.jobValidator = jobValidator;
this.unitService = unitService; this.unitService = unitService;
this.jobGroupService = jobGroupService; this.jobGroupService = jobGroupService;
this.mapper = mapper; this.mapper = mapper;
@@ -54,12 +54,12 @@ namespace PARR.API.Controllers.V1
[HttpPost(ApiRoutes.JobUnitPreview.Preview)] [HttpPost(ApiRoutes.JobUnitPreview.Preview)]
public async Task<IActionResult> Preview([FromBody] JobRequest request) public async Task<IActionResult> Preview([FromBody] JobRequest request)
{ {
#region Валидация //#region Валидация
var jobValidateResult = await jobValidator.ValidateAsync(request);//Валидация параметров самого задания //var jobValidateResult = await jobValidator.ValidateAsync(request);//Валидация параметров самого задания
if (!jobValidateResult.IsValid) //if (!jobValidateResult.IsValid)
return BadRequest(new Response(jobValidateResult.Errors)); // return BadRequest(new Response(jobValidateResult.Errors));
#endregion //#endregion
var job = mapper.Map<Job>(request); var job = mapper.Map<Job>(request);

View File

@@ -27,21 +27,21 @@ namespace PARR.API.Controllers.V1
private readonly ILogger<ProcessController> logger; private readonly ILogger<ProcessController> logger;
private readonly IMapper mapper; private readonly IMapper mapper;
private readonly IProcessRepository processService; private readonly IProcessRepository processService;
private readonly IValidator<ProcessRequest> validator; //private readonly IValidator<ProcessRequest> validator;
private readonly IUriService uriService; private readonly IUriService uriService;
public ProcessController( public ProcessController(
ILogger<ProcessController> logger, ILogger<ProcessController> logger,
IMapper mapper, IMapper mapper,
IProcessRepository processService, IProcessRepository processService,
IValidator<ProcessRequest> validator, //IValidator<ProcessRequest> validator,
IUriService uriService IUriService uriService
) )
{ {
this.logger = logger; this.logger = logger;
this.mapper = mapper; this.mapper = mapper;
this.processService = processService; this.processService = processService;
this.validator = validator; //this.validator = validator;
this.uriService = uriService; this.uriService = uriService;
} }
@@ -120,9 +120,9 @@ namespace PARR.API.Controllers.V1
[HttpPost(ApiRoutes.Process.Create)] [HttpPost(ApiRoutes.Process.Create)]
public async Task<IActionResult> Create([FromBody] ProcessRequest request) public async Task<IActionResult> Create([FromBody] ProcessRequest request)
{ {
var resultValidate = await validator.ValidateAsync(request); //var resultValidate = await validator.ValidateAsync(request);
if (!resultValidate.IsValid) //if (!resultValidate.IsValid)
return BadRequest(new Response(resultValidate.Errors)); // return BadRequest(new Response(resultValidate.Errors));
var existName = await processService.Get().FirstOrDefaultAsync(t => t.Name.ToLower() == request.Name.ToLower().Trim()); var existName = await processService.Get().FirstOrDefaultAsync(t => t.Name.ToLower() == request.Name.ToLower().Trim());
if (existName != null) if (existName != null)
@@ -159,9 +159,9 @@ namespace PARR.API.Controllers.V1
[HttpPut(ApiRoutes.Process.Update)] [HttpPut(ApiRoutes.Process.Update)]
public async Task<IActionResult> Update([FromRoute] Guid id, [FromBody] ProcessRequest request) public async Task<IActionResult> Update([FromRoute] Guid id, [FromBody] ProcessRequest request)
{ {
var resultValidate = await validator.ValidateAsync(request); //var resultValidate = await validator.ValidateAsync(request);
if (!resultValidate.IsValid) //if (!resultValidate.IsValid)
return BadRequest(new Response(resultValidate.Errors)); // return BadRequest(new Response(resultValidate.Errors));
//проверка на уникальность esppId //проверка на уникальность esppId
var existEsppId = await processService.Get().FirstOrDefaultAsync(t => t.Id != id && t.EsppId == request.EsppId); var existEsppId = await processService.Get().FirstOrDefaultAsync(t => t.Id != id && t.EsppId == request.EsppId);

View File

@@ -29,7 +29,7 @@ namespace PARR.API.Controllers.V1.Statistics
public class StatRobotStateController : BaseApiController public class StatRobotStateController : BaseApiController
{ {
private readonly IInfluxDbService influxDbService; private readonly IInfluxDbService influxDbService;
private readonly IValidator<RobotStateRequest> validator; //private readonly IValidator<RobotStateRequest> validator;
private readonly InfluxDbSettings influxDbSettings; private readonly InfluxDbSettings influxDbSettings;
private readonly MonitoringSettings monitoringSettings; private readonly MonitoringSettings monitoringSettings;
private readonly IClientService clientService; private readonly IClientService clientService;
@@ -38,7 +38,7 @@ namespace PARR.API.Controllers.V1.Statistics
public StatRobotStateController( public StatRobotStateController(
IInfluxDbService influxDbService, IInfluxDbService influxDbService,
IValidator<RobotStateRequest> validator, //IValidator<RobotStateRequest> validator,
InfluxDbSettings influxDbSettings, InfluxDbSettings influxDbSettings,
MonitoringSettings monitoringSettings, MonitoringSettings monitoringSettings,
IClientService clientService, IClientService clientService,
@@ -47,7 +47,7 @@ namespace PARR.API.Controllers.V1.Statistics
) )
{ {
this.influxDbService = influxDbService; this.influxDbService = influxDbService;
this.validator = validator; //this.validator = validator;
this.influxDbSettings = influxDbSettings; this.influxDbSettings = influxDbSettings;
this.monitoringSettings = monitoringSettings; this.monitoringSettings = monitoringSettings;
this.clientService = clientService; this.clientService = clientService;
@@ -136,9 +136,9 @@ namespace PARR.API.Controllers.V1.Statistics
[HttpPost(ApiRoutes.StatRobotState.Send)] [HttpPost(ApiRoutes.StatRobotState.Send)]
public async Task<IActionResult> Send([FromBody] RobotStateRequest request) public async Task<IActionResult> Send([FromBody] RobotStateRequest request)
{ {
var resultValidate = await validator.ValidateAsync(request); //var resultValidate = await validator.ValidateAsync(request);
if (!resultValidate.IsValid) //if (!resultValidate.IsValid)
return BadRequest(new Response(resultValidate.Errors)); // return BadRequest(new Response(resultValidate.Errors));
var result = influxDbService.Write(write => var result = influxDbService.Write(write =>
{ {

View File

@@ -27,21 +27,21 @@ namespace PARR.API.Controllers.V1
private readonly ILogger<SubprocessController> logger; private readonly ILogger<SubprocessController> logger;
private readonly IMapper mapper; private readonly IMapper mapper;
private readonly ISubprocessRepository subprocessService; private readonly ISubprocessRepository subprocessService;
private readonly IValidator<SubprocessRequest> validator; //private readonly IValidator<SubprocessRequest> validator;
private readonly IUriService uriService; private readonly IUriService uriService;
public SubprocessController( public SubprocessController(
ILogger<SubprocessController> logger, ILogger<SubprocessController> logger,
IMapper mapper, IMapper mapper,
ISubprocessRepository subprocessService, ISubprocessRepository subprocessService,
IValidator<SubprocessRequest> validator, //IValidator<SubprocessRequest> validator,
IUriService uriService IUriService uriService
) )
{ {
this.logger = logger; this.logger = logger;
this.mapper = mapper; this.mapper = mapper;
this.subprocessService = subprocessService; this.subprocessService = subprocessService;
this.validator = validator; //this.validator = validator;
this.uriService = uriService; this.uriService = uriService;
} }
@@ -124,9 +124,9 @@ namespace PARR.API.Controllers.V1
[HttpPost(ApiRoutes.Subprocess.Create)] [HttpPost(ApiRoutes.Subprocess.Create)]
public async Task<IActionResult> Create([FromBody] SubprocessRequest request) public async Task<IActionResult> Create([FromBody] SubprocessRequest request)
{ {
var resultValidate = await validator.ValidateAsync(request); //var resultValidate = await validator.ValidateAsync(request);
if (!resultValidate.IsValid) //if (!resultValidate.IsValid)
return BadRequest(new Response(resultValidate.Errors)); // return BadRequest(new Response(resultValidate.Errors));
var existName = await subprocessService.Get().FirstOrDefaultAsync(t => t.Name.ToLower() == request.Name.Trim().ToLower()); var existName = await subprocessService.Get().FirstOrDefaultAsync(t => t.Name.ToLower() == request.Name.Trim().ToLower());
if (existName != null) if (existName != null)
@@ -164,9 +164,9 @@ namespace PARR.API.Controllers.V1
[HttpPut(ApiRoutes.Subprocess.Update)] [HttpPut(ApiRoutes.Subprocess.Update)]
public async Task<IActionResult> Update([FromRoute] Guid id, [FromBody] SubprocessRequest request) public async Task<IActionResult> Update([FromRoute] Guid id, [FromBody] SubprocessRequest request)
{ {
var resultValidate = await validator.ValidateAsync(request); //var resultValidate = await validator.ValidateAsync(request);
if (!resultValidate.IsValid) //if (!resultValidate.IsValid)
return BadRequest(new Response(resultValidate.Errors)); // return BadRequest(new Response(resultValidate.Errors));
//проверка на уникальность esppId //проверка на уникальность esppId
var existEsppId = await subprocessService.Get().FirstOrDefaultAsync(t => t.Id != id && t.EsppId == request.EsppId); var existEsppId = await subprocessService.Get().FirstOrDefaultAsync(t => t.Id != id && t.EsppId == request.EsppId);

View File

@@ -22,7 +22,7 @@ namespace PARR.API.Controllers.V1
[Authorize(Roles = ParrRoles.Administrator.Role)] [Authorize(Roles = ParrRoles.Administrator.Role)]
public class TemplateActivatorController : BaseApiController public class TemplateActivatorController : BaseApiController
{ {
private readonly IValidator<TemplateActivatorRequest> validator; //private readonly IValidator<TemplateActivatorRequest> validator;
private readonly IRabbitService mqService; private readonly IRabbitService mqService;
private readonly IUriService uriService; private readonly IUriService uriService;
private readonly MqSettings mqSettings; private readonly MqSettings mqSettings;
@@ -30,7 +30,7 @@ namespace PARR.API.Controllers.V1
private readonly IClientService clientService; private readonly IClientService clientService;
public TemplateActivatorController( public TemplateActivatorController(
IValidator<TemplateActivatorRequest> validator, //IValidator<TemplateActivatorRequest> validator,
IRabbitService mqService, IRabbitService mqService,
IUriService uriService, IUriService uriService,
MqSettings mqSettings, MqSettings mqSettings,
@@ -38,7 +38,7 @@ namespace PARR.API.Controllers.V1
IClientService clientService IClientService clientService
) )
{ {
this.validator = validator; //this.validator = validator;
this.mqService = mqService; this.mqService = mqService;
this.uriService = uriService; this.uriService = uriService;
this.mqSettings = mqSettings; this.mqSettings = mqSettings;
@@ -54,9 +54,9 @@ namespace PARR.API.Controllers.V1
[HttpPost(ApiRoutes.TemplateActivator.SendRequest)] [HttpPost(ApiRoutes.TemplateActivator.SendRequest)]
public async Task<IActionResult> SendRequest([FromBody] TemplateActivatorRequest request) public async Task<IActionResult> SendRequest([FromBody] TemplateActivatorRequest request)
{ {
var resultValidate = await validator.ValidateAsync(request); //var resultValidate = await validator.ValidateAsync(request);
if (!resultValidate.IsValid) //if (!resultValidate.IsValid)
return BadRequest(new Response(resultValidate.Errors)); // return BadRequest(new Response(resultValidate.Errors));
var mqRequest = new TemplateActivatorMq var mqRequest = new TemplateActivatorMq
{ {

View File

@@ -21,19 +21,19 @@ namespace PARR.API.Controllers.V1
{ {
private readonly ITemplateRepository templateService; private readonly ITemplateRepository templateService;
private readonly IMapper mapper; private readonly IMapper mapper;
private readonly IValidator<TemplateScheduleEsppIdRequest> validator; //private readonly IValidator<TemplateScheduleEsppIdRequest> validator;
private readonly IUriService uriService; private readonly IUriService uriService;
public TemplateScheduleEspp( public TemplateScheduleEspp(
ITemplateRepository templateService, ITemplateRepository templateService,
IMapper mapper, IMapper mapper,
IValidator<TemplateScheduleEsppIdRequest> validator, //IValidator<TemplateScheduleEsppIdRequest> validator,
IUriService uriService IUriService uriService
) )
{ {
this.templateService = templateService; this.templateService = templateService;
this.mapper = mapper; this.mapper = mapper;
this.validator = validator; //this.validator = validator;
this.uriService = uriService; this.uriService = uriService;
} }
@@ -62,9 +62,9 @@ namespace PARR.API.Controllers.V1
[HttpPost(ApiRoutes.TemplateScheduleEspp.Create)] [HttpPost(ApiRoutes.TemplateScheduleEspp.Create)]
public async Task<IActionResult> SetEsppId([FromRoute] Guid templateId, [FromBody] TemplateScheduleEsppIdRequest request) public async Task<IActionResult> SetEsppId([FromRoute] Guid templateId, [FromBody] TemplateScheduleEsppIdRequest request)
{ {
var resultValidate = await validator.ValidateAsync(request); //var resultValidate = await validator.ValidateAsync(request);
if (!resultValidate.IsValid) //if (!resultValidate.IsValid)
return BadRequest(new Response(resultValidate.Errors)); // return BadRequest(new Response(resultValidate.Errors));
var template = await templateService.GetAsync(templateId); var template = await templateService.GetAsync(templateId);

View File

@@ -27,21 +27,21 @@ namespace PARR.API.Controllers.V1
private readonly ILogger<TnkController> logger; private readonly ILogger<TnkController> logger;
private readonly IMapper mapper; private readonly IMapper mapper;
private readonly ITnkRepository tnkService; private readonly ITnkRepository tnkService;
private readonly IValidator<TnkRequest> validator; //private readonly IValidator<TnkRequest> validator;
private readonly IUriService uriService; private readonly IUriService uriService;
public TnkController( public TnkController(
ILogger<TnkController> logger, ILogger<TnkController> logger,
IMapper mapper, IMapper mapper,
ITnkRepository tnkService, ITnkRepository tnkService,
IValidator<TnkRequest> validator, //IValidator<TnkRequest> validator,
IUriService uriService IUriService uriService
) )
{ {
this.logger = logger; this.logger = logger;
this.mapper = mapper; this.mapper = mapper;
this.tnkService = tnkService; this.tnkService = tnkService;
this.validator = validator; //this.validator = validator;
this.uriService = uriService; this.uriService = uriService;
} }
@@ -127,9 +127,9 @@ namespace PARR.API.Controllers.V1
[HttpPost(ApiRoutes.Tnk.Create)] [HttpPost(ApiRoutes.Tnk.Create)]
public async Task<IActionResult> Create([FromBody] TnkRequest request) public async Task<IActionResult> Create([FromBody] TnkRequest request)
{ {
var resultValidate = await validator.ValidateAsync(request); //var resultValidate = await validator.ValidateAsync(request);
if (!resultValidate.IsValid) //if (!resultValidate.IsValid)
return BadRequest(new Response(resultValidate.Errors)); // return BadRequest(new Response(resultValidate.Errors));
var existName = await tnkService.Get().FirstOrDefaultAsync(t => t.Name.ToLower() == request.Name.Trim().ToLower()); var existName = await tnkService.Get().FirstOrDefaultAsync(t => t.Name.ToLower() == request.Name.Trim().ToLower());
if (existName != null) if (existName != null)
@@ -168,9 +168,9 @@ namespace PARR.API.Controllers.V1
[HttpPut(ApiRoutes.Tnk.Update)] [HttpPut(ApiRoutes.Tnk.Update)]
public async Task<IActionResult> Update([FromRoute] Guid id, [FromBody] TnkRequest request) public async Task<IActionResult> Update([FromRoute] Guid id, [FromBody] TnkRequest request)
{ {
var resultValidate = await validator.ValidateAsync(request); //var resultValidate = await validator.ValidateAsync(request);
if (!resultValidate.IsValid) //if (!resultValidate.IsValid)
return BadRequest(new Response(resultValidate.Errors)); // return BadRequest(new Response(resultValidate.Errors));
////проверка на уникальность esppId ////проверка на уникальность esppId
//var existEsppId = await tnkService.Get().FirstOrDefaultAsync(t => t.Id != id && t.EsppId == request.EsppId); //var existEsppId = await tnkService.Get().FirstOrDefaultAsync(t => t.Id != id && t.EsppId == request.EsppId);

View File

@@ -15,6 +15,7 @@ using PARR.Core.Repositories.Interfaces;
using PARR.Domain.Common.Pagination; using PARR.Domain.Common.Pagination;
using PARR.Domain.Common.Roles; using PARR.Domain.Common.Roles;
using PARR.Domain.Entities; using PARR.Domain.Entities;
using PARR.Domain.Exceptions;
namespace PARR.API.Controllers.V1 namespace PARR.API.Controllers.V1
{ {
@@ -26,21 +27,21 @@ namespace PARR.API.Controllers.V1
{ {
private readonly IMapper mapper; private readonly IMapper mapper;
private readonly IUserRepository userService; private readonly IUserRepository userService;
private readonly IValidator<UserRequest> validator; //private readonly IValidator<UserRequest> validator;
private readonly IUriService uriService; private readonly IUriService uriService;
private readonly ILogger<UserController> logger; private readonly ILogger<UserController> logger;
public UserController( public UserController(
IMapper mapper, IMapper mapper,
IUserRepository userService, IUserRepository userService,
IValidator<UserRequest> validator, //IValidator<UserRequest> validator,
IUriService uriService, IUriService uriService,
ILogger<UserController> logger ILogger<UserController> logger
) )
{ {
this.mapper = mapper; this.mapper = mapper;
this.userService = userService; this.userService = userService;
this.validator = validator; //this.validator = validator;
this.uriService = uriService; this.uriService = uriService;
this.logger = logger; this.logger = logger;
} }
@@ -122,14 +123,16 @@ namespace PARR.API.Controllers.V1
[HttpPost(ApiRoutes.User.Create)] [HttpPost(ApiRoutes.User.Create)]
public async Task<IActionResult> Create([FromBody] UserRequest request) public async Task<IActionResult> Create([FromBody] UserRequest request)
{ {
var resultValidate = await validator.ValidateAsync(request); //var resultValidate = await validator.ValidateAsync(request);
if (!resultValidate.IsValid) //if (!resultValidate.IsValid)
return BadRequest(new Response(resultValidate.Errors)); // return BadRequest(new Response(resultValidate.Errors));
var existIp = await userService.Get().FirstOrDefaultAsync(t => t.Ip == request.Ip); var existIp = await userService.Get().FirstOrDefaultAsync(t => t.Ip == request.Ip);
if (existIp != null) if (existIp != null)
//throw new AlreadyExistsException($"Ip {request.Ip} занят другим пользователем.");
return BadRequest(new Response(false, new List<ErrorModel> { new ErrorModel { FieldName = nameof(request.Ip), Message = $"Ip {request.Ip} занят другим пользователем." } })); return BadRequest(new Response(false, new List<ErrorModel> { new ErrorModel { FieldName = nameof(request.Ip), Message = $"Ip {request.Ip} занят другим пользователем." } }));
var user = new User var user = new User
{ {
Id = Guid.NewGuid(), Id = Guid.NewGuid(),
@@ -158,9 +161,9 @@ namespace PARR.API.Controllers.V1
[HttpPut(ApiRoutes.User.Update)] [HttpPut(ApiRoutes.User.Update)]
public async Task<IActionResult> Update([FromRoute] Guid id, [FromBody] UserRequest request) public async Task<IActionResult> Update([FromRoute] Guid id, [FromBody] UserRequest request)
{ {
var resultValidate = await validator.ValidateAsync(request); //var resultValidate = await validator.ValidateAsync(request);
if (!resultValidate.IsValid) //if (!resultValidate.IsValid)
return BadRequest(new Response(resultValidate.Errors)); // return BadRequest(new Response(resultValidate.Errors));
var orig = await userService.Get() var orig = await userService.Get()
.Include(t => t.Roles).ThenInclude(t => t.Role) .Include(t => t.Roles).ThenInclude(t => t.Role)

View File

@@ -27,7 +27,7 @@ namespace PARR.API.Controllers.V1
private readonly IMapper mapper; private readonly IMapper mapper;
private readonly IWeekendDayRepository weekendDayService; private readonly IWeekendDayRepository weekendDayService;
private readonly IUriService uriService; private readonly IUriService uriService;
private readonly IValidator<WeekendRequest> validator; //private readonly IValidator<WeekendRequest> validator;
public WeekendController( public WeekendController(
IMapper mapper, IMapper mapper,
@@ -39,7 +39,7 @@ namespace PARR.API.Controllers.V1
this.mapper = mapper; this.mapper = mapper;
this.weekendDayService = weekendDayService; this.weekendDayService = weekendDayService;
this.uriService = uriService; this.uriService = uriService;
this.validator = validator; //this.validator = validator;
} }
@@ -94,9 +94,9 @@ namespace PARR.API.Controllers.V1
[HttpPost(ApiRoutes.Weekend.Create)] [HttpPost(ApiRoutes.Weekend.Create)]
public async Task<IActionResult> Create([FromBody] WeekendRequest request) public async Task<IActionResult> Create([FromBody] WeekendRequest request)
{ {
var resultValidate = await validator.ValidateAsync(request); //var resultValidate = await validator.ValidateAsync(request);
if (!resultValidate.IsValid) //if (!resultValidate.IsValid)
return BadRequest(new Response(resultValidate.Errors)); // return BadRequest(new Response(resultValidate.Errors));
var weekend = new WeekendDay { Id = Guid.NewGuid(), Date = request.WeekendDate }; var weekend = new WeekendDay { Id = Guid.NewGuid(), Date = request.WeekendDate };