Skip to content

Commit

Permalink
feat: added mfes to search products response (#54)
Browse files Browse the repository at this point in the history
* feat: added mfes to search products response

* feat: temp solution
  • Loading branch information
JordenReuter authored Apr 16, 2024
1 parent 657c201 commit 2c1777f
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ public interface ProductMapper {
@Mapping(target = "removeStreamItem", ignore = true)
ProductPageResultDTO mapPage(PageResult<Product> page);

@Mapping(target = "removeMicrofrontendsItem", ignore = true)
ProductResultDTO mapResult(Product product);

ProductSearchCriteria map(ProductSearchCriteriaDTO dto);

default Product create(CreateProductRequestDTO dto, Workspace workspace) {
Expand Down
4 changes: 4 additions & 0 deletions src/main/openapi/onecx-workspace-internal-openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,10 @@ components:
type: string
baseUrl:
type: string
microfrontends:
type: array
items:
$ref: '#/components/schemas/Microfrontend'
RoleSearchCriteria:
type: object
properties:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ void deleteProductByIdTest() {

assertThat(dto).isNotNull();
assertThat(dto.getStream()).isNotEmpty().hasSize(1);
assertThat(dto.getStream().get(0).getMicrofrontends()).hasSize(2);
}

@Test
Expand Down

0 comments on commit 2c1777f

Please sign in to comment.