package com.jxy.marketall.controller;

import com.jxy.common.core.utils.StringUtils;
import com.jxy.common.core.web.Result.AjaxResult;
import com.jxy.common.redis.service.RedisService;
import com.jxy.common.security.annotation.RequiresLogin;
import com.jxy.common.security.utils.SecurityUtils;
import com.jxy.marketall.service.ETHV2Service;
import com.jxy.marketall.service.USDService;
import com.jxy.marketall.vo.EBalanceVo;
import com.jxy.marketall.vo.ETHMintedVo;
import com.jxy.marketall.vo.QueryVo;
import com.jxy.marketall.vo.SmaVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Description 统一请求接口
 * @Date 2022/5/27 9:54
 * @Author 杜懿
 */
@RestController
@RequestMapping(value = {"/eth/v2","/ETH/v2"})
@Api(tags = "eth v2接口")
public class ETHV2Controller {

    @Autowired
    private ETHV2Service ethv2Service;

    @Autowired
    private USDService usdService;

    @Autowired
    private RedisService redisService;

    @PostMapping(value = {"/PiCycleTopIndicator"})
    @ApiOperation(value = "PI周期顶指标 Pi Cycle Top Indicator")
    public AjaxResult piCTI(@RequestBody(required = false) QueryVo vo){
        if(StringUtils.isNull(vo)){vo = new QueryVo();}

        return  ethv2Service.getPiCycleTIList(vo);
    }

    @GetMapping(value = {"/test"})
    public AjaxResult test(){
        return  AjaxResult.success(SecurityUtils.getLoginUser());
    }


    @PostMapping(value = {"/goldenRatioMult"})
    @ApiOperation(value = "库存/黄金比例乘数 Golden Ratio Multiplier ")
    //@RequiresLogin
    public AjaxResult goldenRatioMult(@RequestBody(required = false) SmaVo vo){
        if(StringUtils.isNull(vo)){vo = new SmaVo();}
        return  ethv2Service.getGoldenRatioMultList(vo.getSma());
    }

    @PostMapping(value = {"/cdd"})
    @ApiOperation(value = "币天销毁量 Coin Days Destroyed")
    //@RequiresLogin
    public AjaxResult cdd(@RequestBody(required = false) SmaVo vo){
        if(StringUtils.isNull(vo)){vo = new SmaVo();}
        return  ethv2Service.getCDDList(vo.getSma());
    }

    @PostMapping(value = {"/dormancy"})
    @ApiOperation(value = "已花费输出休眠平均天数 Average Coin Dormancy")
    //@RequiresLogin
    public AjaxResult dormancy(@RequestBody(required = false) SmaVo vo){
        if(StringUtils.isNull(vo)){vo = new SmaVo();}
        return  ethv2Service.getAverageCoinDormancyList(vo.getSma());
    }

    @PostMapping(value = {"/asol"})
    @ApiOperation(value = "")
    //@RequiresLogin
    public AjaxResult asol(@RequestBody(required = false) QueryVo vo){
        if(StringUtils.isNull(vo)){vo = new QueryVo();}
        return  ethv2Service.getASOLList(vo);
    }

    @PostMapping(value = {"/cddwave"})
    @ApiOperation(value = "币天销毁量分布  Distribution of Coin Days Destroyed")
    //@RequiresLogin
    public AjaxResult cddwave(@RequestBody(required = false) SmaVo vo){
        if(StringUtils.isNull(vo)){vo = new SmaVo();}
        return  ethv2Service.getCDDWaveList(vo.getSma());
    }


    @PostMapping(value = {"/address/distribution"})
    @ApiOperation(value = "按余额分段的地址数分布 Distribution of Address nozero")
    //@RequiresLogin
    public AjaxResult addressDistribution(@RequestBody(required = false) SmaVo vo){
        if(StringUtils.isNull(vo)){vo = new SmaVo();}
        return  ethv2Service.getAddressBalanceList(vo.getSma());
    }

    @PostMapping(value = {"/address/supplyDistribution"})
    @ApiOperation(value = "有者地址的供应分布 Distribution of Address Supply")
    //@RequiresLogin
    public AjaxResult addressSupplyDistribution(@RequestBody(required = false) SmaVo vo){
        if(StringUtils.isNull(vo)){vo = new SmaVo();}
        return  ethv2Service.getAddressSupplyList(vo.getSma());
    }

