package com.zhongshu.card.server.core.controller.devices;

import com.github.microservice.models.device.DevicePermissSendResponseParam;
import com.github.microservice.models.device.DeviceSyncListParam;
import com.github.microservice.models.device.GateWaySyncParam;
import com.github.microservice.models.hxz.DevicePingInfoParam;
import com.github.microservice.net.ResultContent;
import com.zhongshu.card.server.core.service.devices.DeviceSyncFromIotService;
import com.zhongshu.card.server.core.service.devices.permiss.DevicePermissSendLogService;
import io.swagger.v3.oas.annotations.Hidden;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 *
 */
@RequestMapping("/deviceSync")
@RestController
@Validated
@Tag(name = "物联网平台 设备同步")
@Hidden
public class DeviceSyncController {

    @Autowired
    private DeviceSyncFromIotService deviceSyncFromIotService;

    @Autowired
    private DevicePermissSendLogService devicePermissSendLogService;

    @Operation(summary = "物联网--同步设备接口", hidden = true)
    @RequestMapping(value = "syncDevices", method = {RequestMethod.POST})
    public ResultContent syncDevices(@RequestBody DeviceSyncListParam param) {
        return deviceSyncFromIotService.syncFromIotDevices(param);
    }

    @Operation(summary = "物联网--同步设备最近上线时间", hidden = true)
    @RequestMapping(value = "lastDeviceOnLineTime", method = {RequestMethod.POST})
    public ResultContent lastDeviceOnLineTime(@RequestBody DevicePingInfoParam param) {
        return deviceSyncFromIotService.syncDeviceOnLineTime(param);
    }

    @Operation(summary = "物联网--同步设备在线状态", hidden = true)
    @RequestMapping(value = "syncDeviceOnLineState", method = {RequestMethod.POST})
    public ResultContent syncDeviceOnLineState(@RequestBody DevicePingInfoParam param) {
        return deviceSyncFromIotService.syncDeviceOnLineState(param);
    }

    @Operation(summary = "物联网--同步网关接口", hidden = true)
    @RequestMapping(value = "syncGateWays", method = {RequestMethod.POST})
    public ResultContent syncGateWays(@RequestBody GateWaySyncParam param) {
        return deviceSyncFromIotService.syncGateWays(param);
    }

    @Operation(summary = "物联网--设备权限下发的响应")
    @RequestMapping(value = "markSendResponse", method = {RequestMethod.POST})
    public ResultContent markSendResponse(@RequestBody DevicePermissSendResponseParam param) {
        return devicePermissSendLogService.markSendResponse(param);
    }

}

