diff --git a/Dockerfile b/Dockerfile index cee3b16..a4f179b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -101,7 +101,6 @@ RUN mkdir -p src/main/java && \ USER ${APP_USER} -RUN gradle openApiGenerate dependencies --no-daemon # # 🏗️ Build Stage diff --git a/README.md b/README.md index 5deaf0a..0209cce 100644 --- a/README.md +++ b/README.md @@ -1 +1,4 @@ # p4pa-organization + +To update the `generated.openapi` file, execute the `gradle generateOpenApiDocs` command. +Ensure VPN connectivity is active to access required resources. diff --git a/build.gradle.kts b/build.gradle.kts index f710ccc..ce1bad5 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -88,40 +88,12 @@ configurations { } } -tasks.compileJava { - dependsOn("openApiGenerate") -} - openApi { apiDocsUrl.set("http://localhost:8080/v3/api-docs") outputDir.set(file("$projectDir/openapi")) outputFileName.set("generated.openapi.json") } -configure { - named("main") { - java.srcDir("$projectDir/build/generated/src/main/java") - } -} - springBoot { mainClass.value("it.gov.pagopa.pu.organization.OrganizationApplication") } - -openApiGenerate { - generatorName.set("spring") - inputSpec.set("$rootDir/openapi/template-payments-java-repository.openapi.yaml") - outputDir.set("$projectDir/build/generated") - apiPackage.set("it.gov.pagopa.template.controller.generated") - modelPackage.set("it.gov.pagopa.template.model.generated") - configOptions.set(mapOf( - "dateLibrary" to "java8", - "requestMappingMode" to "api_interface", - "useSpringBoot3" to "true", - "interfaceOnly" to "true", - "useTags" to "true", - "generateConstructorWithAllArgs" to "false", - "generatedConstructorWithRequiredArgs" to "false", - "additionalModelTypeAnnotations" to "@lombok.Data @lombok.Builder @lombok.AllArgsConstructor @lombok.RequiredArgsConstructor" - )) -} diff --git a/gradlew b/gradlew old mode 100755 new mode 100644 diff --git a/openapi/generated.openapi.json b/openapi/generated.openapi.json index 938e2be..0213712 100644 --- a/openapi/generated.openapi.json +++ b/openapi/generated.openapi.json @@ -261,6 +261,287 @@ } } }, + "/organizations": { + "get": { + "tags": [ + "organization-entity-controller" + ], + "description": "get-organization", + "operationId": "getCollectionResource-organization-get_1", + "parameters": [ + { + "name": "page", + "in": "query", + "description": "Zero-based page index (0..N)", + "required": false, + "schema": { + "minimum": 0, + "type": "integer", + "default": 0 + } + }, + { + "name": "size", + "in": "query", + "description": "The size of the page to be returned", + "required": false, + "schema": { + "minimum": 1, + "type": "integer", + "default": 20 + } + }, + { + "name": "sort", + "in": "query", + "description": "Sorting criteria in the format: property,(asc|desc). Default sort order is ascending. Multiple sort criteria are supported.", + "required": false, + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/PagedModelEntityModelOrganization" + } + }, + "text/uri-list": { + "schema": { + "type": "string" + } + }, + "application/x-spring-data-compact+json": { + "schema": { + "$ref": "#/components/schemas/PagedModelEntityModelOrganization" + } + } + } + } + } + }, + "post": { + "tags": [ + "organization-entity-controller" + ], + "description": "create-organization", + "operationId": "postCollectionResource-organization-post", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OrganizationRequestBody" + } + } + }, + "required": true + }, + "responses": { + "201": { + "description": "Created", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelOrganization" + } + } + } + } + } + } + }, + "/organizations/search/findByIpaCode": { + "get": { + "tags": [ + "organization-search-controller" + ], + "operationId": "executeSearch-organization-get", + "parameters": [ + { + "name": "ipaCode", + "in": "query", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelOrganization" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + } + }, + "/organizations/{id}": { + "get": { + "tags": [ + "organization-entity-controller" + ], + "description": "get-organization", + "operationId": "getItemResource-organization-get", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelOrganization" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + }, + "put": { + "tags": [ + "organization-entity-controller" + ], + "description": "update-organization", + "operationId": "putItemResource-organization-put", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OrganizationRequestBody" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelOrganization" + } + } + } + }, + "201": { + "description": "Created", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelOrganization" + } + } + } + }, + "204": { + "description": "No Content" + } + } + }, + "delete": { + "tags": [ + "organization-entity-controller" + ], + "description": "delete-organization", + "operationId": "deleteItemResource-organization-delete", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "204": { + "description": "No Content" + }, + "404": { + "description": "Not Found" + } + } + }, + "patch": { + "tags": [ + "organization-entity-controller" + ], + "description": "patch-organization", + "operationId": "patchItemResource-organization-patch", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OrganizationRequestBody" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelOrganization" + } + } + } + }, + "204": { + "description": "No Content" + } + } + } + }, "/profile": { "get": { "tags": [ @@ -310,6 +591,36 @@ } } } + }, + "/profile/organizations": { + "get": { + "tags": [ + "profile-controller" + ], + "operationId": "descriptor_1_1_2", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + }, + "application/alps+json": { + "schema": { + "type": "string" + } + }, + "application/schema+json": { + "schema": { + "$ref": "#/components/schemas/JsonSchema" + } + } + } + } + } + } } }, "components": { @@ -394,9 +705,36 @@ } } }, + "PersonalisationFe": { + "type": "object", + "properties": { + "headerAssistanceUrl": { + "type": "string" + }, + "footerDescText": { + "type": "string" + }, + "footerPrivacyInfoUrl": { + "type": "string" + }, + "footerGDPRUrl": { + "type": "string" + }, + "footerTermsCondUrl": { + "type": "string" + }, + "footerAccessibilityUrl": { + "type": "string" + } + } + }, "EntityModelBroker": { "type": "object", "properties": { + "brokerId": { + "type": "integer", + "format": "int64" + }, "organizationId": { "type": "integer", "format": "int64" @@ -436,7 +774,7 @@ "format": "byte" }, "personalisationFe": { - "type": "string" + "$ref": "#/components/schemas/PersonalisationFe" }, "_links": { "$ref": "#/components/schemas/Links" @@ -486,6 +824,141 @@ } } }, + "EntityModelOrganization": { + "type": "object", + "properties": { + "organizationId": { + "type": "integer", + "format": "int64" + }, + "ipaCode": { + "type": "string" + }, + "orgFiscalCode": { + "type": "string" + }, + "orgName": { + "type": "string" + }, + "adminEmail": { + "type": "string" + }, + "creationDate": { + "type": "string", + "format": "date-time" + }, + "lastUpdateDate": { + "type": "string", + "format": "date-time" + }, + "fee": { + "type": "integer", + "format": "int64" + }, + "iban": { + "type": "string" + }, + "urlOrgSendSilPaymentResult": { + "type": "string" + }, + "password": { + "type": "string" + }, + "creditBicSeller": { + "type": "boolean" + }, + "beneficiaryOrgName": { + "type": "string" + }, + "beneficiaryOrgAddress": { + "type": "string" + }, + "beneficiaryOrgCivic": { + "type": "string" + }, + "beneficiaryOrgPostalCode": { + "type": "string" + }, + "beneficiaryOrgLocation": { + "type": "string" + }, + "beneficiaryOrgProvince": { + "type": "string" + }, + "beneficiaryOrgNation": { + "type": "string" + }, + "beneficiaryOrgPhoneNumber": { + "type": "string" + }, + "beneficiaryOrgWebSite": { + "type": "string" + }, + "beneficiaryOrgEmail": { + "type": "string" + }, + "applicationCode": { + "type": "string" + }, + "cbillInterBankCode": { + "type": "string" + }, + "orgInformation": { + "type": "string" + }, + "orgLogoDesc": { + "type": "string" + }, + "authorizationDesc": { + "type": "string" + }, + "status": { + "type": "string" + }, + "urlActiveExternal": { + "type": "string" + }, + "additionalLanguage": { + "type": "string" + }, + "orgTypeCode": { + "type": "string" + }, + "startDate": { + "type": "string", + "format": "date" + }, + "brokerId": { + "type": "integer", + "format": "int64" + }, + "_links": { + "$ref": "#/components/schemas/Links" + } + } + }, + "PagedModelEntityModelOrganization": { + "type": "object", + "properties": { + "_embedded": { + "type": "object", + "properties": { + "organization": { + "type": "array", + "items": { + "$ref": "#/components/schemas/EntityModelOrganization" + } + } + } + }, + "_links": { + "$ref": "#/components/schemas/Links" + }, + "page": { + "$ref": "#/components/schemas/PageMetadata" + } + } + }, "BrokerRequestBody": { "type": "object", "properties": { @@ -532,7 +1005,117 @@ "format": "byte" }, "personalisationFe": { + "$ref": "#/components/schemas/PersonalisationFe" + } + } + }, + "OrganizationRequestBody": { + "type": "object", + "properties": { + "organizationId": { + "type": "integer", + "format": "int64" + }, + "ipaCode": { + "type": "string" + }, + "orgFiscalCode": { + "type": "string" + }, + "orgName": { + "type": "string" + }, + "adminEmail": { + "type": "string" + }, + "creationDate": { + "type": "string", + "format": "date-time" + }, + "lastUpdateDate": { + "type": "string", + "format": "date-time" + }, + "fee": { + "type": "integer", + "format": "int64" + }, + "iban": { + "type": "string" + }, + "urlOrgSendSilPaymentResult": { + "type": "string" + }, + "password": { + "type": "string" + }, + "creditBicSeller": { + "type": "boolean" + }, + "beneficiaryOrgName": { + "type": "string" + }, + "beneficiaryOrgAddress": { + "type": "string" + }, + "beneficiaryOrgCivic": { + "type": "string" + }, + "beneficiaryOrgPostalCode": { + "type": "string" + }, + "beneficiaryOrgLocation": { + "type": "string" + }, + "beneficiaryOrgProvince": { + "type": "string" + }, + "beneficiaryOrgNation": { + "type": "string" + }, + "beneficiaryOrgPhoneNumber": { + "type": "string" + }, + "beneficiaryOrgWebSite": { + "type": "string" + }, + "beneficiaryOrgEmail": { + "type": "string" + }, + "applicationCode": { + "type": "string" + }, + "cbillInterBankCode": { + "type": "string" + }, + "orgInformation": { + "type": "string" + }, + "orgLogoDesc": { + "type": "string" + }, + "authorizationDesc": { "type": "string" + }, + "status": { + "type": "string" + }, + "urlActiveExternal": { + "type": "string" + }, + "additionalLanguage": { + "type": "string" + }, + "orgTypeCode": { + "type": "string" + }, + "startDate": { + "type": "string", + "format": "date" + }, + "brokerId": { + "type": "integer", + "format": "int64" } } }, diff --git a/openapi/template-payments-java-repository.openapi.yaml b/openapi/template-payments-java-repository.openapi.yaml deleted file mode 100644 index 7f5b1c0..0000000 --- a/openapi/template-payments-java-repository.openapi.yaml +++ /dev/null @@ -1,31 +0,0 @@ -openapi: 3.1.0 -info: - title: Fake API - description: "Sample API" - version: "1.0.0" -paths: - /api/v1/greet: - get: - summary: "Hello World" - description: "Sample endpoint that return greetings" - responses: - '200': - description: "Success" - content: - application/json: - schema: - type: object - properties: - message: - type: string - example: "Hello, World!" - '500': - description: "Internal Server Error" - content: - application/json: - schema: - type: object - properties: - error: - type: string - example: "Internal Server Error" diff --git a/src/main/java/it/gov/pagopa/pu/organization/model/Organization.java b/src/main/java/it/gov/pagopa/pu/organization/model/Organization.java new file mode 100644 index 0000000..5ba179f --- /dev/null +++ b/src/main/java/it/gov/pagopa/pu/organization/model/Organization.java @@ -0,0 +1,56 @@ +package it.gov.pagopa.pu.organization.model; + +import jakarta.persistence.*; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.time.Instant; +import java.time.LocalDate; + +@Entity +@Table(name = "organization") +@AllArgsConstructor +@NoArgsConstructor +@Data +public class Organization implements Serializable { + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "organization_generator") + @SequenceGenerator(name = "organization_generator", sequenceName = "organization_seq", allocationSize = 1) + private Long organizationId; + private String ipaCode; + private String orgFiscalCode; + private String orgName; + private String adminEmail; + private Instant creationDate; + private Instant lastUpdateDate; + private Long fee; + private String iban; + private String urlOrgSendSilPaymentResult; + private String password; + private Boolean creditBicSeller; + private String beneficiaryOrgName; + private String beneficiaryOrgAddress; + private String beneficiaryOrgCivic; + private String beneficiaryOrgPostalCode; + private String beneficiaryOrgLocation; + private String beneficiaryOrgProvince; + private String beneficiaryOrgNation; + private String beneficiaryOrgPhoneNumber; + private String beneficiaryOrgWebSite; + private String beneficiaryOrgEmail; + private String applicationCode; + private String cbillInterBankCode; + private String orgInformation; + private String orgLogoDesc; + private String authorizationDesc; + private String status; + private String urlActiveExternal; + private String additionalLanguage; + private String orgTypeCode; + private LocalDate startDate; + private Long brokerId; + +} diff --git a/src/main/java/it/gov/pagopa/pu/organization/repository/OrganizationRepository.java b/src/main/java/it/gov/pagopa/pu/organization/repository/OrganizationRepository.java new file mode 100644 index 0000000..f6da89d --- /dev/null +++ b/src/main/java/it/gov/pagopa/pu/organization/repository/OrganizationRepository.java @@ -0,0 +1,14 @@ +package it.gov.pagopa.pu.organization.repository; + +import it.gov.pagopa.pu.organization.model.Organization; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.rest.core.annotation.RepositoryRestResource; + +import java.util.Optional; + +@RepositoryRestResource(path = "organizations", collectionResourceRel = "organization") +public interface OrganizationRepository extends JpaRepository { + + Optional findByIpaCode(String ipaCode); + +} diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index b1ea352..ab2e363 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -21,4 +21,3 @@ management: exposure.include: "*" web: exposure.include: info, health -app: