package com.dcs.equipment.controller;

import com.dcs.common.core.domain.AjaxResult;
import com.dcs.equipment.domain.InfluxDBQuery;
import com.dcs.equipment.service.InfluxDBService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author: wangpx
 * @date: 2025-04-16 15:52
 */
@Api
@RestController
@RequestMapping("/influxdb")
public class InfluxDBController {
    @Autowired
    private InfluxDBService service;

    @PostMapping("/queryWithFlux")
    @ApiOperation(value = "使用Flux语言查询InfluxDB数据")
    public AjaxResult queryWithFlux(@RequestBody InfluxDBQuery query) {
        return AjaxResult.success(service.queryWithFlux(query));
    }

    @GetMapping("/getTemperatureByDay")
    @ApiOperation(value = "获取1天内温度数据")
    public AjaxResult getTemperatureByDay() {
        return AjaxResult.success(service.queryTemperatureByDay());
    }
    @GetMapping("/getTemperatureByWeek")
    @ApiOperation(value = "获取1周内温度数据")
    public AjaxResult getTemperatureByWeek() {
        return AjaxResult.success(service.queryTemperatureByWeek());
    }
    @GetMapping("/getTemperatureByMonth")
    @ApiOperation(value = "获取1月内温度数据")
    public AjaxResult getTemperatureByMonth() {
        return AjaxResult.success(service.queryTemperatureByMonth());
    }
}