    @PostMapping(value = {"/address/profitPercent"})
    @ApiOperation(value = "盈利地址百分比 Percent of Addresses in Profit")
    //@RequiresLogin
    public AjaxResult addressProfitPercent(@RequestBody(required = false) SmaVo vo){
        if(StringUtils.isNull(vo)){vo = new SmaVo();}
        return  ethv2Service.getAddressProfitPercentList(vo.getSma());
    }

    @PostMapping(value = {"/address/profit"})
    @ApiOperation(value = "盈利地址数 Number of Addresses in Profit")
    //@RequiresLogin
    public AjaxResult addressProfit(@RequestBody(required = false) SmaVo vo){
        if(StringUtils.isNull(vo)){vo = new SmaVo();}
        return  ethv2Service.getAddressProfitList(vo.getSma());
    }

    @PostMapping(value = {"/address/loss"})
    @ApiOperation(value = "亏损地址数 Number of Addresses in Loss")
    //@RequiresLogin
    public AjaxResult addressLoss(@RequestBody(required = false) SmaVo vo){
        if(StringUtils.isNull(vo)){vo = new SmaVo();}
        return  ethv2Service.getAddressLossList(vo.getSma());
    }

    @PostMapping(value = {"/inflactionRate"})
    @ApiOperation(value = "通货膨胀率 Inflation Rate")
    //@RequiresLogin
    public AjaxResult inflactionRate(@RequestBody(required = false) SmaVo vo){
        if(StringUtils.isNull(vo)){vo = new SmaVo();}
        return  ethv2Service.getInflationRateList(vo.getSma());
    }

    @PostMapping(value = {"/issuance"})
    @ApiOperation(value = "新币发行量 issuance")
    //@RequiresLogin
    public AjaxResult issuance(@RequestBody(required = false) SmaVo vo){
        if(StringUtils.isNull(vo)){vo = new SmaVo();}
        return  ethv2Service.getIssuanceList(vo.getSma());
    }

    @PostMapping(value = {"/sopr"})
    @ApiOperation(value = "已花费输出盈利比 Spent Output Profit Ratio")
    //@RequiresLogin
    public AjaxResult sopr(@RequestBody(required = false) QueryVo vo){
        if(StringUtils.isNull(vo)){vo = new QueryVo();}
        return  ethv2Service.getSOPRList(vo);
    }

    @PostMapping(value = {"/velocity"})
    @ApiOperation(value = "流通速度 Velocity")
    //@RequiresLogin
    public AjaxResult velocity(@RequestBody(required = false) SmaVo vo){
        if(StringUtils.isNull(vo)){vo = new SmaVo();}
        return  ethv2Service.getVelocityList(vo.getSma());
    }

    @PostMapping(value = {"/nvtRatio"})
    @ApiOperation(value = "市值/交易价值比 Network Value to Transactions Ratio")
    //@RequiresLogin
    public AjaxResult nvtRatio(@RequestBody(required = false) SmaVo vo){
        if(StringUtils.isNull(vo)){vo = new SmaVo();}
        return  ethv2Service.getNVTRatioList(vo.getSma());
    }

    @PostMapping(value = {"/nvtSign"})
    @ApiOperation(value = "市值/交易价值比 Network Value to Transactions Ratio")
    //@RequiresLogin
    public AjaxResult nvtSign(@RequestBody(required = false) SmaVo vo){
        if(StringUtils.isNull(vo)){vo = new SmaVo();}
        return  ethv2Service.getNVTSignList(vo.getSma());
    }

    @PostMapping(value = {"/liveliness"})
    @ApiOperation(value = "活跃度 liveliness")
    //@RequiresLogin
    public AjaxResult liveliness(@RequestBody(required = false) SmaVo vo){
        if(StringUtils.isNull(vo)){vo = new SmaVo();}
        return  ethv2Service.getLiveLinessList(vo.getSma());
    }

    @PostMapping(value = {"/frm"})
    @ApiOperation(value = "交易费率乘数 Fee Ratio Multiple (FRM)")
    //@RequiresLogin
    public AjaxResult frm(@RequestBody(required = false) SmaVo vo){
        if(StringUtils.isNull(vo)){vo = new SmaVo();}
        return  ethv2Service.getFRMList(vo.getSma());
    }

