diff --git a/backend/src/main/java/org/sc/adapter/microservice/ErtEventMicroserviceAdapter.kt b/backend/src/main/java/org/sc/adapter/microservice/ErtEventMicroserviceAdapter.kt index 381fe9e..6ce59d5 100644 --- a/backend/src/main/java/org/sc/adapter/microservice/ErtEventMicroserviceAdapter.kt +++ b/backend/src/main/java/org/sc/adapter/microservice/ErtEventMicroserviceAdapter.kt @@ -20,13 +20,15 @@ class ErtEventMicroserviceAdapter @Autowired constructor( lateinit var endpointUrl: String override fun getByIstat1( - istat: String + istat: String, + skip: Int, + limit: Int, ): ResponseEntity? { return try { restTemplateBuilder.build() .getForEntity( endpointUrl.plus( - "/${istat}" + "/${istat}?skip=${skip}&limit=${limit}" ), org.openapitools.model.EventResponse::class.java ) diff --git a/backend/src/main/java/org/sc/controller/microservice/ErtEventsController.kt b/backend/src/main/java/org/sc/controller/microservice/ErtEventsController.kt index b225274..a26f0f6 100644 --- a/backend/src/main/java/org/sc/controller/microservice/ErtEventsController.kt +++ b/backend/src/main/java/org/sc/controller/microservice/ErtEventsController.kt @@ -1,15 +1,13 @@ package org.sc.controller.microservice import io.swagger.v3.oas.annotations.Operation +import org.hikit.common.ControllerConstants import org.openapitools.model.EventResponse import org.sc.adapter.microservice.ErtEventMicroserviceAdapter import org.sc.data.validator.GeneralValidator import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression -import org.springframework.web.bind.annotation.GetMapping -import org.springframework.web.bind.annotation.PathVariable -import org.springframework.web.bind.annotation.RequestMapping -import org.springframework.web.bind.annotation.RestController +import org.springframework.web.bind.annotation.* @RestController @ConditionalOnExpression("\${microservice.ert.events.enabled:false}") @@ -25,13 +23,15 @@ class ErtEventsController @Autowired constructor( @Operation(summary = "Retrieve events by istat code") @GetMapping("/{istat}", produces = ["application/json"]) operator fun get( - @PathVariable(required = true) istat: String + @PathVariable(required = true) istat: String, + @RequestParam(required = false, defaultValue = ControllerConstants.MIN_DOCS_ON_READ) skip: Int, + @RequestParam(required = false, defaultValue = ControllerConstants.MAX_DOCS_ON_READ) limit: Int, ): EventResponse? { val validationErrors = generalValidator.validateIstat(istat) if(validationErrors.isNotEmpty()) { composeErrorResponse(validationErrors) } - return ertEventMicroserviceAdapter.getByIstat1(istat)!!.body + return ertEventMicroserviceAdapter.getByIstat1(istat, skip, limit)!!.body } private fun composeErrorResponse(validationErrors: Set) { diff --git a/backend/src/main/resources/microservice/ert-swagger.json b/backend/src/main/resources/microservice/ert-swagger.json index c7889f8..aae4e58 100644 --- a/backend/src/main/resources/microservice/ert-swagger.json +++ b/backend/src/main/resources/microservice/ert-swagger.json @@ -221,6 +221,26 @@ "schema": { "type": "string" } + }, + { + "name": "skip", + "in": "query", + "required": false, + "schema": { + "type": "integer", + "format": "int32", + "default": 0 + } + }, + { + "name": "limit", + "in": "query", + "required": false, + "schema": { + "type": "integer", + "format": "int32", + "default": 150 + } } ], "responses": { @@ -538,43 +558,6 @@ } } }, - "CityRef": { - "type": "object", - "properties": { - "istat": { - "type": "string" - }, - "city": { - "type": "string" - }, - "province": { - "type": "string" - }, - "province_short": { - "type": "string" - }, - "iat": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Iat" - } - } - } - }, - "Contact": { - "type": "object", - "properties": { - "label": { - "type": "string" - }, - "type": { - "type": "string" - }, - "value": { - "type": "string" - } - } - }, "EventDto": { "type": "object", "properties": { @@ -609,10 +592,7 @@ } }, "cityRef": { - "type": "array", - "items": { - "$ref": "#/components/schemas/CityRef" - } + "$ref": "#/components/schemas/CityRefDto" }, "attachments": { "type": "array", @@ -683,29 +663,6 @@ } } }, - "Iat": { - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "address": { - "type": "string" - }, - "number": { - "type": "string" - }, - "coordinates": { - "$ref": "#/components/schemas/Coordinates" - }, - "contacts": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Contact" - } - } - } - }, "TicketDto": { "type": "object", "properties": {