From 686f223a91d64487495d1b1aa5bb7aa269e6a83f Mon Sep 17 00:00:00 2001 From: Jorden_Reuter Date: Wed, 12 Jun 2024 12:55:07 +0200 Subject: [PATCH] feat: added maximum pagesize and default order --- src/main/java/org/tkit/onecx/theme/domain/daos/ThemeDAO.java | 4 +++- src/main/openapi/onecx-theme-internal-openapi.yaml | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/tkit/onecx/theme/domain/daos/ThemeDAO.java b/src/main/java/org/tkit/onecx/theme/domain/daos/ThemeDAO.java index ba91b6b..ac45ce5 100644 --- a/src/main/java/org/tkit/onecx/theme/domain/daos/ThemeDAO.java +++ b/src/main/java/org/tkit/onecx/theme/domain/daos/ThemeDAO.java @@ -90,6 +90,7 @@ public PageResult findThemesByCriteria(ThemeSearchCriteria criteria) { if (criteria.getName() != null && !criteria.getName().isBlank()) { cq.where(cb.like(root.get(Theme_.name), QueryCriteriaUtil.wildcard(criteria.getName()))); } + cq.orderBy(cb.desc(root.get(TraceableEntity_.CREATION_DATE))); return createPageQuery(cq, Page.of(criteria.getPageNumber(), criteria.getPageSize())).getPageResult(); } catch (Exception ex) { @@ -101,7 +102,8 @@ public PageResult findAll(Integer pageNumber, Integer pageSize) { try { var cb = this.getEntityManager().getCriteriaBuilder(); var cq = cb.createQuery(Theme.class); - cq.from(Theme.class); + var root = cq.from(Theme.class); + cq.orderBy(cb.desc(root.get(TraceableEntity_.CREATION_DATE))); return createPageQuery(cq, Page.of(pageNumber, pageSize)).getPageResult(); } catch (Exception ex) { throw new DAOException(ErrorKeys.ERROR_FIND_ALL_THEME_PAGE, ex); diff --git a/src/main/openapi/onecx-theme-internal-openapi.yaml b/src/main/openapi/onecx-theme-internal-openapi.yaml index e4e6fd8..cd9fc46 100644 --- a/src/main/openapi/onecx-theme-internal-openapi.yaml +++ b/src/main/openapi/onecx-theme-internal-openapi.yaml @@ -203,7 +203,8 @@ components: pageSize: format: int32 description: The size of page - default: 10 + default: 100 + maximum: 1000 type: integer ThemeInfoList: type: object