package com.jxy.marketall.controller;

import com.jxy.common.core.utils.StringUtils;
import com.jxy.common.core.web.Result.AjaxResult;
import com.jxy.marketall.service.BorderMongoService;
import com.jxy.marketall.service.ExchangeService;
import com.jxy.marketall.vo.*;
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("/exchange")
@Api(tags = "交易所接口")
public class ExchangeController {

    @Autowired
    private ExchangeService exchangeService;

    @Autowired
    private BorderMongoService borderMongoService;


    @PostMapping(value = {"/fundingRate"})
    @ApiOperation(value = "资金费率")
    public AjaxResult fundingRate(@RequestBody() BourseVo vo){
        if(StringUtils.isNull(vo)){vo = new BourseVo();}

        return  exchangeService.getFundingRateByTime(vo);
    }

    @PostMapping(value = {"/openInterest"})
    @ApiOperation(value = "未平仓合约数")
    public AjaxResult openInterest(@RequestBody() BourseVo vo){
        if(StringUtils.isNull(vo)){vo = new BourseVo();}

        return  exchangeService.getOpenInterestByTime(vo);
    }

    @PostMapping(value = {"/takerlongshortRatio"})
    @ApiOperation(value = "合约主动买入量")
    public AjaxResult takerlongshortRatio(@RequestBody() BourseVo vo){
        if(StringUtils.isNull(vo)){vo = new BourseVo();}

        return  exchangeService.getTakerlongshortRatioByTime(vo);
    }

    @PostMapping(value = {"/volumeProfile"})
    @ApiOperation(value = "成交量分布")
    public AjaxResult volumeProfile(@RequestBody() VolumeProfileVo vo){
        if(StringUtils.isNull(vo)){vo = new VolumeProfileVo();}

        return  exchangeService.getVolumeProfile(vo);
    }

    @PostMapping(value = {"/v2/tzbp"})
    @ApiOperation(value = "时区购买力")
    public AjaxResult tzbp(@RequestBody() TimeZoneVo vo){
        return  exchangeService.getTimeZoneBuyPowerList(vo);
    }

    @PostMapping(value = {"/v2/bobp"})
    @ApiOperation(value = "买入大单挂单")
    public AjaxResult bobp(@RequestBody BorderVo vo){
        if(StringUtils.isNull(vo)){vo = new BorderVo();}
        return borderMongoService.getBuyPowerList(vo);
    }

    @PostMapping(value = {"/v2/bosp"})
    @ApiOperation(value = "卖出大单挂单")
    public AjaxResult bosp(@RequestBody BorderVo vo){
        if(StringUtils.isNull(vo)){vo = new BorderVo();}
        return borderMongoService.getSellPowerList(vo);
    }



    @PostMapping(value = {"/v2/btcBalance"})
    @ApiOperation(value = "btc余额")
    public AjaxResult btcBalance(@RequestBody() QueryVo vo){
        if(StringUtils.isNull(vo)){vo = new QueryVo();}
        return exchangeService.getBTCBalanceList(vo);
    }


    @PostMapping(value = {"/v2/ethBalance"})
    @ApiOperation(value = "eth余额")
    public AjaxResult ethBalance(@RequestBody() QueryVo vo){
        if(StringUtils.isNull(vo)){vo = new QueryVo();}
        return exchangeService.getETHBalanceList(vo);
    }

}
