package com.sptg.iot.api.feigns;

import com.baomidou.mybatisplus.plugins.Page;
import com.sptg.common.core.beans.ResultBean;
import com.sptg.iot.api.dto.DeviceStatusNoticeDto;
import com.sptg.iot.api.dto.HeartbeatNoticeDto;
import com.sptg.iot.api.dto.IotDeviceDto;
import com.sptg.iot.api.entity.IotDevice;
import com.sptg.iot.api.feigns.fallback.IotDeviceFeignFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;

/**
 * @author zwx
 * @create 2020/10/22 15:00
 */
@FeignClient(value = "smart-house-iot", fallbackFactory = IotDeviceFeignFallbackFactory.class)
public interface IotDeviceFeign {

    @PostMapping(value = "/iot/device/list")
    public ResultBean<Page<IotDevice>> showIotDeviceList(@RequestBody IotDeviceDto iotDeviceDto);

    @PostMapping(value = "/iot/device/pagingQuery")
    public ResultBean<Page<IotDevice>> pagingQuery(@RequestBody IotDeviceDto iotDeviceDto);

    @PostMapping(value = "/iot/device/register")
    public ResultBean<String> iotDeviceRegister(@RequestBody IotDeviceDto iotDeviceDto);

    @PostMapping(value = "/iot/device/sync/list")
    public ResultBean<String> syncIotDeviceList(@RequestBody IotDeviceDto iotDeviceDto);

    @PostMapping(value = "/iot/device/sync/listByPrefix")
    public ResultBean<String> syncIotDeviceListByPrefix(@RequestBody IotDeviceDto iotDeviceDto);

    /**
     * 同步设备详情（单个）
     * @param iotDeviceDto
     * @return
     */
    @PostMapping(value = "/iot/device/sync/detail/one")
    public ResultBean<String> syncIotDeviceDetailOne(@RequestBody IotDeviceDto iotDeviceDto);

    /**
     * 同步设备详情（批量）
     * @param iotDeviceDtoList
     * @return
     */
    @PostMapping(value = "/iot/device/sync/detail/batch")
    public ResultBean<String> syncIotDeviceDetailBatch(@RequestBody List<IotDeviceDto> iotDeviceDtoList);

    /**
     * 同步设备详情（全量）
     * @param iotDeviceDto
     * @return
     */
    @PostMapping(value = "/iot/device/sync/detail/all")
    public ResultBean<String> syncIotDeviceDetailAll(@RequestBody IotDeviceDto iotDeviceDto);

    @GetMapping(value = "/iot/device/getIotDeviceById/{id}")
    public IotDevice getIotDeviceById(@PathVariable(value = "id") Long id);

    @GetMapping(value = "/iot/device/getByDeviceId/{device_id}")
    public IotDevice getIotDeviceByDeviceId(@PathVariable(value = "device_id") String deviceId);

    @PostMapping(value = "/iot/device/updateStatus")
    public ResultBean<String> updateIotDeviceStatus(@RequestBody IotDevice iotDevice);

    @PostMapping(value = "/iot/device/update")
    public ResultBean<String> update(@RequestBody IotDevice iotDevice);

    @PostMapping(value = "/iot/device/heartbeat/notice")
    public ResultBean<IotDevice> deviceHeartbeatNotice(@RequestBody List<HeartbeatNoticeDto> heartbeatDtoList);

    @PostMapping(value = "/iot/device/status/notice")
    public ResultBean<IotDevice> deviceStatusNotice(@RequestBody DeviceStatusNoticeDto deviceStatusDto);

    @GetMapping(value = "/iot/device/getList")
    public ResultBean<List<IotDevice>> getList();

    @PostMapping(value = "/iot/device/updateBatch")
    public ResultBean<String> updateBatch(@RequestBody List<IotDevice> iotDeviceList);

    @PostMapping(value = "/iot/device/insertOrUpdateBatch")
    public ResultBean<String> insertOrUpdateBatch(@RequestBody List<IotDevice> iotDeviceList);
}
