Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PageInfo泛型转换✒️ pull#477 #553

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dahuoyzs
Copy link

@dahuoyzs dahuoyzs commented Sep 6, 2020

pull#477

实例

    public Result<PageInfo<KaArticleResult>> page(KaArticleQuery kaArticleQuery) {
        //分页查询
        PageHelper.startPage(kaArticleQuery.getPageNum(),kaArticleQuery.getPageSize());
        //条件查询
        QueryWrapper<KaArticle> wrapper = kaArticleQuery.buildQueryWrapper();
        List<KaArticle> kaArticles = kaArticleMapper.selectList(wrapper);
        PageInfo<KaArticleResult> kaArticleResults = PageInfoUtil.convert(PageInfo.of(kaArticles), KaArticleResult.class);
        kaArticleResults.getList().forEach(kaArticleResult -> {
            //TODO 基础信息返回值填充
        });

        return Result.success(kaArticleResults);
    }

其中

PageInfo<KaArticleResult> kaArticleResults = PageInfoUtil.convert(PageInfo.of(kaArticles), KaArticleResult.class);

这一行的确是有点 难受

可简化为

PageInfo<KaArticleResult> kaArticleResults = PageInfo.convert(PageInfo.of(kaArticles),KaArticleResult.class);

或者

PageInfo<KaArticleResult> kaArticleResults = PageInfo.of(kaArticles).convert(KaArticleResult.class);

这样方便Web环境中DTO对象的快速转换。

@abel533
Copy link
Collaborator

abel533 commented Jun 6, 2021

感谢PR,抱歉这么晚才回复。

由于涉及到了属性的复制,这块考虑到性能可能有很多种实现,暂时先不合并当前PR。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants