This is an automated email from the ASF dual-hosted git repository.
liuhongyu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shenyu.git
The following commit(s) were added to refs/heads/master by this push:
new 3c615de383 [Fix] the selector and rule pagination non-functional
(#6239) (#6243)
3c615de383 is described below
commit 3c615de383334a8fc574a84089297e52873108c5
Author: VampireAchao <[email protected]>
AuthorDate: Tue Dec 2 19:14:00 2025 +0800
[Fix] the selector and rule pagination non-functional (#6239) (#6243)
* fix: the selector and rule pagination non-functional (#6239)
* code style optimization
* Update
shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/SelectorServiceImpl.java
Co-authored-by: Copilot <[email protected]>
* Update
shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/RuleServiceImpl.java
Co-authored-by: Copilot <[email protected]>
* Update
shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/RuleServiceImpl.java
Co-authored-by: Copilot <[email protected]>
* Update
shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/SelectorServiceImpl.java
Co-authored-by: Copilot <[email protected]>
* code style optimization
---------
Co-authored-by: aias00 <[email protected]>
Co-authored-by: Copilot <[email protected]>
---
.../shenyu/admin/service/impl/RuleServiceImpl.java | 19 +++++++++++++++++++
.../admin/service/impl/SelectorServiceImpl.java | 20 ++++++++++++++++++++
2 files changed, 39 insertions(+)
diff --git
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/RuleServiceImpl.java
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/RuleServiceImpl.java
index f609f83919..0e903a943b 100644
---
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/RuleServiceImpl.java
+++
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/RuleServiceImpl.java
@@ -17,6 +17,9 @@
package org.apache.shenyu.admin.service.impl;
+import com.github.pagehelper.Page;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
import com.google.common.collect.Lists;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
@@ -35,6 +38,7 @@ import org.apache.shenyu.admin.model.entity.SelectorDO;
import org.apache.shenyu.admin.model.event.rule.RuleCreatedEvent;
import org.apache.shenyu.admin.model.event.selector.BatchSelectorDeletedEvent;
import org.apache.shenyu.admin.model.page.CommonPager;
+import org.apache.shenyu.admin.model.page.PageCondition;
import org.apache.shenyu.admin.model.page.PageResultUtils;
import org.apache.shenyu.admin.model.query.RuleConditionQuery;
import org.apache.shenyu.admin.model.query.RuleQuery;
@@ -56,6 +60,7 @@ import org.apache.shenyu.common.utils.JsonUtils;
import org.apache.shenyu.common.utils.ListUtil;
import org.apache.shenyu.common.utils.UUIDUtils;
import org.springframework.context.event.EventListener;
+import org.springframework.data.util.CastUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -107,6 +112,20 @@ public class RuleServiceImpl implements RuleService {
}
}
+ @Override
+ public PageInfo<RuleVO> searchByPage(final
PageCondition<RuleQueryCondition> pageCondition) {
+ RuleQueryCondition condition = pageCondition.getCondition();
+ doConditionPreProcessing(condition);
+ PageHelper.startPage(pageCondition.getPageNum(),
pageCondition.getPageSize());
+ condition.init();
+ final Page<RuleDO> doList =
CastUtils.cast(ruleMapper.selectByCondition(condition));
+ PageInfo<RuleVO> doPageInfo = doList.toPageInfo(RuleVO::buildRuleVO);
+ for (RuleVO rule : doPageInfo.getList()) {
+
rule.setMatchModeName(MatchModeEnum.getMatchModeByCode(rule.getMatchMode()));
+ }
+ return doPageInfo;
+ }
+
@Override
public List<RuleVO> searchByCondition(final RuleQueryCondition condition) {
condition.init();
diff --git
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/SelectorServiceImpl.java
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/SelectorServiceImpl.java
index 13e04bef54..f44132f4de 100644
---
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/SelectorServiceImpl.java
+++
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/SelectorServiceImpl.java
@@ -17,6 +17,9 @@
package org.apache.shenyu.admin.service.impl;
+import com.github.pagehelper.Page;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
import com.google.common.collect.Lists;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
@@ -48,6 +51,7 @@ import org.apache.shenyu.admin.model.entity.SelectorDO;
import
org.apache.shenyu.admin.model.event.plugin.BatchNamespacePluginDeletedEvent;
import org.apache.shenyu.admin.model.event.selector.SelectorCreatedEvent;
import org.apache.shenyu.admin.model.page.CommonPager;
+import org.apache.shenyu.admin.model.page.PageCondition;
import org.apache.shenyu.admin.model.page.PageResultUtils;
import org.apache.shenyu.admin.model.query.SelectorConditionQuery;
import org.apache.shenyu.admin.model.query.SelectorQuery;
@@ -80,6 +84,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.event.EventListener;
+import org.springframework.data.util.CastUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -153,6 +158,21 @@ public class SelectorServiceImpl implements
SelectorService {
}
}
+ @Override
+ public PageInfo<SelectorVO> searchByPage(final
PageCondition<SelectorQueryCondition> pageCondition) {
+ SelectorQueryCondition condition = pageCondition.getCondition();
+ doConditionPreProcessing(condition);
+ PageHelper.startPage(pageCondition.getPageNum(),
pageCondition.getPageSize());
+ condition.init();
+ final Page<SelectorDO> doList =
CastUtils.cast(selectorMapper.selectByCondition(condition));
+ PageInfo<SelectorVO> doPageInfo =
doList.toPageInfo(SelectorVO::buildSelectorVO);
+ for (SelectorVO selector : doPageInfo.getList()) {
+
selector.setMatchModeName(MatchModeEnum.getMatchModeByCode(selector.getMatchMode()));
+
selector.setTypeName(SelectorTypeEnum.getSelectorTypeByCode(selector.getType()));
+ }
+ return doPageInfo;
+ }
+
@Override
public List<SelectorVO> searchByCondition(final SelectorQueryCondition
condition) {
condition.init();