Git Product home page Git Product logo

Comments (3)

zjfplayer avatar zjfplayer commented on June 24, 2024

是转化过后,所有属性都要手动赋值吗?

from mybatis-pagehelper.

abel533 avatar abel533 commented on June 24, 2024

大概率是你转换方法丢失了分页信息,可以考虑用下面的方法:

/**
     * 数据对象转换
     *
     * @param function 用以转换数据对象的函数
     * @param <E>      目标类型
     * @return 转换了对象类型的包装结果
     */
    public <E> PageInfo<E> convert(Page.Function<T, E> function) {
        List<E> list = new ArrayList<E>(this.list.size());
        for (T t : this.list) {
            list.add(function.apply(t));
        }
        PageInfo<E> newPageInfo = new PageInfo<>(list);
        newPageInfo.setPageNum(this.pageNum);
        newPageInfo.setPageSize(this.pageSize);
        newPageInfo.setSize(this.size);
        newPageInfo.setStartRow(this.startRow);
        newPageInfo.setEndRow(this.endRow);
        newPageInfo.setTotal(this.total);
        newPageInfo.setPages(this.pages);
        newPageInfo.setPrePage(this.prePage);
        newPageInfo.setNextPage(this.nextPage);
        newPageInfo.setIsFirstPage(this.isFirstPage);
        newPageInfo.setIsLastPage(this.isLastPage);
        newPageInfo.setHasPreviousPage(this.hasPreviousPage);
        newPageInfo.setHasNextPage(this.hasNextPage);
        newPageInfo.setNavigatePages(this.navigatePages);
        newPageInfo.setNavigateFirstPage(this.navigateFirstPage);
        newPageInfo.setNavigateLastPage(this.navigateLastPage);
        newPageInfo.setNavigatepageNums(this.navigatepageNums);
        return newPageInfo;
    }

new PageInfo(list).convert(转换Fun);

from mybatis-pagehelper.

zjfplayer avatar zjfplayer commented on June 24, 2024

我换了种使用方式就行了:

PageInfo page=new PageInfo(dbList);
page.setList(convertedList);

from mybatis-pagehelper.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.