package com.microservices.dms.achievementLibrary.controller;

import com.microservices.common.core.web.domain.AjaxResult;
import com.microservices.dms.achievementLibrary.service.BlockChainService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/blockFisco")
@Api(tags = "数据管理体系-数据产权入链交易")
public class BlockFiscoController {

    @Autowired
    private BlockChainService blockChainService;


    @GetMapping("/getTransactionByHash")
    @ApiOperation(value = "通过交易哈希获取交易详情")
    public AjaxResult getTransactionByHash(String txHash) {
        return AjaxResult.success(blockChainService.getTransactionByHash(txHash));
    }


    @ApiOperation(value = "交易哈希获取交易回执")
    @GetMapping("/getTransactionReceipt")
    public AjaxResult getTransactionReceipt(String txHash) {
        return  AjaxResult.success(blockChainService.getTransactionReceipt(txHash));
    }


    @ApiOperation(value = "获取最新区块号")
    @GetMapping("/blockNumber")
    public AjaxResult getBlockNumber() {
        return  AjaxResult.success(blockChainService.getBlockNumber());
    }


    @ApiOperation(value = "获取区块链总交易数")
    @GetMapping("/getTotalTransactionCount")
    public AjaxResult getTotalTransactionCount() {
        return  AjaxResult.success(blockChainService.getTotalTransactionCount());
    }


}
