Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
阅读了PageInfo泛型转换✒️ pull#477 #553的相关内容,自己在使用Mybatis-PageHelper时也遇到同样的问题,咨询了大家的解决方案,均是自己在项目中实现一个转换工具类,这是我之前使用的转换工具类
但本着使用一个插件时,需要配套提供的配置及自建工具类尽可能少的想法,又考虑您之前提到的”涉及属性转换,考虑性能问题“及”对分页插件的强依赖问题“等的担忧,最终建议使用这样的方式,即将转换的具体实现方式交由用户自己实现,借鉴
Page
类的toPageInfo()
方法,在PageInfo
类中新增类似的方法,如下这里的方法参数中使用的
Function
接口使用Page
类中的,目的亦是不引入对jdk1.8的强依赖;此时,我在控制器中使用时的代码由
简化成
此时,
Order
到OrderDTO
的转换由用户自己实现,但用户可以不再需要维护一个用来做数据转换的工具类,减轻了使用负担。希望能够得到采纳。