package com.ycwl.basic.integration.device.client;

import com.ycwl.basic.integration.common.response.CommonResponse;
import com.ycwl.basic.integration.device.dto.status.DeviceStatusDTO;
import com.ycwl.basic.integration.device.dto.status.OnlineStatusResponseDTO;
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 java.util.List;

@FeignClient(name = "zt-device", contextId = "deviceStatusClient", path = "/api/device/status")
public interface DeviceStatusClient {

    /**
     * 获取设备状态
     */
    @GetMapping("/{deviceNo}")
    CommonResponse<DeviceStatusDTO> getDeviceStatus(@PathVariable("deviceNo") String deviceNo);

    /**
     * 检查设备是否在线
     */
    @GetMapping("/{deviceNo}/online")
    CommonResponse<OnlineStatusResponseDTO> isDeviceOnline(@PathVariable("deviceNo") String deviceNo);

    /**
     * 获取所有在线设备
     */
    @GetMapping("/online")
    CommonResponse<List<DeviceStatusDTO>> getAllOnlineDevices();

    /**
     * 设置设备离线
     */
    @PostMapping("/{deviceNo}/offline")
    CommonResponse<String> setDeviceOffline(@PathVariable("deviceNo") String deviceNo);

    /**
     * 设置设备在线
     */
    @PostMapping("/{deviceNo}/online")
    CommonResponse<String> setDeviceOnline(@PathVariable("deviceNo") String deviceNo);

    /**
     * 清理过期设备状态
     */
    @PostMapping("/clean")
    CommonResponse<String> cleanExpiredDevices();
}