Search in sources :

Example 6 with Page

use of io.nuls.core.dto.Page in project nuls by nuls-io.

the class BlockDaoImpl method getBlockHeaderList.

@Override
public Page<BlockHeaderPo> getBlockHeaderList(int pageNumber, int pageSize) {
    PageHelper.startPage(pageNumber, pageSize);
    PageHelper.orderBy("height desc");
    List<BlockHeaderPo> blockList = getMapper().selectList(new Searchable());
    PageInfo<BlockHeaderPo> pageInfo = new PageInfo<>(blockList);
    Page<BlockHeaderPo> page = new Page<>();
    page.setTotal(pageInfo.getTotal());
    page.setPageNumber(pageNumber);
    page.setPageSize(pageSize);
    page.setPages(pageInfo.getPages());
    page.setList(blockList);
    return page;
}
Also used : PageInfo(com.github.pagehelper.PageInfo) Page(io.nuls.core.dto.Page) Searchable(io.nuls.db.dao.impl.mybatis.util.Searchable) BlockHeaderPo(io.nuls.db.entity.BlockHeaderPo)

Example 7 with Page

use of io.nuls.core.dto.Page in project nuls by nuls-io.

the class TransactionDaoImpl method getTxs.

@Override
public Page<TransactionPo> getTxs(Long blockHeight, int type, int pageNum, int pageSize) {
    Searchable searchable = new Searchable();
    if (type != 0) {
        searchable.addCondition("type", SearchOperator.eq, type);
    }
    if (blockHeight != null) {
        searchable.addCondition("block_height", SearchOperator.eq, blockHeight);
    }
    long count = getMapper().selectCount(searchable);
    if (count < (pageNum - 1) * pageSize) {
        return new Page<>(pageNum, pageSize);
    }
    PageHelper.orderBy("a.create_time desc");
    if (pageNum > 0 && pageSize > 0) {
        PageHelper.startPage(pageNum, pageSize);
    }
    List<String> txHashList = getMapper().selectTxHashList(searchable);
    searchable = new Searchable();
    searchable.addCondition("a.hash", SearchOperator.in, txHashList);
    PageHelper.orderBy("a.create_time desc,b.in_index asc,c.out_index asc");
    List<TransactionPo> poList = getMapper().selectList(searchable);
    Page<TransactionPo> page = new Page<>();
    if (pageSize > 0) {
        page.setPageNumber(pageNum);
        page.setPageSize(pageSize);
    } else {
        page.setPageNumber(1);
        page.setPageSize((int) count);
    }
    page.setTotal(count);
    page.setList(poList);
    return page;
}
Also used : Page(io.nuls.core.dto.Page) TransactionPo(io.nuls.db.entity.TransactionPo) Searchable(io.nuls.db.dao.impl.mybatis.util.Searchable)

Aggregations

Page (io.nuls.core.dto.Page)7 BlockHeaderPo (io.nuls.db.entity.BlockHeaderPo)4 ArrayList (java.util.ArrayList)4 Searchable (io.nuls.db.dao.impl.mybatis.util.Searchable)3 PageInfo (com.github.pagehelper.PageInfo)2 TransactionPo (io.nuls.db.entity.TransactionPo)2 BlockDto (io.nuls.rpc.entity.BlockDto)2 Transaction (io.nuls.core.chain.entity.Transaction)1 NulsRuntimeException (io.nuls.core.exception.NulsRuntimeException)1 AbstractCoinTransaction (io.nuls.ledger.entity.tx.AbstractCoinTransaction)1 LockNulsTransaction (io.nuls.ledger.entity.tx.LockNulsTransaction)1 TransferTransaction (io.nuls.ledger.entity.tx.TransferTransaction)1 RpcResult (io.nuls.rpc.entity.RpcResult)1 TransactionDto (io.nuls.rpc.entity.TransactionDto)1 List (java.util.List)1