diff --git a/back-end-projects/Explorer/src/main/java/com/github/ontio/controller/NodesController.java b/back-end-projects/Explorer/src/main/java/com/github/ontio/controller/NodesController.java index 4195b1e5..03342db7 100644 --- a/back-end-projects/Explorer/src/main/java/com/github/ontio/controller/NodesController.java +++ b/back-end-projects/Explorer/src/main/java/com/github/ontio/controller/NodesController.java @@ -100,8 +100,8 @@ public ResponseBean getCurrentTotalStake() { @ApiOperation(value = "Get candidate nodes information") @GetMapping(value = "/current-stakes") - public ResponseBean getCurrentStake() { - List nodeInfoList = nodesService.getCurrentOnChainInfo(); + public ResponseBean getCurrentStake(@RequestParam(value = "public_key", required = false) String publicKey) { + List nodeInfoList = nodesService.getCurrentOnChainStakeInfo(publicKey); if (nodeInfoList.size() == 0) { return new ResponseBean(ErrorInfo.NOT_FOUND.code(), ErrorInfo.NOT_FOUND.desc(), nodeInfoList); } diff --git a/back-end-projects/Explorer/src/main/java/com/github/ontio/mapper/NodeInfoOnChainMapper.java b/back-end-projects/Explorer/src/main/java/com/github/ontio/mapper/NodeInfoOnChainMapper.java index 26f9a508..bab4b64c 100644 --- a/back-end-projects/Explorer/src/main/java/com/github/ontio/mapper/NodeInfoOnChainMapper.java +++ b/back-end-projects/Explorer/src/main/java/com/github/ontio/mapper/NodeInfoOnChainMapper.java @@ -11,7 +11,7 @@ @Repository public interface NodeInfoOnChainMapper extends Mapper { - List selectAllInfo(); + List selectAllInfo(String publicKey); Long selectTotalStake(); diff --git a/back-end-projects/Explorer/src/main/java/com/github/ontio/model/dto/NodeInfoOnChainDto.java b/back-end-projects/Explorer/src/main/java/com/github/ontio/model/dto/NodeInfoOnChainDto.java index ccec13d8..be5cae1b 100644 --- a/back-end-projects/Explorer/src/main/java/com/github/ontio/model/dto/NodeInfoOnChainDto.java +++ b/back-end-projects/Explorer/src/main/java/com/github/ontio/model/dto/NodeInfoOnChainDto.java @@ -30,6 +30,9 @@ public class NodeInfoOnChainDto extends NodeInfoOnChain { @Transient private Integer badActor; + @Transient + private String userApy; + public NodeInfoOnChainDto() { } @@ -42,5 +45,6 @@ public NodeInfoOnChainDto(NodeInfoOnChainDto nodeInfoOnChain) { this.ontologyHarbinger = nodeInfoOnChain.getOntologyHarbinger(); this.risky = nodeInfoOnChain.getRisky(); this.badActor = nodeInfoOnChain.getBadActor(); + this.userApy = nodeInfoOnChain.getUserApy(); } } \ No newline at end of file diff --git a/back-end-projects/Explorer/src/main/java/com/github/ontio/service/INodesService.java b/back-end-projects/Explorer/src/main/java/com/github/ontio/service/INodesService.java index d6f6bebe..868b2891 100644 --- a/back-end-projects/Explorer/src/main/java/com/github/ontio/service/INodesService.java +++ b/back-end-projects/Explorer/src/main/java/com/github/ontio/service/INodesService.java @@ -37,7 +37,7 @@ public interface INodesService { - List getCurrentOnChainInfo(); + List getCurrentOnChainStakeInfo(String publicKey); NodeInfoOffChain getCurrentOffChainInfo(String publicKey, Integer openFlag); diff --git a/back-end-projects/Explorer/src/main/java/com/github/ontio/service/impl/NodesServiceImpl.java b/back-end-projects/Explorer/src/main/java/com/github/ontio/service/impl/NodesServiceImpl.java index 391ed4f8..761e2ec3 100644 --- a/back-end-projects/Explorer/src/main/java/com/github/ontio/service/impl/NodesServiceImpl.java +++ b/back-end-projects/Explorer/src/main/java/com/github/ontio/service/impl/NodesServiceImpl.java @@ -137,9 +137,9 @@ private Map getNodeRankChange() { } @Override - public List getCurrentOnChainInfo() { + public List getCurrentOnChainStakeInfo(String publicKey) { try { - List nodeInfoOnChainList = nodeInfoOnChainMapper.selectAllInfo(); + List nodeInfoOnChainList = nodeInfoOnChainMapper.selectAllInfo(publicKey); Map nodeRankChangeMap = getNodeRankChange(); List nodeInfoOnChainWithRankChanges = new ArrayList<>(); for (NodeInfoOnChainDto nodeInfo : nodeInfoOnChainList) { @@ -320,7 +320,7 @@ public List getLatestBonusesWithInfos() { List nodeInfoOnChainLst; List nodeBonusLst; try { - nodeInfoOnChainLst = nodeInfoOnChainMapper.selectAllInfo(); + nodeInfoOnChainLst = nodeInfoOnChainMapper.selectAllInfo(null); int nodeCount = nodeBonusMapper.selectNodeCount(); nodeBonusLst = nodeBonusMapper.selectLatestNodeBonusList(nodeCount); } catch (Exception e) { diff --git a/back-end-projects/Explorer/src/main/resources/mapper/NodeInfoOnChainMapper.xml b/back-end-projects/Explorer/src/main/resources/mapper/NodeInfoOnChainMapper.xml index 4d31f528..4ff760eb 100644 --- a/back-end-projects/Explorer/src/main/resources/mapper/NodeInfoOnChainMapper.xml +++ b/back-end-projects/Explorer/src/main/resources/mapper/NodeInfoOnChainMapper.xml @@ -47,9 +47,16 @@ b.ontology_harbinger, b.fee_sharing_ratio, b.risky, - b.bad_actor + b.bad_actor, + IFNULL(c.user_apy,'0.00%') as user_apy FROM tbl_node_info_on_chain a LEFT JOIN tbl_node_info_off_chain b ON a.public_key = b.public_key + LEFT JOIN tbl_node_inspire c ON a.public_key = c.public_key + + + AND a.public_key = #{publicKey} + +