package com.ruoyi.tdengine.api;


import com.ruoyi.common.core.constant.ServiceNameConstants;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.hw.validated.tdengine.AddTdSTableColumn;
import com.ruoyi.common.core.hw.validated.tdengine.InsertTdTable;
import com.ruoyi.tdengine.api.domain.*;
import com.ruoyi.tdengine.api.factory.RemoteTdEngineFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;
import java.util.Map;

@FeignClient(contextId = "remoteTdEngineService", value = ServiceNameConstants.TDENGINE_SERVICE, fallbackFactory = RemoteTdEngineFallbackFactory.class)
public interface RemoteTdEngineService {

    @PostMapping("/tdengine/createDatabase")
    R<?> createDataBase(@RequestParam("databaseName") String databaseName);

    @PostMapping("/tdengine/createSuperTable")
    R<?> createSuperTable(@Validated @RequestBody TdSuperTableVo tdSuperTableVo);

    @PostMapping("/tdengine/createTable")
    R<?> createTable(@Validated @RequestBody TdTableVo tdTableVo);

    @PostMapping("/tdengine/addSuperTableColumn")
    R<?> addSuperTableColumn(@Validated(AddTdSTableColumn.class) @RequestBody TdSuperTableVo tdSuperTableVo);

    @PostMapping("/tdengine/dropSuperTableColumn")
    R<?> dropColumnForSuperTable(@Validated(AddTdSTableColumn.class) @RequestBody TdSuperTableVo tdSuperTableVo);

    @PostMapping("/tdengine/alterTableTag")
    public R<?> alterTableTag(@Validated @RequestBody AlterTagVo alterTagVo);

    @PostMapping("/tdengine/insertTable")
    R<?> insertTable(@Validated(InsertTdTable.class) @RequestBody TdTableVo tdTableVo);

    @PostMapping("/tdengine/getLatestData")
    R<?> getLatestData(@Validated @RequestBody TdSelectDto tdSelectDto);

    @PostMapping("/tdengine/getLatestDataByTags")
    R<List<Map<String, Object>>> getLatestDataByTags(@Validated @RequestBody TdSuperTableSelectVo tdSuperTableSelectVo);

    @PostMapping("/tdengine/getHistoryData")
    R<List<Map<String, Object>>> getHistoryData(@Validated @RequestBody TdHistorySelectDto tdHistorySelectDto);

    @PostMapping("/tdengine/getCountOfHistoryData")
    R<?> getCountOfHistoryData(@Validated @RequestBody TdHistorySelectDto tdHistorySelectDto);

    @PostMapping("/tdengine/getOnlineDevicesGroupByDay")
    R<?> getOnlineDevicesGroupByDay(@Validated @RequestBody DeviceStatus queryDeviceStatus);
}