    @PostMapping(value = {"/supply/profitPercent"})
    @ApiOperation(value = "盈利百分比 Percent Supply in Profit")
    //@RequiresLogin
    public AjaxResult supplyProfitPercent(@RequestBody(required = false) SmaVo vo){
        if(StringUtils.isNull(vo)){vo = new SmaVo();}
        return  ethv2Service.getSupplyProfitPercentList(vo.getSma());
    }

    @PostMapping(value = {"/supply/profit"})
    @ApiOperation(value = "盈利供应量 Total Supply in Profit ")
    //@RequiresLogin
    public AjaxResult supplyProfit(@RequestBody(required = false) SmaVo vo){
        if(StringUtils.isNull(vo)){vo = new SmaVo();}
        return  ethv2Service.getTotalSupplyProfitList(vo.getSma());
    }

    @PostMapping(value = {"/supply/loss"})
    @ApiOperation(value = "盈利亏损量 Total Supply in Loss ")
    //@RequiresLogin
    public AjaxResult supplyLoss(@RequestBody(required = false) SmaVo vo){
        if(StringUtils.isNull(vo)){vo = new SmaVo();}
        return  ethv2Service.getTotalSupplyLossList(vo.getSma());
    }

    @PostMapping(value = {"/nupl"})
    @ApiOperation(value = "未实现的净收益损失比 Net Unrealized Profit/Loss")
    //@RequiresLogin
    public AjaxResult nupl(@RequestBody(required = false) SmaVo vo){
        if(StringUtils.isNull(vo)){vo = new SmaVo();}
        return  ethv2Service.getNUPLList(vo.getSma());
    }

    @PostMapping(value = {"/relativeUProfit"})
    @ApiOperation(value = "未实现的净收益量 Relative Unrealized Profit")
    //@RequiresLogin
    public AjaxResult relativeUProfit(@RequestBody(required = false) SmaVo vo){
        if(StringUtils.isNull(vo)){vo = new SmaVo();}
        return  ethv2Service.getRelativeUProfitList(vo.getSma());
    }

    @PostMapping(value = {"/relativeULoss"})
    @ApiOperation(value = "未实现的净亏损量 Relative Unrealized Loss")
    //@RequiresLogin
    public AjaxResult relativeULoss(@RequestBody(required = false) SmaVo vo){
        if(StringUtils.isNull(vo)){vo = new SmaVo();}
        return  ethv2Service.getRelativeULossList(vo.getSma());
    }

    @PostMapping(value = {"/lthNUPL"})
    @ApiOperation(value = "长持者未实现的净收益量 Long Term Holder NUPL")
    //@RequiresLogin
    public AjaxResult lthNUPL(@RequestBody(required = false) SmaVo vo){
        if(StringUtils.isNull(vo)){vo = new SmaVo();}
        return  ethv2Service.getLTHNUPLList(vo.getSma());
    }

    @PostMapping(value = {"/sthNUPL"})
    @ApiOperation(value = "短持者未实现的净亏损量 Short Term Holder NUPL")
    //@RequiresLogin
    public AjaxResult sthNUPL(@RequestBody(required = false) SmaVo vo){
        if(StringUtils.isNull(vo)){vo = new SmaVo();}
        return  ethv2Service.getSTHNUPLList(vo.getSma());
    }

    @PostMapping(value = {"/marketcap"})
    @ApiOperation(value = "流通市值 Market Cap")
    //@RequiresLogin
    public AjaxResult marketcap(@RequestBody(required = false) QueryVo vo){
        if(StringUtils.isNull(vo)){vo = new QueryVo();}
        return  ethv2Service.getMarketCapList(vo);
    }

    @PostMapping(value = {"/rcap"})
    @ApiOperation(value = "已实现流通市值 Realized Cap")
    //@RequiresLogin
    public AjaxResult rcap(@RequestBody(required = false) SmaVo vo){
        if(StringUtils.isNull(vo)){vo = new SmaVo();}
        return  ethv2Service.getRealizedCapList(vo.getSma());
    }

    @PostMapping(value = {"/rprice"})
    @ApiOperation(value = "已实现价格 Realized Price")
    //@RequiresLogin
    public AjaxResult rprice(@RequestBody(required = false) SmaVo vo){
        if(StringUtils.isNull(vo)){vo = new SmaVo();}
        return  ethv2Service.getRealizedPriceList(vo.getSma());
    }

