You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shenyu.apache.org by "VampireAchao (via GitHub)" <gi...@apache.org> on 2025/12/01 09:56:34 UTC

[PR] [Fix] the selector and rule pagination non-functional (#6239) [shenyu]

VampireAchao opened a new pull request, #6243:
URL: https://github.com/apache/shenyu/pull/6243

   <!-- Describe your PR here; e.g. Fixes #issueNo -->
   Fixes #6239
   <!--
   Thank you for proposing a pull request. This template will guide you through the essential steps necessary for a pull request.
   -->
   Make sure that:
   
   - [x] You have read the [contribution guidelines](https://shenyu.apache.org/community/contributor-guide).
   - [x] You submit test cases (unit or integration tests) that back your changes.
   - [x] Your local test passed `./mvnw clean install -Dmaven.javadoc.skip=true`.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shenyu.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Fix] the selector and rule pagination non-functional (#6239) [shenyu]

Posted by "Aias00 (via GitHub)" <gi...@apache.org>.
Aias00 commented on PR #6243:
URL: https://github.com/apache/shenyu/pull/6243#issuecomment-3600850508

   @VampireAchao hi, i applyed some copilot`s suggestions, which caused checkstyle errors. could u pls fix them?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shenyu.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Fix] the selector and rule pagination non-functional (#6239) [shenyu]

Posted by "Aias00 (via GitHub)" <gi...@apache.org>.
Aias00 merged PR #6243:
URL: https://github.com/apache/shenyu/pull/6243


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shenyu.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Fix] the selector and rule pagination non-functional (#6239) [shenyu]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #6243:
URL: https://github.com/apache/shenyu/pull/6243#discussion_r2576515881


##########
shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/SelectorServiceImpl.java:
##########
@@ -153,6 +157,21 @@ public void doConditionPreProcessing(final SelectorQueryCondition condition) {
         }
     }
 
+    @Override
+    public PageInfo<SelectorVO> searchByPage(final PageCondition<SelectorQueryCondition> pageCondition) {
+        doConditionPreProcessing(pageCondition.getCondition());
+        PageHelper.startPage(pageCondition.getPageNum(), pageCondition.getPageSize());
+        SelectorQueryCondition condition = pageCondition.getCondition();

Review Comment:
   The condition is retrieved twice from pageCondition: once on line 162 for preprocessing and again on line 164. This can be simplified by extracting the condition once at the beginning of the method, which would improve readability and avoid redundant method calls.
   ```suggestion
           SelectorQueryCondition condition = pageCondition.getCondition();
           doConditionPreProcessing(condition);
           PageHelper.startPage(pageCondition.getPageNum(), pageCondition.getPageSize());
   ```



##########
shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/RuleServiceImpl.java:
##########
@@ -107,6 +111,20 @@ public void doConditionPreProcessing(final RuleQueryCondition condition) {
         }
     }
 
+    @Override
+    public PageInfo<RuleVO> searchByPage(final PageCondition<RuleQueryCondition> pageCondition) {
+        doConditionPreProcessing(pageCondition.getCondition());
+        PageHelper.startPage(pageCondition.getPageNum(), pageCondition.getPageSize());
+        RuleQueryCondition condition = pageCondition.getCondition();

Review Comment:
   The condition is retrieved twice from pageCondition: once on line 116 for preprocessing and again on line 118. This can be simplified by extracting the condition once at the beginning of the method, which would improve readability and avoid redundant method calls.
   ```suggestion
           RuleQueryCondition condition = pageCondition.getCondition();
           doConditionPreProcessing(condition);
           PageHelper.startPage(pageCondition.getPageNum(), pageCondition.getPageSize());
   ```



##########
shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/RuleServiceImpl.java:
##########
@@ -107,6 +111,20 @@ public void doConditionPreProcessing(final RuleQueryCondition condition) {
         }
     }
 
+    @Override
+    public PageInfo<RuleVO> searchByPage(final PageCondition<RuleQueryCondition> pageCondition) {

Review Comment:
   The new searchByPage method lacks test coverage. The existing RuleServiceTest.java file does not include tests for this new pagination method. Consider adding tests to verify the pagination behavior, including proper PageHelper usage and VO enrichment.



##########
shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/SelectorServiceImpl.java:
##########
@@ -153,6 +157,21 @@ public void doConditionPreProcessing(final SelectorQueryCondition condition) {
         }
     }
 
+    @Override
+    public PageInfo<SelectorVO> searchByPage(final PageCondition<SelectorQueryCondition> pageCondition) {
+        doConditionPreProcessing(pageCondition.getCondition());
+        PageHelper.startPage(pageCondition.getPageNum(), pageCondition.getPageSize());
+        SelectorQueryCondition condition = pageCondition.getCondition();
+        condition.init();
+        final Page<SelectorDO> page = (Page<SelectorDO>) selectorMapper.selectByCondition(condition);
+        PageInfo<SelectorVO> pageInfo = page.toPageInfo(SelectorVO::buildSelectorVO);
+        for (SelectorVO selector : pageInfo.getList()) {
+            selector.setMatchModeName(MatchModeEnum.getMatchModeByCode(selector.getMatchMode()));
+            selector.setTypeName(SelectorTypeEnum.getSelectorTypeByCode(selector.getType()));
+        }

Review Comment:
   [List<SelectorDO>](1) is cast to the concrete type [Page<SelectorDO>](2), losing abstraction.
   ```suggestion
           final List<SelectorDO> doList = selectorMapper.selectByCondition(condition);
           PageInfo<SelectorDO> doPageInfo = new PageInfo<>(doList);
           List<SelectorVO> voList = doPageInfo.getList().stream()
                   .map(SelectorVO::buildSelectorVO)
                   .collect(Collectors.toList());
           for (SelectorVO selector : voList) {
               selector.setMatchModeName(MatchModeEnum.getMatchModeByCode(selector.getMatchMode()));
               selector.setTypeName(SelectorTypeEnum.getSelectorTypeByCode(selector.getType()));
           }
           PageInfo<SelectorVO> pageInfo = new PageInfo<>();
           pageInfo.setPageNum(doPageInfo.getPageNum());
           pageInfo.setPageSize(doPageInfo.getPageSize());
           pageInfo.setTotal(doPageInfo.getTotal());
           pageInfo.setPages(doPageInfo.getPages());
           pageInfo.setList(voList);
   ```



##########
shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/SelectorServiceImpl.java:
##########
@@ -153,6 +157,21 @@ public void doConditionPreProcessing(final SelectorQueryCondition condition) {
         }
     }
 
+    @Override
+    public PageInfo<SelectorVO> searchByPage(final PageCondition<SelectorQueryCondition> pageCondition) {

Review Comment:
   The new searchByPage method lacks test coverage. The existing SelectorServiceTest.java file does not include tests for this new pagination method. Consider adding tests to verify the pagination behavior, including proper PageHelper usage and VO enrichment.



##########
shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/RuleServiceImpl.java:
##########
@@ -107,6 +111,20 @@ public void doConditionPreProcessing(final RuleQueryCondition condition) {
         }
     }
 
+    @Override
+    public PageInfo<RuleVO> searchByPage(final PageCondition<RuleQueryCondition> pageCondition) {
+        doConditionPreProcessing(pageCondition.getCondition());
+        PageHelper.startPage(pageCondition.getPageNum(), pageCondition.getPageSize());
+        RuleQueryCondition condition = pageCondition.getCondition();
+        condition.init();
+        final Page<RuleDO> ruleDOList = (Page<RuleDO>) ruleMapper.selectByCondition(condition);
+        PageInfo<RuleVO> rules = ruleDOList.toPageInfo(RuleVO::buildRuleVO);
+        for (RuleVO rule : rules.getList()) {
+            rule.setMatchModeName(MatchModeEnum.getMatchModeByCode(rule.getMatchMode()));
+        }

Review Comment:
   [List<RuleDO>](1) is cast to the concrete type [Page<RuleDO>](2), losing abstraction.
   ```suggestion
           final List<RuleDO> ruleDOList = ruleMapper.selectByCondition(condition);
           List<RuleVO> ruleVOList = ruleDOList.stream().map(RuleVO::buildRuleVO).collect(Collectors.toList());
           for (RuleVO rule : ruleVOList) {
               rule.setMatchModeName(MatchModeEnum.getMatchModeByCode(rule.getMatchMode()));
           }
           PageInfo<RuleVO> rules = new PageInfo<>(ruleVOList);
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shenyu.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Fix] the selector and rule pagination non-functional (#6239) [shenyu]

Posted by "VampireAchao (via GitHub)" <gi...@apache.org>.
VampireAchao commented on PR #6243:
URL: https://github.com/apache/shenyu/pull/6243#issuecomment-3595723225

   link:https://github.com/apache/shenyu/pull/6242#issuecomment-3595703332


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shenyu.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Fix] the selector and rule pagination non-functional (#6239) [shenyu]

Posted by "Aias00 (via GitHub)" <gi...@apache.org>.
Aias00 commented on code in PR #6243:
URL: https://github.com/apache/shenyu/pull/6243#discussion_r2580175624


##########
shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/SelectorServiceImpl.java:
##########
@@ -153,6 +157,21 @@ public void doConditionPreProcessing(final SelectorQueryCondition condition) {
         }
     }
 
+    @Override
+    public PageInfo<SelectorVO> searchByPage(final PageCondition<SelectorQueryCondition> pageCondition) {
+        doConditionPreProcessing(pageCondition.getCondition());
+        PageHelper.startPage(pageCondition.getPageNum(), pageCondition.getPageSize());
+        SelectorQueryCondition condition = pageCondition.getCondition();
+        condition.init();
+        final Page<SelectorDO> page = (Page<SelectorDO>) selectorMapper.selectByCondition(condition);
+        PageInfo<SelectorVO> pageInfo = page.toPageInfo(SelectorVO::buildSelectorVO);
+        for (SelectorVO selector : pageInfo.getList()) {
+            selector.setMatchModeName(MatchModeEnum.getMatchModeByCode(selector.getMatchMode()));
+            selector.setTypeName(SelectorTypeEnum.getSelectorTypeByCode(selector.getType()));
+        }

Review Comment:
   Error:  /home/runner/work/shenyu/shenyu/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/SelectorServiceImpl.java:20:8: Unused import - com.github.pagehelper.Page. [UnusedImports]
   Error:  /home/runner/work/shenyu/shenyu/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/RuleServiceImpl.java:20:8: Unused import - com.github.pagehelper.Page. [UnusedImports]
   Audit done.
   [shenyu-admin] [INFO] There are 2 errors reported by Checkstyle 9.3 with /script/shenyu_checkstyle.xml ruleset.
   Error: -admin] [ERROR] src/main/java/org/apache/shenyu/admin/service/impl/SelectorServiceImpl.java:[20,8] (imports) UnusedImports: Unused import - com.github.pagehelper.Page.
   Error: -admin] [ERROR] src/main/java/org/apache/shenyu/admin/service/impl/RuleServiceImpl.java:[20,8] (imports) UnusedImports: Unused import - com.github.pagehelper.Page.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shenyu.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Fix] the selector and rule pagination non-functional (#6239) [shenyu]

Posted by "VampireAchao (via GitHub)" <gi...@apache.org>.
VampireAchao commented on PR #6243:
URL: https://github.com/apache/shenyu/pull/6243#issuecomment-3601347595

   > @VampireAchao hi, i applyed some copilot`s suggestions, which caused checkstyle errors. could u pls fix them?
   
   
   
   > @VampireAchao hi, i applyed some copilot`s suggestions, which caused checkstyle errors. could u pls fix them?
   
   done


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shenyu.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org