Commit 4824a339 authored by jianhua.zhang's avatar jianhua.zhang

新增接口获取区块最新高度

parent 9732a72c
......@@ -3,19 +3,13 @@ package com.wuban.tron.explore.controller.v1;
import com.github.pagehelper.PageInfo;
import com.wuban.tron.explore.constant.Constant;
import com.wuban.tron.explore.constant.HomeSearchTypeEnum;
import com.wuban.tron.explore.entity.Address;
import com.wuban.tron.explore.entity.BlockDayCensus;
import com.wuban.tron.explore.entity.BlockHeader;
import com.wuban.tron.explore.entity.Transaction;
import com.wuban.tron.explore.entity.*;
import com.wuban.tron.explore.entity.example.AddressExample;
import com.wuban.tron.explore.entity.example.BlockDayCensusExample;
import com.wuban.tron.explore.entity.example.BlockHeaderExample;
import com.wuban.tron.explore.entity.example.TransactionExample;
import com.wuban.tron.explore.param.response.*;
import com.wuban.tron.explore.service.AddressService;
import com.wuban.tron.explore.service.BlockDayCensusService;
import com.wuban.tron.explore.service.BlockHeaderService;
import com.wuban.tron.explore.service.TransactionService;
import com.wuban.tron.explore.service.*;
import com.wuban.tron.explore.util.ApiResponse;
import com.wuban.tron.explore.util.DateUtil;
import com.wuban.tron.explore.util.ResponseKit;
......@@ -52,6 +46,8 @@ public class TransactionControllerV1 {
private final AddressService addressService;
private final LastBlockService lastBlockService;
/**
* 首页 - 搜索
*
......@@ -118,7 +114,7 @@ public class TransactionControllerV1 {
List<Transaction> txList = this.transactionService.getByExample(example);
if (!CollectionUtils.isEmpty(txList)) {
Transaction trans = txList.get(0);
model.setHash(condition);
model.setHash(trans.getTxId());
model.setBlockHash(trans.getBlockId());
model.setBlockNumber(trans.getNumber().intValue());
model.setFrom(trans.getOwnerAddress());
......@@ -228,7 +224,7 @@ public class TransactionControllerV1 {
if (!CollectionUtils.isEmpty(pageInfo.getList())) {
pageInfo.getList().forEach(o -> {
TransInfoModel model = TransInfoModel.getInstance();
model.setHash(o.getBlockId());
model.setHash(o.getTxId());
model.setBlockHash(o.getTxId());
model.setBlockNumber(o.getNumber().intValue());
model.setFrom(o.getOwnerAddress());
......@@ -329,7 +325,7 @@ public class TransactionControllerV1 {
List<Transaction> txList = this.transactionService.getByExample(example);
if (!CollectionUtils.isEmpty(txList)) {
Transaction trans = txList.get(0);
model.setHash(hash);
model.setHash(trans.getTxId());
model.setBlockHash(trans.getBlockId());
model.setBlockNumber(trans.getNumber().intValue());
model.setFrom(trans.getOwnerAddress());
......@@ -421,6 +417,17 @@ public class TransactionControllerV1 {
return ResponseKit.success(modelList);
}
/**
* 首页图表
*
* @return
*/
@RequestMapping(value="getBlockNumber", method = RequestMethod.GET)
public ApiResponse getBlockNumber() {
LastBlock lastBlock = this.lastBlockService.getOneByExample();
return ResponseKit.success(lastBlock.getLastBlockNum());
}
public final static boolean isNumeric(String s) {
if (s != null && !"".equals(s.trim())) {
return s.matches("^[0-9]*$");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment