Commit e5afe18a authored by handolukats's avatar handolukats
Browse files

TEIS-1325 added controller to patch risk statement assessment

parent aeec4ba9
package ee.sm.ti.teis.commongateway.riskassessment.riskstatementassessment.request;
import ee.sm.ti.teis.AbstractDTO;
import ee.sm.ti.teis.ErrorDTO;
import ee.sm.ti.teis.commongateway.riskassessment.riskstatementassessment.dto.RiskStatementAssessmentPublicDto;
public class PatchRiskStatementAssessmentPublicRequest extends AbstractDTO<RiskStatementAssessmentPublicDto, ErrorDTO> {
public static final String ROUTING_KEY = "api.PatchRiskStatementAssessmentPublicRequest";
@Override
public String routingKey() {
return ROUTING_KEY;
}
}
package ee.sm.ti.teis.commongateway.riskassessment.riskstatementassessment.response;
import ee.sm.ti.teis.AbstractDTO;
import ee.sm.ti.teis.ErrorDTO;
import ee.sm.ti.teis.commongateway.riskassessment.riskstatementassessment.dto.RiskStatementAssessmentPublicDto;
public class PatchRiskStatementAssessmentPublicResponse extends AbstractDTO<RiskStatementAssessmentPublicDto, ErrorDTO> {
public static final String ROUTING_KEY = "api.PatchRiskStatementAssessmentPublicResponse";
@Override
public String routingKey() {
return ROUTING_KEY;
}
}
package ee.sm.ti.teis.commongateway.riskassessment.riskstatementassessment;
import ee.sm.ti.teis.commongateway.riskassessment.riskstatementassessment.dto.RiskStatementAssessmentPublicDto;
import ee.sm.ti.teis.commongateway.riskassessment.riskstatementassessment.request.PatchRiskStatementAssessmentPublicRequest;
import ee.sm.ti.teis.gatewaycommon.controller.TeisBaseController;
import ee.sm.ti.teis.servicerequest.RequestMetaDTO;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;
import java.util.UUID;
@RestController
@RequestMapping("risk-statement-assessments")
@RequiredArgsConstructor
public class RiskStatementAssessmentController extends TeisBaseController {
private final RiskStatementAssessmentProcessingService service;
@ApiOperation(value = "${teis.api.risk-assessments.risk-statement-assessment.patch}",
response = RiskStatementAssessmentPublicDto.class)
@ApiResponses(value = {
@ApiResponse(code = 400, message = "Sisendi parameetrid ei vasta nõuetele"),
@ApiResponse(code = 403, message = "Kasutajal ei ole õigust andmeobjekti pärida"),
@ApiResponse(code = 404, message = "Sisendis esitatud andmetega objekti ei eksisteeri")})
@PatchMapping("{id}/assessment")
public RiskStatementAssessmentPublicDto updateAssessment(@PathVariable UUID id,
@RequestBody RiskStatementAssessmentPublicDto dto,
@ApiIgnore RequestMetaDTO requestMetaDTO) {
PatchRiskStatementAssessmentPublicRequest request = new PatchRiskStatementAssessmentPublicRequest();
dto.setId(id);
request.setPayload(dto, requestMetaDTO);
return service.updateAssessment(request);
}
}
package ee.sm.ti.teis.commongateway.riskassessment.riskstatementassessment;
import ee.sm.ti.teis.commongateway.riskassessment.riskstatementassessment.dto.RiskStatementAssessmentPublicDto;
import ee.sm.ti.teis.commongateway.riskassessment.riskstatementassessment.request.PatchRiskStatementAssessmentPublicRequest;
import ee.sm.ti.teis.commongateway.riskassessment.riskstatementassessment.response.PatchRiskStatementAssessmentPublicResponse;
import ee.sm.ti.teis.gatewaycommon.error.NoResponseFromRabbitException;
import lombok.RequiredArgsConstructor;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Service;
@Service
@RequiredArgsConstructor
public class RiskStatementAssessmentProcessingService {
private final RabbitTemplate gwRabbitTemplate;
public RiskStatementAssessmentPublicDto updateAssessment(PatchRiskStatementAssessmentPublicRequest request) {
PatchRiskStatementAssessmentPublicResponse response =
(PatchRiskStatementAssessmentPublicResponse) gwRabbitTemplate.convertSendAndReceive(request.routingKey(), request);
if (response != null) {
return response.processResponse();
}
throw new NoResponseFromRabbitException(request.getRequestMetaDTO().getRequestId());
}
}
......@@ -135,5 +135,6 @@ teis.api.risk-assessments.risk-assessment.update-status: Teenus muudab riskianal
teis.api.risk-assessments.risk-assessment.get-by-id: Teenus väljastab riskianalüüsi andmeobjekti.
teis.api.risk-assessments.risk-assessment.get-risk-factor-assessments: Teenus väljastab riskianalüüsi raames antud ohu hinnangute andmed oos hinnatavate ohtude kirjeldustega.
teis.api.risk-assessments.risk-assessment.delete: Teenus kustutab riskianalüüsi. Teenust kasutab iseteenindus, et kustutada ekslikult loodud riskianalüüs. Kustutada ei saa kinnitatud riskianalüüsi.
teis.api.risk-assessments.risk-statement-assessment.patch: Teenus salvestab abinõu rakendamise vastuse (kas abinõu on rakendatud). Teenust kasutab iseteenindus, et salvestada kasutaja tehtud valikud.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment