Skip to content

Commit

Permalink
feat: added maximum pagesize and default order (#63)
Browse files Browse the repository at this point in the history
* feat: added maximum pagesize and default order

* fix: static access
  • Loading branch information
JordenReuter authored Jun 12, 2024
1 parent 5fb2e0c commit 8043a25
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/main/java/org/tkit/onecx/theme/domain/daos/ThemeDAO.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.tkit.quarkus.jpa.daos.Page;
import org.tkit.quarkus.jpa.daos.PageResult;
import org.tkit.quarkus.jpa.exceptions.DAOException;
import org.tkit.quarkus.jpa.models.AbstractTraceableEntity_;
import org.tkit.quarkus.jpa.models.TraceableEntity_;
import org.tkit.quarkus.jpa.utils.QueryCriteriaUtil;

Expand Down Expand Up @@ -90,6 +91,7 @@ public PageResult<Theme> 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(AbstractTraceableEntity_.CREATION_DATE)));

return createPageQuery(cq, Page.of(criteria.getPageNumber(), criteria.getPageSize())).getPageResult();
} catch (Exception ex) {
Expand All @@ -101,7 +103,8 @@ public PageResult<Theme> 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(AbstractTraceableEntity_.CREATION_DATE)));
return createPageQuery(cq, Page.of(pageNumber, pageSize)).getPageResult();
} catch (Exception ex) {
throw new DAOException(ErrorKeys.ERROR_FIND_ALL_THEME_PAGE, ex);
Expand Down
3 changes: 2 additions & 1 deletion src/main/openapi/onecx-theme-internal-openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,8 @@ components:
pageSize:
format: int32
description: The size of page
default: 10
default: 100
maximum: 1000
type: integer
ThemeInfoList:
type: object
Expand Down

0 comments on commit 8043a25

Please sign in to comment.