From 165654bf1f7e4382722f1d43d866a2ab8b383315 Mon Sep 17 00:00:00 2001 From: oleksiybozhykntt Date: Fri, 20 Dec 2024 12:39:10 +0100 Subject: [PATCH] updated entity --- .../controller/TaxonomyController.java | 2 +- .../DistinctOrganizationTypeDTO.java | 5 ++--- .../repository/TaxonomyRepository.java | 20 +++++++++---------- .../organization/service/TaxonomyService.java | 2 +- 4 files changed, 13 insertions(+), 16 deletions(-) rename src/main/java/it/gov/pagopa/pu/organization/{dto => model}/DistinctOrganizationTypeDTO.java (52%) diff --git a/src/main/java/it/gov/pagopa/pu/organization/controller/TaxonomyController.java b/src/main/java/it/gov/pagopa/pu/organization/controller/TaxonomyController.java index 1257f93..333d245 100644 --- a/src/main/java/it/gov/pagopa/pu/organization/controller/TaxonomyController.java +++ b/src/main/java/it/gov/pagopa/pu/organization/controller/TaxonomyController.java @@ -1,6 +1,6 @@ package it.gov.pagopa.pu.organization.controller; -import it.gov.pagopa.pu.organization.dto.DistinctOrganizationTypeDTO; +import it.gov.pagopa.pu.organization.model.DistinctOrganizationTypeDTO; import it.gov.pagopa.pu.organization.service.TaxonomyService; import java.util.List; import org.springframework.http.HttpStatusCode; diff --git a/src/main/java/it/gov/pagopa/pu/organization/dto/DistinctOrganizationTypeDTO.java b/src/main/java/it/gov/pagopa/pu/organization/model/DistinctOrganizationTypeDTO.java similarity index 52% rename from src/main/java/it/gov/pagopa/pu/organization/dto/DistinctOrganizationTypeDTO.java rename to src/main/java/it/gov/pagopa/pu/organization/model/DistinctOrganizationTypeDTO.java index 9cd4900..5a85e40 100644 --- a/src/main/java/it/gov/pagopa/pu/organization/dto/DistinctOrganizationTypeDTO.java +++ b/src/main/java/it/gov/pagopa/pu/organization/model/DistinctOrganizationTypeDTO.java @@ -1,9 +1,8 @@ -package it.gov.pagopa.pu.organization.dto; +package it.gov.pagopa.pu.organization.model; -import it.gov.pagopa.pu.organization.model.Taxonomy; import org.springframework.data.rest.core.config.Projection; -@Projection(name = "distinctOrganizationType", types = { Taxonomy.class }) +@Projection(name = "dataView", types = Taxonomy.class) public interface DistinctOrganizationTypeDTO { String getOrganizationType(); String getOrganizationTypeDescription(); diff --git a/src/main/java/it/gov/pagopa/pu/organization/repository/TaxonomyRepository.java b/src/main/java/it/gov/pagopa/pu/organization/repository/TaxonomyRepository.java index dbc9e8a..9c79417 100644 --- a/src/main/java/it/gov/pagopa/pu/organization/repository/TaxonomyRepository.java +++ b/src/main/java/it/gov/pagopa/pu/organization/repository/TaxonomyRepository.java @@ -1,10 +1,6 @@ package it.gov.pagopa.pu.organization.repository; -import it.gov.pagopa.pu.organization.dto.DistinctCollectionReasonDTO; -import it.gov.pagopa.pu.organization.dto.DistinctMacroAreaDTO; -import it.gov.pagopa.pu.organization.dto.DistinctOrganizationTypeDTO; -import it.gov.pagopa.pu.organization.dto.DistinctServiceTypeDTO; -import it.gov.pagopa.pu.organization.dto.DistinctTaxonomyCodeDTO; +import it.gov.pagopa.pu.organization.model.DistinctOrganizationTypeDTO; import it.gov.pagopa.pu.organization.model.Taxonomy; import java.util.List; import org.springframework.data.jpa.repository.JpaRepository; @@ -13,15 +9,17 @@ @RepositoryRestResource(collectionResourceRel = "taxonomy", path = "taxonomy") public interface TaxonomyRepository extends JpaRepository { - @Query("SELECT DISTINCT t.organizationType,t.organizationTypeDescription FROM Taxonomy t") - List findDistinctOrganizationType(); - List findDistinctMacroAreaCodeByOrganizationType(String organizationType); + @Query("select distinct t.organizationType as organizationType, t.organizationTypeDescription as organizationTypeDescription from Taxonomy t") + List findDistinctOrganizationTypeAndOrganizationTypeDescriptionBy(); + List findDistinctOrganizationTypeBy(); - List findDistinctServiceTypeCodeByOrganizationTypeAndMacroAreaCode(String organizationType,String macroAreaCode); + List findDistinctMacroAreaCodeByOrganizationType(String organizationType); - List findDistinctCollectionReasonByOrganizationTypeAndMacroAreaCodeAndServiceTypeCode(String organizationType,String macroAreaCode,String serviceTypeCode); + List findDistinctServiceTypeCodeByOrganizationTypeAndMacroAreaCode(String organizationType,String macroAreaCode); - List findDistinctTaxonomyCodeByOrganizationTypeAndMacroAreaCodeAndServiceTypeCodeAndCollectionReason(String organizationType,String macroAreaName,String serviceType,String collectionReason); + List findDistinctCollectionReasonByOrganizationTypeAndMacroAreaCodeAndServiceTypeCode(String organizationType,String macroAreaCode,String serviceTypeCode); + + List findDistinctTaxonomyCodeByOrganizationTypeAndMacroAreaCodeAndServiceTypeCodeAndCollectionReason(String organizationType,String macroAreaName,String serviceType,String collectionReason); } diff --git a/src/main/java/it/gov/pagopa/pu/organization/service/TaxonomyService.java b/src/main/java/it/gov/pagopa/pu/organization/service/TaxonomyService.java index 89ed914..649a757 100644 --- a/src/main/java/it/gov/pagopa/pu/organization/service/TaxonomyService.java +++ b/src/main/java/it/gov/pagopa/pu/organization/service/TaxonomyService.java @@ -1,6 +1,6 @@ package it.gov.pagopa.pu.organization.service; -import it.gov.pagopa.pu.organization.dto.DistinctOrganizationTypeDTO; +import it.gov.pagopa.pu.organization.model.DistinctOrganizationTypeDTO; import it.gov.pagopa.pu.organization.repository.TaxonomyRepository; import java.util.List; import org.springframework.stereotype.Service;