package com.jxy.marketall.controller;

import com.jxy.common.core.web.Result.AjaxResult;
import com.jxy.marketall.mapper.MsgSubMapper;
import com.jxy.marketall.service.DataPushService;
import org.apache.rocketmq.client.exception.MQBrokerException;
import org.apache.rocketmq.client.exception.MQClientException;
import org.apache.rocketmq.remoting.exception.RemotingException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Description 统一请求接口
 * @Date 2022/5/27 9:54
 * @Author 杜懿
 */
@RestController
@RequestMapping("/push")
public class DataPushController {

    @Autowired
    private DataPushService dataPushService;

    @PostMapping("/realtime/btc/dailyv2e1")
    public AjaxResult BTCdailyindsv2e1(@RequestBody() String data){
        System.out.println("data:"+data);
        try {
            dataPushService.BTCRealTimeV2e1DataPush(data);
            return AjaxResult.success();
        } catch (MQClientException e) {
            e.printStackTrace();
            return AjaxResult.error("error1");
        } catch (RemotingException e) {
            e.printStackTrace();
            return AjaxResult.error("error2");
        } catch (InterruptedException e) {
            e.printStackTrace();
            return AjaxResult.error("error3");
        } catch (MQBrokerException e) {
            e.printStackTrace();
            return AjaxResult.error("error4");
        }

    }

}