    @PostMapping(value = {"/mvrvRatio"})
    @ApiOperation(value = "流通市值-已实现流通市值比 Market Value to Realized Value Ratio")
    //@RequiresLogin
    public AjaxResult mvrvRatio(@RequestBody(required = false) SmaVo vo){
        if(StringUtils.isNull(vo)){vo = new SmaVo();}
        return  ethv2Service.getMVRVRatioList(vo.getSma());
    }

    @PostMapping(value = {"/burnedSupply"})
    @ApiOperation(value = "燃烧量 Burned Supply")
    //@RequiresLogin
    public AjaxResult burnedSupply(@RequestBody(required = false) SmaVo vo){
        if(StringUtils.isNull(vo)){vo = new SmaVo();}
        return  ethv2Service.getBurnedSupplyList(vo.getSma());
    }

    @PostMapping(value = {"/mintedSupply"})
    @ApiOperation(value = "发行量 Minted Supply")
    //@RequiresLogin
    public AjaxResult mintedSupply(@RequestBody(required = false) SmaVo vo){
        if(StringUtils.isNull(vo)){vo = new SmaVo();}
        return  ethv2Service.getMintedSupplyList(vo.getSma());
    }

    @PostMapping(value = {"/usdt/minted"})
    @ApiOperation(value = "USDT每日铸造量曲线数据")
    //@RequiresLogin
    public AjaxResult usdtMinted(@RequestBody(required = false) QueryVo vo){
        if(StringUtils.isNull(vo)){vo = new QueryVo();}
        return  usdService.getUSDTMinted(vo);
    }

    @PostMapping(value = {"/usdt/minted/list"})
    @ApiOperation(value = "USDT每日铸造详情表格")
    //@RequiresLogin
    public AjaxResult usdtMinted(@RequestBody(required = false) ETHMintedVo vo){
        if(StringUtils.isNull(vo)){vo = new ETHMintedVo();}
        return  usdService.getUSDTMintedList(vo);
    }

    @PostMapping(value = {"/usdc/minted"})
    @ApiOperation(value = "USDC每日铸造量曲线数据")
    //@RequiresLogin
    public AjaxResult usdcMinted(@RequestBody(required = false) QueryVo vo){
        if(StringUtils.isNull(vo)){vo = new QueryVo();}
        return  usdService.getUSDCMinted(vo);
    }

    @PostMapping(value = {"/usdc/minted/list"})
    @ApiOperation(value = "USDC每日铸造详情表格")
    //@RequiresLogin
    public AjaxResult usdcMinted(@RequestBody(required = false) ETHMintedVo vo){
        if(StringUtils.isNull(vo)){vo = new ETHMintedVo();}
        return  usdService.getUSDCMintedList(vo);
    }

    @PostMapping(value = {"/busd/minted"})
    @ApiOperation(value = "BUSD每日铸造量曲线数据")
    //@RequiresLogin
    public AjaxResult busdMinted(@RequestBody(required = false) QueryVo vo){
        if(StringUtils.isNull(vo)){vo = new QueryVo();}
        return  usdService.getBUSDMinted(vo);
    }

    @PostMapping(value = {"/busd/minted/list"})
    @ApiOperation(value = "BUSD每日铸造详情表格")
    //@RequiresLogin
    public AjaxResult busdMinted(@RequestBody(required = false) ETHMintedVo vo){
        if(StringUtils.isNull(vo)){vo = new ETHMintedVo();}
        return  usdService.getBUSDMintedList(vo);
    }

    @PostMapping(value = {"/exchanges"})
    @ApiOperation(value = "获取所有交易所名")
    //@RequiresLogin
    public AjaxResult exchanges(){

        return  ethv2Service.getExchanges();
    }

    @PostMapping(value = {"/ebalance"})
    @ApiOperation(value = "待交易量")
    //@RequiresLogin
    public AjaxResult ebalance(@RequestBody EBalanceVo vo){

        return  ethv2Service.getExchangeBalance(vo);
    }


    @PostMapping(value = {"/price"})
    @ApiOperation(value = "ethindsv1表价格")
    //@RequiresLogin
    public AjaxResult price(@RequestBody(required = false) QueryVo vo){
        if(StringUtils.isNull(vo)){ vo = new QueryVo();}
        return  ethv2Service.getPrice(vo);
    }

}
