package com.jxy.marketall.controller;

/**
 * @Description TODO
 * @Date 2022/6/27 10:28
 * @Author 杜懿
 */

import cn.hutool.db.meta.Table;
import com.jxy.common.core.utils.StringUtils;
import com.jxy.common.core.web.Result.AjaxResult;
import com.jxy.common.security.annotation.RequiresLogin;
import com.jxy.marketall.dto.BiAnWSDto;
import com.jxy.marketall.entity.BiAn;
import com.jxy.marketall.service.impl.BiAnServiceImpl;
import com.jxy.marketall.utils.MyWebSocketClient;
import com.jxy.marketall.vo.BiAnVo;
import com.jxy.marketall.vo.BianceVolumeVo;
import com.jxy.marketall.vo.BourseVo;
import com.jxy.marketall.vo.TZVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.java_websocket.client.WebSocketClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Description btc查询
 * @Date 2022/6/20 17:26
 * @Author 杜懿
 */
@RestController
@RequestMapping("/bian")
@Api(tags = "bian查询接口")
public class BiAnController {

    @Autowired
    private BiAnServiceImpl biAnService;

    //@GetMapping("/list")
    //@ApiOperation(value = "币安 条件查询",response = List.class)
    //@ApiImplicitParams({
    //        @ApiImplicitParam(name = "timeInterval", value = "时间间隔 单位分钟min、小时h、天d、月M，严格区分大小写", dataType = "string", paramType = "query"),
    //        @ApiImplicitParam(name = "symbol", value = "交易对", dataType = "string", paramType = "query", required = true),
    //        @ApiImplicitParam(name = "start", value = "开始时间  可以只传开始时间，表示查询大于这个时间的值", dataType = "string", paramType = "query"),
    //        @ApiImplicitParam(name = "end", value = "结束时间 可以只传开始时间，表示查询大于这个时间的值", dataType = "string", paramType = "query")})
    ////@RequiresLogin
    //public AjaxResult list(BiAnVo biAnVo){
    //
    //    AjaxResult dataByCondition = biAnService.findDataByCondition(biAnVo);
    //    return  dataByCondition;
    //}

    @PostMapping("/kline")
    @ApiOperation(value = "币安 条件查询",response = List.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "timeInterval", value = "时间间隔 单位分钟min、小时h、天d、月M，严格区分大小写", dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "symbol", value = "交易对", dataType = "string", paramType = "query", required = true),
            @ApiImplicitParam(name = "start", value = "开始时间  可以只传开始时间，表示查询大于这个时间的值", dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "end", value = "结束时间 可以只传开始时间，表示查询大于这个时间的值", dataType = "string", paramType = "query")})
    //@RequiresLogin
    public AjaxResult kline(@RequestBody() BourseVo vo){

        return  biAnService.getKLine(vo);
    }

    @GetMapping("/realTimeData")
    @ApiOperation(value = "币安 实时数据",response = List.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "timeInterval", value = "时间间隔 单位分钟min、小时h、天d、月M，严格区分大小写", dataType = "string", paramType = "query",required = true),
            @ApiImplicitParam(name = "start", value = "开始时间格式yyyy-MM-DD HH:MM:SS  只传开始时间，表示查询大于这个时间的值", dataType = "string", paramType = "query",required = true),
            @ApiImplicitParam(name = "symbol", value = "交易对", dataType = "string", paramType = "query", required = true)})
    //@RequiresLogin
    public AjaxResult realTimeData(BiAnVo biAnVo){
        return  AjaxResult.success(biAnService.getRealTimeData(biAnVo));
    }

    @GetMapping("/priceValue")
    @ApiOperation(value = "价格区间交易量之和",response = List.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "interval", value = "时间间隔 范围[1m, 3m, 5m, 15m, 30m, 1h, 2h, 4h, 6h,1d]", dataType = "string", paramType = "query", required = true),
            @ApiImplicitParam(name = "count", value = "显示数量 默认50", dataType = "string", paramType = "query", required = true),
            @ApiImplicitParam(name = "start", value = "开始时间", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "end", value = "结束时间", required = true, dataType = "string", paramType = "query")})
    //@RequiresLogin
    public AjaxResult priceValue(BianceVolumeVo vo){

        return AjaxResult.success(biAnService.getTotalValueList(vo));
    }




}
