Commit 3b8e4df9 authored by Hando Lukats's avatar Hando Lukats
Browse files

TEIS-1324 added controller to patch risk statement assessment description

parent 81d46056
package ee.sm.ti.teis.commongateway.riskassessments.riskstatementassessment.request;
import ee.sm.ti.teis.AbstractDTO;
import ee.sm.ti.teis.ErrorDTO;
import ee.sm.ti.teis.commongateway.riskassessments.riskstatementassessment.dto.RiskStatementAssessmentPublicDto;
public class PatchRiskStatementAssessmentDescriptionPublicRequest extends AbstractDTO<RiskStatementAssessmentPublicDto, ErrorDTO> {
public static final String ROUTING_KEY = "api.PatchRiskStatementAssessmentDescriptionPublicRequest";
@Override
public String routingKey() {
return ROUTING_KEY;
}
}
package ee.sm.ti.teis.commongateway.riskassessments.riskstatementassessment.response;
import ee.sm.ti.teis.AbstractDTO;
import ee.sm.ti.teis.ErrorDTO;
import ee.sm.ti.teis.commongateway.riskassessments.riskstatementassessment.dto.RiskStatementAssessmentPublicDto;
public class PatchRiskStatementAssessmentDescriptionPublicResponse extends AbstractDTO<RiskStatementAssessmentPublicDto, ErrorDTO> {
public static final String ROUTING_KEY = "api.PatchRiskStatementAssessmentDescriptionPublicResponse";
@Override
public String routingKey() {
return ROUTING_KEY;
}
}
......@@ -4,6 +4,7 @@ import ee.sm.ti.teis.commongateway.riskassessments.riskstatementassessment.dto.C
import ee.sm.ti.teis.commongateway.riskassessments.riskstatementassessment.dto.RiskStatementAssessmentPublicDto;
import ee.sm.ti.teis.commongateway.riskassessments.riskstatementassessment.request.CreateRiskStatementAssessmentPublicRequest;
import ee.sm.ti.teis.commongateway.riskassessments.riskstatementassessment.request.DeleteRiskStatementAssessmentPublicRequest;
import ee.sm.ti.teis.commongateway.riskassessments.riskstatementassessment.request.PatchRiskStatementAssessmentDescriptionPublicRequest;
import ee.sm.ti.teis.commongateway.riskassessments.riskstatementassessment.request.PatchRiskStatementAssessmentPublicRequest;
import ee.sm.ti.teis.gatewaycommon.controller.TeisBaseController;
import ee.sm.ti.teis.servicerequest.RequestMetaDTO;
......@@ -11,13 +12,7 @@ import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import java.util.UUID;
......@@ -74,4 +69,21 @@ public class RiskStatementAssessmentController extends TeisBaseController {
service.delete(request);
}
@ApiOperation(value = "${teis.api.risk-assessments.risk-statement-assessment.patch-description}",
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}/description")
public RiskStatementAssessmentPublicDto updateDescription(@PathVariable UUID id,
@RequestBody RiskStatementAssessmentPublicDto dto,
@ApiIgnore RequestMetaDTO requestMetaDTO) {
PatchRiskStatementAssessmentDescriptionPublicRequest request = new PatchRiskStatementAssessmentDescriptionPublicRequest();
dto.setId(id);
request.setPayload(dto, requestMetaDTO);
return service.updateDescription(request);
}
}
......@@ -3,9 +3,11 @@ package ee.sm.ti.teis.commongateway.riskassessments.riskstatementassessment;
import ee.sm.ti.teis.commongateway.riskassessments.riskstatementassessment.dto.RiskStatementAssessmentPublicDto;
import ee.sm.ti.teis.commongateway.riskassessments.riskstatementassessment.request.CreateRiskStatementAssessmentPublicRequest;
import ee.sm.ti.teis.commongateway.riskassessments.riskstatementassessment.request.DeleteRiskStatementAssessmentPublicRequest;
import ee.sm.ti.teis.commongateway.riskassessments.riskstatementassessment.request.PatchRiskStatementAssessmentDescriptionPublicRequest;
import ee.sm.ti.teis.commongateway.riskassessments.riskstatementassessment.request.PatchRiskStatementAssessmentPublicRequest;
import ee.sm.ti.teis.commongateway.riskassessments.riskstatementassessment.response.CreateRiskStatementAssessmentPublicResponse;
import ee.sm.ti.teis.commongateway.riskassessments.riskstatementassessment.response.DeleteRiskStatementAssessmentPublicResponse;
import ee.sm.ti.teis.commongateway.riskassessments.riskstatementassessment.response.PatchRiskStatementAssessmentDescriptionPublicResponse;
import ee.sm.ti.teis.commongateway.riskassessments.riskstatementassessment.response.PatchRiskStatementAssessmentPublicResponse;
import ee.sm.ti.teis.gatewaycommon.error.NoResponseFromRabbitException;
import lombok.RequiredArgsConstructor;
......@@ -48,4 +50,14 @@ public class RiskStatementAssessmentProcessingService {
throw new NoResponseFromRabbitException(request.getRequestMetaDTO().getRequestId());
}
public RiskStatementAssessmentPublicDto updateDescription(PatchRiskStatementAssessmentDescriptionPublicRequest request) {
PatchRiskStatementAssessmentDescriptionPublicResponse response =
(PatchRiskStatementAssessmentDescriptionPublicResponse) gwRabbitTemplate.convertSendAndReceive(request.routingKey(), request);
if (response != null) {
return response.processResponse();
}
throw new NoResponseFromRabbitException(request.getRequestMetaDTO().getRequestId());
}
}
......@@ -139,6 +139,7 @@ teis.api.risk-assessments.risk-assessment.delete: Teenus kustutab riskianalüüs
teis.api.risk-assessments.risk-assessment.copy: Teenus loob uue riskianalüüsi olemasoleva riskianalüüsi kopeerimise teel.
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.
teis.api.risk-assessments.risk-statement-assessment.patch-description: Teenus salvestab täiendavalt lisatud abinõu kirjelduse muudatuse. Teenust kasutab iseteenindus, et kasutaja saaks korrigeerida vigaselt sisestatud kirjeldust.
teis.api.risk-assessments.risk-statement-assessment.create: Teenus salvestab täiendava abinõu rakendamise andmed. Teenust kasutab iseteenindus, et salvestada kasutaja sisestatud täiendava abinõu rakendamise andmed.
teis.api.risk-assessments.risk-statement-assessment.delete: Teenus kustutab abinõu rakendamise väite kohta antud vastuse. Teenust kasutab iseteenindus, et kasutaja saaks kustutada ekslikult lisatud andmeobjekti.
......
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