package com.usky.transfer.controller.web;

import com.usky.common.core.bean.ApiResult;
import com.usky.transfer.domain.DeviceDataWriteVO;
import com.usky.transfer.domain.MqttDeviceDataVO;
import com.usky.transfer.service.QueryInfluxdbDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @Author :
 * @CreateTime : 2024/2/29
 * @Description :
 **/
@RestController
@RequestMapping("/dataWrite")
public class SendMessageController {
    @Autowired
    private QueryInfluxdbDataService queryInfluxdbDataService;

    /**
     * 单个设备数据写入
     * @return
     */
    @PostMapping("/sendDeviceData")
    public ApiResult<Map<String,Object>> sendDeviceData(@RequestBody DeviceDataWriteVO writeVO){
        return ApiResult.success(queryInfluxdbDataService.sendDeviceDataToMQ(writeVO));
    }

    /**
     * MQTT设备数据上报调试
     * @param mqttDeviceDataVO
     * @return
     */
    @PostMapping("/mqttDeviceData")
    public ApiResult<Map<String,Object>> mqttDeviceData(@RequestBody MqttDeviceDataVO mqttDeviceDataVO){
        return ApiResult.success(queryInfluxdbDataService.mqttDeviceData(mqttDeviceDataVO));
    }


}