diff --git a/src/main/java/org/tkit/onecx/workspace/domain/services/ProductService.java b/src/main/java/org/tkit/onecx/workspace/domain/services/ProductService.java new file mode 100644 index 0000000..296a8e8 --- /dev/null +++ b/src/main/java/org/tkit/onecx/workspace/domain/services/ProductService.java @@ -0,0 +1,27 @@ +package org.tkit.onecx.workspace.domain.services; + +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.inject.Inject; +import jakarta.transaction.Transactional; + +import org.tkit.onecx.workspace.domain.criteria.ProductSearchCriteria; +import org.tkit.onecx.workspace.domain.daos.ProductDAO; +import org.tkit.onecx.workspace.rs.internal.mappers.ProductMapper; + +import gen.org.tkit.onecx.workspace.rs.internal.model.ProductPageResultDTO; + +@ApplicationScoped +public class ProductService { + + @Inject + ProductDAO productDAO; + + @Inject + ProductMapper mapper; + + @Transactional + public ProductPageResultDTO findByCriteria(ProductSearchCriteria criteria) { + var result = productDAO.findByCriteria(criteria); + return mapper.mapPage(result); + } +} diff --git a/src/main/java/org/tkit/onecx/workspace/rs/internal/controllers/ProductInternalRestController.java b/src/main/java/org/tkit/onecx/workspace/rs/internal/controllers/ProductInternalRestController.java index ccb3096..2e6759d 100644 --- a/src/main/java/org/tkit/onecx/workspace/rs/internal/controllers/ProductInternalRestController.java +++ b/src/main/java/org/tkit/onecx/workspace/rs/internal/controllers/ProductInternalRestController.java @@ -15,6 +15,7 @@ import org.jboss.resteasy.reactive.server.ServerExceptionMapper; import org.tkit.onecx.workspace.domain.daos.ProductDAO; import org.tkit.onecx.workspace.domain.daos.WorkspaceDAO; +import org.tkit.onecx.workspace.domain.services.ProductService; import org.tkit.onecx.workspace.rs.internal.mappers.InternalExceptionMapper; import org.tkit.onecx.workspace.rs.internal.mappers.ProductMapper; import org.tkit.quarkus.jpa.exceptions.ConstraintException; @@ -46,6 +47,9 @@ public class ProductInternalRestController implements ProductInternalApi { @Inject WorkspaceDAO workspaceDAO; + @Inject + ProductService productService; + @Override public Response createProduct(CreateProductRequestDTO createProductRequestDTO) { var workspace = workspaceDAO.findById(createProductRequestDTO.getWorkspaceId()); @@ -80,8 +84,8 @@ public Response getProductById(String productId) { @Override public Response searchProducts(ProductSearchCriteriaDTO productSearchCriteriaDTO) { var criteria = mapper.map(productSearchCriteriaDTO); - var result = dao.findByCriteria(criteria); - return Response.ok(mapper.mapPage(result)).build(); + var result = productService.findByCriteria(criteria); + return Response.ok(result).build(); } @Override diff --git a/src/main/java/org/tkit/onecx/workspace/rs/internal/mappers/ProductMapper.java b/src/main/java/org/tkit/onecx/workspace/rs/internal/mappers/ProductMapper.java index 39cd359..0e01d18 100644 --- a/src/main/java/org/tkit/onecx/workspace/rs/internal/mappers/ProductMapper.java +++ b/src/main/java/org/tkit/onecx/workspace/rs/internal/mappers/ProductMapper.java @@ -19,6 +19,9 @@ public interface ProductMapper { @Mapping(target = "removeStreamItem", ignore = true) ProductPageResultDTO mapPage(PageResult page); + @Mapping(target = "removeMicrofrontendsItem", ignore = true) + ProductResultDTO mapResult(Product product); + ProductSearchCriteria map(ProductSearchCriteriaDTO dto); default Product create(CreateProductRequestDTO dto, Workspace workspace) { diff --git a/src/main/openapi/onecx-workspace-internal-openapi.yaml b/src/main/openapi/onecx-workspace-internal-openapi.yaml index 81b803a..1dd7bd4 100644 --- a/src/main/openapi/onecx-workspace-internal-openapi.yaml +++ b/src/main/openapi/onecx-workspace-internal-openapi.yaml @@ -748,6 +748,10 @@ components: type: string baseUrl: type: string + microfrontends: + type: array + items: + $ref: '#/components/schemas/Microfrontend' RoleSearchCriteria: type: object properties: diff --git a/src/test/java/org/tkit/onecx/workspace/rs/internal/controllers/ProductRestControllerTest.java b/src/test/java/org/tkit/onecx/workspace/rs/internal/controllers/ProductRestControllerTest.java index 186afd6..f9b5321 100644 --- a/src/test/java/org/tkit/onecx/workspace/rs/internal/controllers/ProductRestControllerTest.java +++ b/src/test/java/org/tkit/onecx/workspace/rs/internal/controllers/ProductRestControllerTest.java @@ -119,6 +119,7 @@ void deleteProductByIdTest() { assertThat(dto).isNotNull(); assertThat(dto.getStream()).isNotEmpty().hasSize(1); + assertThat(dto.getStream().get(0).getMicrofrontends()).hasSize(2); } @Test