Search in sources :

Example 16 with Searchable

use of io.nuls.db.dao.impl.mybatis.util.Searchable in project nuls by nuls-io.

the class NodeDaoImpl method saveChange.

@Override
@DbSession
public void saveChange(NodePo po) {
    try {
        Searchable searchable = new Searchable();
        searchable.addCondition("id", SearchOperator.eq, po.getId());
        if (getMapper().selectCount(searchable) > 0) {
            getMapper().updateByPrimaryKey(po);
        } else {
            getMapper().insert(po);
        }
    } catch (Exception e) {
        Log.error(e);
    }
}
Also used : Searchable(io.nuls.db.dao.impl.mybatis.util.Searchable) DbSession(io.nuls.db.transactional.annotation.DbSession)

Example 17 with Searchable

use of io.nuls.db.dao.impl.mybatis.util.Searchable in project nuls by nuls-io.

the class TransactionLocalDaoImpl method getTxs.

@Override
public List<TransactionLocalPo> getTxs(Long startHeight, Long endHeight) {
    Searchable searchable = new Searchable();
    searchable.addCondition("block_height", SearchOperator.gte, startHeight);
    searchable.addCondition("block_height", SearchOperator.lte, endHeight);
    PageHelper.orderBy("block_height asc, create_time asc");
    return getMapper().selectList(searchable);
}
Also used : Searchable(io.nuls.db.dao.impl.mybatis.util.Searchable)

Example 18 with Searchable

use of io.nuls.db.dao.impl.mybatis.util.Searchable in project nuls by nuls-io.

the class UtxoOutputDaoImpl method getLockUtxo.

@Override
public List<UtxoOutputPo> getLockUtxo(String address, Long beginTime, Integer pageNumber, Integer pageSize) {
    Searchable searchable = new Searchable();
    searchable.addCondition("b.address", SearchOperator.eq, address);
    searchable.addCondition("b.lock_time", SearchOperator.gt, beginTime);
    PageHelper.startPage(pageNumber, pageSize);
    return getMapper().selectAccountOutput(searchable);
}
Also used : Searchable(io.nuls.db.dao.impl.mybatis.util.Searchable)

Example 19 with Searchable

use of io.nuls.db.dao.impl.mybatis.util.Searchable in project nuls by nuls-io.

the class TransactionDaoImpl method getTxs.

@Override
public List<TransactionPo> getTxs(Long blockHeight) {
    Searchable searchable = new Searchable();
    searchable.addCondition("block_height", SearchOperator.eq, blockHeight);
    PageHelper.orderBy("tx_index,b.in_index asc,c.out_index asc");
    return getMapper().selectList(searchable);
}
Also used : Searchable(io.nuls.db.dao.impl.mybatis.util.Searchable)

Example 20 with Searchable

use of io.nuls.db.dao.impl.mybatis.util.Searchable 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

Searchable (io.nuls.db.dao.impl.mybatis.util.Searchable)25 Page (io.nuls.core.dto.Page)3 PageInfo (com.github.pagehelper.PageInfo)2 BlockHeaderPo (io.nuls.db.entity.BlockHeaderPo)2 TransactionPo (io.nuls.db.entity.TransactionPo)2 NodePo (io.nuls.db.entity.NodePo)1 TransactionLocalPo (io.nuls.db.entity.TransactionLocalPo)1 DbSession (io.nuls.db.transactional.annotation.DbSession)1