diff --git a/src/main/java/org/tkit/onecx/permission/domain/criteria/PermissionSearchCriteria.java b/src/main/java/org/tkit/onecx/permission/domain/criteria/PermissionSearchCriteria.java index a912317..bab905f 100644 --- a/src/main/java/org/tkit/onecx/permission/domain/criteria/PermissionSearchCriteria.java +++ b/src/main/java/org/tkit/onecx/permission/domain/criteria/PermissionSearchCriteria.java @@ -1,5 +1,7 @@ package org.tkit.onecx.permission.domain.criteria; +import java.util.List; + import lombok.Getter; import lombok.Setter; @@ -8,6 +10,7 @@ public class PermissionSearchCriteria { private String appId; + private List productNames; private Integer pageNumber; private Integer pageSize; } diff --git a/src/main/java/org/tkit/onecx/permission/domain/daos/PermissionDAO.java b/src/main/java/org/tkit/onecx/permission/domain/daos/PermissionDAO.java index 914dfe7..e578643 100644 --- a/src/main/java/org/tkit/onecx/permission/domain/daos/PermissionDAO.java +++ b/src/main/java/org/tkit/onecx/permission/domain/daos/PermissionDAO.java @@ -30,7 +30,9 @@ public PageResult findByCriteria(PermissionSearchCriteria criteria) List predicates = new ArrayList<>(); addSearchStringPredicate(predicates, cb, root.get(Permission_.appId), criteria.getAppId()); - + if (criteria.getProductNames() != null) { + predicates.add(root.get(Permission_.PRODUCT_NAME).in(criteria.getProductNames())); + } if (!predicates.isEmpty()) { cq.where(predicates.toArray(new Predicate[] {})); } diff --git a/src/main/openapi/onecx-permission-internal-openapi.yaml b/src/main/openapi/onecx-permission-internal-openapi.yaml index 31920ef..8428e32 100644 --- a/src/main/openapi/onecx-permission-internal-openapi.yaml +++ b/src/main/openapi/onecx-permission-internal-openapi.yaml @@ -500,8 +500,11 @@ components: properties: appId: type: string - productName: - type: string + productNames: + type: array + items: + type: + string pageNumber: format: int32 description: The number of page. diff --git a/src/test/java/org/tkit/onecx/permission/rs/internal/controllers/PermissionRestControllerTest.java b/src/test/java/org/tkit/onecx/permission/rs/internal/controllers/PermissionRestControllerTest.java index 9d9842e..be3fd65 100644 --- a/src/test/java/org/tkit/onecx/permission/rs/internal/controllers/PermissionRestControllerTest.java +++ b/src/test/java/org/tkit/onecx/permission/rs/internal/controllers/PermissionRestControllerTest.java @@ -6,6 +6,8 @@ import static org.jboss.resteasy.reactive.RestResponse.Status.BAD_REQUEST; import static org.jboss.resteasy.reactive.RestResponse.Status.OK; +import java.util.List; + import org.junit.jupiter.api.Test; import org.tkit.onecx.permission.rs.internal.mappers.ExceptionMapper; import org.tkit.onecx.permission.test.AbstractTest; @@ -75,6 +77,23 @@ void searchCriteriaTest() { assertThat(data).isNotNull(); assertThat(data.getTotalElements()).isEqualTo(5); assertThat(data.getStream()).isNotNull().hasSize(5); + + var productNamesCriteria = new PermissionSearchCriteriaDTO(); + productNamesCriteria.setProductNames(List.of("test1")); + var output = given() + .contentType(APPLICATION_JSON) + .body(productNamesCriteria) + .post() + .then() + .statusCode(OK.getStatusCode()) + .contentType(APPLICATION_JSON) + .extract() + .as(PermissionPageResultDTO.class); + + assertThat(output).isNotNull(); + assertThat(output.getTotalElements()).isEqualTo(7); + assertThat(output.getStream()).isNotNull().hasSize(7); + } @Test