From cc3dc405a054b7baac51f3b4ee282b221345810f Mon Sep 17 00:00:00 2001 From: Marthym Date: Sun, 21 Apr 2024 11:21:18 +0200 Subject: [PATCH] chore(sandside): #162 refactor QueryContext into record --- .../baywatch/common/domain/QueryContext.java | 19 +++++++++--------- .../ScrapingErrorPersistenceAdapter.java | 4 ++-- .../infra/persistence/UserRepository.java | 8 ++++---- .../adapters/MembersPersistenceAdapter.java | 8 ++++---- .../adapters/TeamPersistenceAdapter.java | 8 ++++---- .../techwatch/domain/NewsServiceImpl.java | 20 +++++++++---------- .../infra/persistence/FeedRepository.java | 18 ++++++++--------- .../infra/persistence/NewsRepository.java | 16 +++++++-------- .../infra/persistence/StateRepository.java | 6 +++--- 9 files changed, 53 insertions(+), 54 deletions(-) diff --git a/sandside/src/main/java/fr/ght1pc9kc/baywatch/common/domain/QueryContext.java b/sandside/src/main/java/fr/ght1pc9kc/baywatch/common/domain/QueryContext.java index ea5505c4..904e3bb0 100644 --- a/sandside/src/main/java/fr/ght1pc9kc/baywatch/common/domain/QueryContext.java +++ b/sandside/src/main/java/fr/ght1pc9kc/baywatch/common/domain/QueryContext.java @@ -4,23 +4,22 @@ import fr.ght1pc9kc.juery.api.PageRequest; import fr.ght1pc9kc.juery.api.Pagination; import lombok.Builder; -import lombok.Value; import lombok.With; import java.util.List; import static fr.ght1pc9kc.baywatch.common.api.model.EntitiesProperties.ID; -@Value @Builder -public final class QueryContext { - @Builder.Default - public final Pagination pagination = Pagination.ALL; - public final Criteria filter; - @With - public final String userId; - - public final List teamMates; +public record QueryContext( + Pagination pagination, + Criteria filter, + @With String userId, + List teamMates +) { + public QueryContext { + pagination = Pagination.ALL; + } public static QueryContext from(PageRequest pr) { return new QueryContext(pr.pagination(), pr.filter(), null, List.of()); diff --git a/sandside/src/main/java/fr/ght1pc9kc/baywatch/scraper/infra/adapters/ScrapingErrorPersistenceAdapter.java b/sandside/src/main/java/fr/ght1pc9kc/baywatch/scraper/infra/adapters/ScrapingErrorPersistenceAdapter.java index 842b9ff6..0fe74d6c 100644 --- a/sandside/src/main/java/fr/ght1pc9kc/baywatch/scraper/infra/adapters/ScrapingErrorPersistenceAdapter.java +++ b/sandside/src/main/java/fr/ght1pc9kc/baywatch/scraper/infra/adapters/ScrapingErrorPersistenceAdapter.java @@ -62,7 +62,7 @@ public Flux> persist(Collection> err @Override public Flux> list(QueryContext query) { - Condition conditions = query.filter.accept(JOOQ_CONDITION_VISITOR); + Condition conditions = query.filter().accept(JOOQ_CONDITION_VISITOR); SelectQuery select = dsl.selectQuery(FEEDS_ERRORS); select.addConditions(conditions); @@ -82,7 +82,7 @@ public Flux> list(QueryContext query) { @Override public Mono delete(QueryContext query) { - Condition conditions = query.filter.accept(JOOQ_CONDITION_VISITOR); + Condition conditions = query.filter().accept(JOOQ_CONDITION_VISITOR); DeleteQuery deleteQuery = dsl.deleteQuery(FEEDS_ERRORS); deleteQuery.addConditions(conditions); diff --git a/sandside/src/main/java/fr/ght1pc9kc/baywatch/security/infra/persistence/UserRepository.java b/sandside/src/main/java/fr/ght1pc9kc/baywatch/security/infra/persistence/UserRepository.java index bc855d10..553c9ad6 100644 --- a/sandside/src/main/java/fr/ght1pc9kc/baywatch/security/infra/persistence/UserRepository.java +++ b/sandside/src/main/java/fr/ght1pc9kc/baywatch/security/infra/persistence/UserRepository.java @@ -1,5 +1,6 @@ package fr.ght1pc9kc.baywatch.security.infra.persistence; +import fr.ght1pc9kc.baywatch.common.domain.QueryContext; import fr.ght1pc9kc.baywatch.common.infra.DatabaseQualifier; import fr.ght1pc9kc.baywatch.common.infra.mappers.PropertiesMappers; import fr.ght1pc9kc.baywatch.dsl.tables.records.UsersRecord; @@ -9,7 +10,6 @@ import fr.ght1pc9kc.baywatch.security.domain.exceptions.ConstraintViolationPersistenceException; import fr.ght1pc9kc.baywatch.security.domain.ports.UserPersistencePort; import fr.ght1pc9kc.baywatch.security.infra.adapters.UserMapper; -import fr.ght1pc9kc.baywatch.common.domain.QueryContext; import fr.ght1pc9kc.entity.api.Entity; import fr.ght1pc9kc.juery.jooq.filter.JooqConditionVisitor; import fr.ght1pc9kc.juery.jooq.pagination.JooqPagination; @@ -66,9 +66,9 @@ public Mono> get(String id) { @Override public Flux> list(QueryContext qCtx) { - Condition conditions = qCtx.filter.accept(JOOQ_CONDITION_VISITOR); + Condition conditions = qCtx.filter().accept(JOOQ_CONDITION_VISITOR); Select select = JooqPagination.apply( - qCtx.pagination, USER_PROPERTIES_MAPPING, + qCtx.pagination(), USER_PROPERTIES_MAPPING, dsl.select(USERS.fields()).select(DSL.groupConcat(USERS_ROLES.USRO_ROLE).as(USERS_ROLES.USRO_ROLE.getName())) .from(USERS) .leftJoin(USERS_ROLES).on(USERS_ROLES.USRO_USER_ID.eq(USERS.USER_ID)) @@ -96,7 +96,7 @@ public Flux> list() { @Override public Mono count(QueryContext qCtx) { - Condition conditions = qCtx.getFilter().accept(JOOQ_CONDITION_VISITOR); + Condition conditions = qCtx.filter().accept(JOOQ_CONDITION_VISITOR); return Mono.fromCallable(() -> dsl.fetchCount(dsl.selectFrom(USERS).where(conditions))) .subscribeOn(databaseScheduler); } diff --git a/sandside/src/main/java/fr/ght1pc9kc/baywatch/teams/infra/adapters/MembersPersistenceAdapter.java b/sandside/src/main/java/fr/ght1pc9kc/baywatch/teams/infra/adapters/MembersPersistenceAdapter.java index 084c3688..6754bb8d 100644 --- a/sandside/src/main/java/fr/ght1pc9kc/baywatch/teams/infra/adapters/MembersPersistenceAdapter.java +++ b/sandside/src/main/java/fr/ght1pc9kc/baywatch/teams/infra/adapters/MembersPersistenceAdapter.java @@ -1,11 +1,11 @@ package fr.ght1pc9kc.baywatch.teams.infra.adapters; +import fr.ght1pc9kc.baywatch.common.domain.QueryContext; import fr.ght1pc9kc.baywatch.common.infra.DatabaseQualifier; import fr.ght1pc9kc.baywatch.dsl.tables.records.TeamsMembersRecord; import fr.ght1pc9kc.baywatch.teams.api.model.TeamMember; import fr.ght1pc9kc.baywatch.teams.domain.ports.TeamMemberPersistencePort; import fr.ght1pc9kc.baywatch.teams.infra.mappers.TeamsMapper; -import fr.ght1pc9kc.baywatch.common.domain.QueryContext; import fr.ght1pc9kc.entity.api.Entity; import fr.ght1pc9kc.juery.jooq.filter.JooqConditionVisitor; import fr.ght1pc9kc.juery.jooq.pagination.JooqPagination; @@ -40,12 +40,12 @@ public class MembersPersistenceAdapter implements TeamMemberPersistencePort { @Override @SuppressWarnings("resource") public Flux> list(QueryContext qCtx) { - Condition conditions = qCtx.filter.accept(JOOQ_CONDITION_VISITOR); + Condition conditions = qCtx.filter().accept(JOOQ_CONDITION_VISITOR); if (qCtx.isScoped()) { - conditions = conditions.and(TEAMS_MEMBERS.TEME_USER_ID.eq(qCtx.getUserId())); + conditions = conditions.and(TEAMS_MEMBERS.TEME_USER_ID.eq(qCtx.userId())); } Select select = JooqPagination.apply( - qCtx.pagination, TEAMS_MEMBERS_PROPERTIES_MAPPING, + qCtx.pagination(), TEAMS_MEMBERS_PROPERTIES_MAPPING, dsl.selectFrom(TEAMS_MEMBERS) .where(conditions)); diff --git a/sandside/src/main/java/fr/ght1pc9kc/baywatch/teams/infra/adapters/TeamPersistenceAdapter.java b/sandside/src/main/java/fr/ght1pc9kc/baywatch/teams/infra/adapters/TeamPersistenceAdapter.java index 0a1d7e0f..9eb16d78 100644 --- a/sandside/src/main/java/fr/ght1pc9kc/baywatch/teams/infra/adapters/TeamPersistenceAdapter.java +++ b/sandside/src/main/java/fr/ght1pc9kc/baywatch/teams/infra/adapters/TeamPersistenceAdapter.java @@ -1,11 +1,11 @@ package fr.ght1pc9kc.baywatch.teams.infra.adapters; +import fr.ght1pc9kc.baywatch.common.domain.QueryContext; import fr.ght1pc9kc.baywatch.common.infra.DatabaseQualifier; import fr.ght1pc9kc.baywatch.dsl.tables.records.TeamsRecord; import fr.ght1pc9kc.baywatch.teams.api.model.Team; import fr.ght1pc9kc.baywatch.teams.domain.ports.TeamPersistencePort; import fr.ght1pc9kc.baywatch.teams.infra.mappers.TeamsMapper; -import fr.ght1pc9kc.baywatch.common.domain.QueryContext; import fr.ght1pc9kc.entity.api.Entity; import fr.ght1pc9kc.juery.jooq.filter.JooqConditionVisitor; import fr.ght1pc9kc.juery.jooq.pagination.JooqPagination; @@ -39,9 +39,9 @@ public class TeamPersistenceAdapter implements TeamPersistencePort { @Override @SuppressWarnings("resource") public Flux> list(QueryContext qCtx) { - Condition conditions = qCtx.filter.accept(JOOQ_CONDITION_VISITOR); + Condition conditions = qCtx.filter().accept(JOOQ_CONDITION_VISITOR); Select select = JooqPagination.apply( - qCtx.pagination, TEAMS_PROPERTIES_MAPPING, + qCtx.pagination(), TEAMS_PROPERTIES_MAPPING, dsl.selectFrom(TEAMS) .where(conditions)); @@ -61,7 +61,7 @@ public Flux> list(QueryContext qCtx) { @Override public Mono count(QueryContext qCtx) { - Condition conditions = qCtx.filter.accept(JOOQ_CONDITION_VISITOR); + Condition conditions = qCtx.filter().accept(JOOQ_CONDITION_VISITOR); return Mono.fromCallable(() -> dsl.fetchCount(dsl.selectFrom(TEAMS).where(conditions))) .subscribeOn(databaseScheduler); } diff --git a/sandside/src/main/java/fr/ght1pc9kc/baywatch/techwatch/domain/NewsServiceImpl.java b/sandside/src/main/java/fr/ght1pc9kc/baywatch/techwatch/domain/NewsServiceImpl.java index 9c4de957..d64e96f7 100644 --- a/sandside/src/main/java/fr/ght1pc9kc/baywatch/techwatch/domain/NewsServiceImpl.java +++ b/sandside/src/main/java/fr/ght1pc9kc/baywatch/techwatch/domain/NewsServiceImpl.java @@ -1,5 +1,6 @@ package fr.ght1pc9kc.baywatch.techwatch.domain; +import fr.ght1pc9kc.baywatch.common.domain.QueryContext; import fr.ght1pc9kc.baywatch.common.domain.exceptions.BadRequestCriteria; import fr.ght1pc9kc.baywatch.security.api.AuthenticationFacade; import fr.ght1pc9kc.baywatch.security.api.model.Role; @@ -11,7 +12,6 @@ import fr.ght1pc9kc.baywatch.techwatch.api.model.State; import fr.ght1pc9kc.baywatch.techwatch.api.model.WebFeed; import fr.ght1pc9kc.baywatch.techwatch.domain.filter.CriteriaModifierVisitor; -import fr.ght1pc9kc.baywatch.common.domain.QueryContext; import fr.ght1pc9kc.baywatch.techwatch.domain.ports.FeedPersistencePort; import fr.ght1pc9kc.baywatch.techwatch.domain.ports.NewsPersistencePort; import fr.ght1pc9kc.baywatch.techwatch.domain.ports.StatePersistencePort; @@ -90,13 +90,13 @@ public Mono count(PageRequest pageRequest) { } public Mono forgeAggregateQueryContext(QueryContext qCtx) { - List props = qCtx.filter.accept(new ListPropertiesCriteriaVisitor()); + List props = qCtx.filter().accept(new ListPropertiesCriteriaVisitor()); if (props.size() == 1 && ID.equals(props.getFirst())) { // Shortcut for get one News from id return Mono.just(qCtx); } - return teamServicePort.getTeamMates(qCtx.getUserId()) - .concatWith(Mono.just(qCtx.getUserId())) + return teamServicePort.getTeamMates(qCtx.userId()) + .concatWith(Mono.just(qCtx.userId())) .distinct() .collectList() .flatMap(teamMates -> { @@ -112,11 +112,11 @@ public Mono forgeAggregateQueryContext(QueryContext qCtx) { if (!contexts.getT1().isEmpty()) { filters = Criteria.or(filters, Criteria.property(NEWS_ID).in(contexts.getT1())); } - filters = Criteria.and(filters, qCtx.getFilter()); + filters = Criteria.and(filters, qCtx.filter()); return QueryContext.builder() - .pagination(qCtx.getPagination()) - .userId(qCtx.getUserId()) + .pagination(qCtx.pagination()) + .userId(qCtx.userId()) .teamMates(teamMates) .filter(filters) .build(); @@ -136,14 +136,14 @@ public Mono forgeAggregateQueryContext(QueryContext qCtx) { */ public Mono> getFeedFor(QueryContext qCtx, List props) { QueryContext feedQCtx = (props.contains(FEED_ID)) - ? QueryContext.all(qCtx.filter) - : QueryContext.all(qCtx.filter).withUserId(qCtx.userId); + ? QueryContext.all(qCtx.filter()) + : QueryContext.all(qCtx.filter()).withUserId(qCtx.userId()); return feedRepository.list(feedQCtx) .map(Entity::id) .collectList() .map(feeds -> { if (feedQCtx.isScoped()) { - feeds.add(feedQCtx.getUserId()); + feeds.add(feedQCtx.userId()); } return feeds; }); diff --git a/sandside/src/main/java/fr/ght1pc9kc/baywatch/techwatch/infra/persistence/FeedRepository.java b/sandside/src/main/java/fr/ght1pc9kc/baywatch/techwatch/infra/persistence/FeedRepository.java index 685e2e53..aa494980 100644 --- a/sandside/src/main/java/fr/ght1pc9kc/baywatch/techwatch/infra/persistence/FeedRepository.java +++ b/sandside/src/main/java/fr/ght1pc9kc/baywatch/techwatch/infra/persistence/FeedRepository.java @@ -1,12 +1,12 @@ package fr.ght1pc9kc.baywatch.techwatch.infra.persistence; +import fr.ght1pc9kc.baywatch.common.domain.QueryContext; import fr.ght1pc9kc.baywatch.common.infra.DatabaseQualifier; import fr.ght1pc9kc.baywatch.common.infra.adapters.PerformanceJooqListener; import fr.ght1pc9kc.baywatch.common.infra.mappers.BaywatchMapper; import fr.ght1pc9kc.baywatch.dsl.tables.records.FeedsRecord; import fr.ght1pc9kc.baywatch.dsl.tables.records.FeedsUsersRecord; import fr.ght1pc9kc.baywatch.techwatch.api.model.WebFeed; -import fr.ght1pc9kc.baywatch.common.domain.QueryContext; import fr.ght1pc9kc.baywatch.techwatch.domain.ports.FeedPersistencePort; import fr.ght1pc9kc.baywatch.techwatch.infra.model.FeedDeletedResult; import fr.ght1pc9kc.entity.api.Entity; @@ -199,7 +199,7 @@ public Flux> persistUserRelation(Collection> fee @Override public Mono delete(QueryContext qCtx) { - Condition feedsUsersConditions = qCtx.filter.accept(FeedConditionsVisitors.feedUserIdVisitor()); + Condition feedsUsersConditions = qCtx.filter().accept(FeedConditionsVisitors.feedUserIdVisitor()); final Optional deleteUserLinkQuery; if (DSL.noCondition().equals(feedsUsersConditions)) { deleteUserLinkQuery = Optional.empty(); @@ -207,12 +207,12 @@ public Mono delete(QueryContext qCtx) { var query = dsl.deleteQuery(FEEDS_USERS); query.addConditions(feedsUsersConditions); if (qCtx.isScoped()) { - query.addConditions(FEEDS_USERS.FEUS_USER_ID.eq(qCtx.userId)); + query.addConditions(FEEDS_USERS.FEUS_USER_ID.eq(qCtx.userId())); } deleteUserLinkQuery = Optional.of(query); } - Condition newsFeedConditions = qCtx.filter.accept(FeedConditionsVisitors.newsFeedIdVisitor()); + Condition newsFeedConditions = qCtx.filter().accept(FeedConditionsVisitors.newsFeedIdVisitor()); final Optional deleteNewsFeedQuery; if (DSL.noCondition().equals(newsFeedConditions)) { deleteNewsFeedQuery = Optional.empty(); @@ -222,7 +222,7 @@ public Mono delete(QueryContext qCtx) { dsl.select(FEEDS_USERS.FEUS_FEED_ID).from(FEEDS_USERS).where(feedsUsersConditions)))); } - Condition feedsConditions = qCtx.filter.accept(FeedConditionsVisitors.feedIdVisitor()); + Condition feedsConditions = qCtx.filter().accept(FeedConditionsVisitors.feedIdVisitor()); final Optional deleteFeedQuery; if (DSL.noCondition().equals(feedsConditions)) { deleteFeedQuery = Optional.empty(); @@ -243,7 +243,7 @@ public Mono delete(QueryContext qCtx) { } private Select buildSelectQuery(QueryContext qCtx) { - Condition conditions = qCtx.filter.accept(JOOQ_CONDITION_VISITOR); + Condition conditions = qCtx.filter().accept(JOOQ_CONDITION_VISITOR); SelectQuery select = dsl.selectQuery(); select.addSelect(FEEDS.fields()); select.addFrom(FEEDS); @@ -252,16 +252,16 @@ private Select buildSelectQuery(QueryContext qCtx) { if (qCtx.isScoped()) { select.addSelect(FEEDS_USERS.FEUS_TAGS, FEEDS_USERS.FEUS_FEED_NAME); select.addJoin(FEEDS_USERS, JoinType.JOIN, - FEEDS.FEED_ID.eq(FEEDS_USERS.FEUS_FEED_ID).and(FEEDS_USERS.FEUS_USER_ID.eq(qCtx.userId))); + FEEDS.FEED_ID.eq(FEEDS_USERS.FEUS_FEED_ID).and(FEEDS_USERS.FEUS_USER_ID.eq(qCtx.userId()))); } else { select.addSelect(DSL.groupConcat(FEEDS_USERS.FEUS_USER_ID).as(FEEDS_USERS.FEUS_USER_ID)); select.addJoin(FEEDS_USERS, JoinType.LEFT_OUTER_JOIN, FEEDS.FEED_ID.eq(FEEDS_USERS.FEUS_FEED_ID)); select.addGroupBy(FEEDS.fields()); - Condition havings = qCtx.filter.accept(FeedConditionsVisitors.feedUserHavingVisitor()); + Condition havings = qCtx.filter().accept(FeedConditionsVisitors.feedUserHavingVisitor()); select.addHaving(havings); } - return JooqPagination.apply(qCtx.pagination, FEEDS_PROPERTIES_MAPPING, select); + return JooqPagination.apply(qCtx.pagination(), FEEDS_PROPERTIES_MAPPING, select); } } diff --git a/sandside/src/main/java/fr/ght1pc9kc/baywatch/techwatch/infra/persistence/NewsRepository.java b/sandside/src/main/java/fr/ght1pc9kc/baywatch/techwatch/infra/persistence/NewsRepository.java index 694687ad..2224d93f 100644 --- a/sandside/src/main/java/fr/ght1pc9kc/baywatch/techwatch/infra/persistence/NewsRepository.java +++ b/sandside/src/main/java/fr/ght1pc9kc/baywatch/techwatch/infra/persistence/NewsRepository.java @@ -2,6 +2,7 @@ import com.machinezoo.noexception.Exceptions; import fr.ght1pc9kc.baywatch.common.api.model.EntitiesProperties; +import fr.ght1pc9kc.baywatch.common.domain.QueryContext; import fr.ght1pc9kc.baywatch.common.infra.DatabaseQualifier; import fr.ght1pc9kc.baywatch.common.infra.adapters.PerformanceJooqListener; import fr.ght1pc9kc.baywatch.common.infra.mappers.BaywatchMapper; @@ -9,7 +10,6 @@ import fr.ght1pc9kc.baywatch.dsl.tables.records.NewsRecord; import fr.ght1pc9kc.baywatch.techwatch.api.model.Flags; import fr.ght1pc9kc.baywatch.techwatch.api.model.News; -import fr.ght1pc9kc.baywatch.common.domain.QueryContext; import fr.ght1pc9kc.baywatch.techwatch.domain.ports.NewsPersistencePort; import fr.ght1pc9kc.juery.basic.common.lang3.StringUtils; import fr.ght1pc9kc.juery.basic.filter.ListPropertiesCriteriaVisitor; @@ -161,10 +161,10 @@ public Mono count(QueryContext qCtx) { } private static SelectQuery buildSelectQuery(Collection> fields, QueryContext qCtx, DSLContext dsl) { - Condition conditions = Optional.ofNullable(qCtx.filter).map(f -> f.accept(NEWS_CONDITION_VISITOR)) + Condition conditions = Optional.ofNullable(qCtx.filter()).map(f -> f.accept(NEWS_CONDITION_VISITOR)) .orElse(DSL.noCondition()); - List properties = Optional.ofNullable(qCtx.filter).map(f -> f.accept(LIST_PROPERTIES_VISITOR)) + List properties = Optional.ofNullable(qCtx.filter()).map(f -> f.accept(LIST_PROPERTIES_VISITOR)) .orElse(List.of()); SelectQuery select = dsl.selectQuery(); @@ -176,23 +176,23 @@ private static SelectQuery buildSelectQuery(Collection> fields, select.addJoin(NEWS_FEEDS, JoinType.LEFT_OUTER_JOIN, NEWS.NEWS_ID.eq(NEWS_FEEDS.NEFE_NEWS_ID)); select.addGroupBy(fields); - if (!StringUtils.isBlank(qCtx.userId)) { + if (!StringUtils.isBlank(qCtx.userId())) { select.addSelect(NEWS_STATE.NURS_STATE); select.addJoin(NEWS_STATE, JoinType.LEFT_OUTER_JOIN, - NEWS.NEWS_ID.eq(NEWS_STATE.NURS_NEWS_ID).and(NEWS_STATE.NURS_USER_ID.eq(qCtx.userId))); + NEWS.NEWS_ID.eq(NEWS_STATE.NURS_NEWS_ID).and(NEWS_STATE.NURS_USER_ID.eq(qCtx.userId()))); if (properties.contains(EntitiesProperties.POPULAR)) { ArrayList popularJoinConditions = new ArrayList<>(); popularJoinConditions.add(NEWS.NEWS_ID.eq(POPULAR.NURS_NEWS_ID)); popularJoinConditions.add(DSL.coalesce(POPULAR.NURS_STATE, Flags.NONE).bitAnd(Flags.SHARED).eq(Flags.SHARED)); - if (!qCtx.teamMates.isEmpty()) { - popularJoinConditions.add(POPULAR.NURS_USER_ID.in(qCtx.teamMates)); + if (!qCtx.teamMates().isEmpty()) { + popularJoinConditions.add(POPULAR.NURS_USER_ID.in(qCtx.teamMates())); } select.addJoin(POPULAR, JoinType.LEFT_OUTER_JOIN, DSL.condition(Operator.AND, popularJoinConditions)); } } - SelectQuery paginateSelect = (SelectQuery) JooqPagination.apply(qCtx.pagination, NEWS_PROPERTIES_MAPPING, select); + SelectQuery paginateSelect = (SelectQuery) JooqPagination.apply(qCtx.pagination(), NEWS_PROPERTIES_MAPPING, select); paginateSelect.addOrderBy(NEWS.NEWS_ID); // This avoids random order for records with same value in ordered fields return paginateSelect; } diff --git a/sandside/src/main/java/fr/ght1pc9kc/baywatch/techwatch/infra/persistence/StateRepository.java b/sandside/src/main/java/fr/ght1pc9kc/baywatch/techwatch/infra/persistence/StateRepository.java index 8aee7cb7..e64f14e0 100644 --- a/sandside/src/main/java/fr/ght1pc9kc/baywatch/techwatch/infra/persistence/StateRepository.java +++ b/sandside/src/main/java/fr/ght1pc9kc/baywatch/techwatch/infra/persistence/StateRepository.java @@ -1,12 +1,12 @@ package fr.ght1pc9kc.baywatch.techwatch.infra.persistence; import fr.ght1pc9kc.baywatch.common.api.DefaultMeta; +import fr.ght1pc9kc.baywatch.common.domain.QueryContext; import fr.ght1pc9kc.baywatch.common.infra.DatabaseQualifier; import fr.ght1pc9kc.baywatch.common.infra.mappers.PropertiesMappers; import fr.ght1pc9kc.baywatch.dsl.tables.records.NewsUserStateRecord; import fr.ght1pc9kc.baywatch.techwatch.api.model.Flags; import fr.ght1pc9kc.baywatch.techwatch.api.model.State; -import fr.ght1pc9kc.baywatch.common.domain.QueryContext; import fr.ght1pc9kc.baywatch.techwatch.domain.ports.StatePersistencePort; import fr.ght1pc9kc.entity.api.Entity; import fr.ght1pc9kc.juery.api.Criteria; @@ -45,9 +45,9 @@ public Mono> get(QueryContext queryContext) { @Override public Flux> list(QueryContext queryContext) { var query = dsl.selectQuery(NEWS_USER_STATE); - query.addConditions(queryContext.getFilter().accept(STATE_CONDITION_VISITOR)); + query.addConditions(queryContext.filter().accept(STATE_CONDITION_VISITOR)); if (queryContext.isScoped()) { - query.addConditions(NEWS_USER_STATE.NURS_USER_ID.eq(queryContext.getUserId())); + query.addConditions(NEWS_USER_STATE.NURS_USER_ID.eq(queryContext.userId())); } return Flux.create(sink -> { Cursor cursor = query.fetchLazy();