Commit fbef601b authored by handolukats's avatar handolukats
Browse files

TEIS-1323 added controller to create risk statement assessments

parent 4c01afc4
package ee.sm.ti.teis.commongateway.riskassessments.riskstatementassessment.dto;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.UUID;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class CreateRiskStatementAssessmentPublicDto {
private UUID riskFactorAssessmentId;
private String description;
}
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.CreateRiskStatementAssessmentPublicDto;
public class CreateRiskStatementAssessmentPublicRequest extends AbstractDTO<CreateRiskStatementAssessmentPublicDto, ErrorDTO> {
public static final String ROUTING_KEY = "api.CreateRiskStatementAssessmentPublicRequest";
@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 CreateRiskStatementAssessmentPublicResponse extends AbstractDTO<RiskStatementAssessmentPublicDto, ErrorDTO> {
public static final String ROUTING_KEY = "api.CreateRiskStatementAssessmentPublicResponse";
@Override
public String routingKey() {
return ROUTING_KEY;
}
}
package ee.sm.ti.teis.commongateway.riskassessments.riskstatementassessment;
import ee.sm.ti.teis.commongateway.riskassessments.riskstatementassessment.dto.CreateRiskStatementAssessmentPublicDto;
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.PatchRiskStatementAssessmentPublicRequest;
import ee.sm.ti.teis.gatewaycommon.controller.TeisBaseController;
import ee.sm.ti.teis.servicerequest.RequestMetaDTO;
......@@ -8,7 +10,12 @@ import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
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 springfox.documentation.annotations.ApiIgnore;
import java.util.UUID;
......@@ -37,4 +44,19 @@ public class RiskStatementAssessmentController extends TeisBaseController {
return service.updateAssessment(request);
}
@ApiOperation(value = "${teis.api.risk-assessments.risk-statement-assessment.create}",
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")})
@PostMapping
public RiskStatementAssessmentPublicDto createAssessment(@RequestBody CreateRiskStatementAssessmentPublicDto dto,
@ApiIgnore RequestMetaDTO requestMetaDTO) {
CreateRiskStatementAssessmentPublicRequest request = new CreateRiskStatementAssessmentPublicRequest();
request.setPayload(dto, requestMetaDTO);
return service.createAssessment(request);
}
}
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.PatchRiskStatementAssessmentPublicRequest;
import ee.sm.ti.teis.commongateway.riskassessments.riskstatementassessment.response.CreateRiskStatementAssessmentPublicResponse;
import ee.sm.ti.teis.commongateway.riskassessments.riskstatementassessment.response.PatchRiskStatementAssessmentPublicResponse;
import ee.sm.ti.teis.gatewaycommon.error.NoResponseFromRabbitException;
import lombok.RequiredArgsConstructor;
......@@ -24,4 +26,13 @@ public class RiskStatementAssessmentProcessingService {
throw new NoResponseFromRabbitException(request.getRequestMetaDTO().getRequestId());
}
public RiskStatementAssessmentPublicDto createAssessment(CreateRiskStatementAssessmentPublicRequest request) {
CreateRiskStatementAssessmentPublicResponse response =
(CreateRiskStatementAssessmentPublicResponse) gwRabbitTemplate.convertSendAndReceive(request.routingKey(), request);
if (response != null) {
return response.processResponse();
}
throw new NoResponseFromRabbitException(request.getRequestMetaDTO().getRequestId());
}
}
......@@ -139,5 +139,6 @@ 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.create: Teenus salvestab täiendava abinõu rakendamise andmed. Teenust kasutab iseteenindus, et salvestada kasutaja sisestatud täiendava abinõu rakendamise andmed.
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