package com.usky.eg.controller.web;


import com.usky.common.core.bean.ApiResult;
import com.usky.eg.domain.EgDeviceHeartbeat;
import com.usky.eg.service.EgDeviceHeartbeatService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 门禁设备心跳表 前端控制器
 * </p>
 *
 * @author fhs
 * @since 2026-02-03
 */
@RestController
@RequestMapping("/egDeviceHeartbeat")
public class EgDeviceHeartbeatController {
    private static final Logger log = LoggerFactory.getLogger(EgDeviceHeartbeatController.class);
    @Autowired
    private EgDeviceHeartbeatService heartbeatService;

    @PostMapping("/escalation")
    public ApiResult<Void> heartbeatEscalation(@RequestBody EgDeviceHeartbeat heartbeat) {
        try {
            heartbeatService.heartbeatEscalation(heartbeat);
        } catch (Exception e) {
            log.error("设备心跳异常", e);
            return ApiResult.error("设备心跳入库异常！");
        }
        return ApiResult.success();
    }
}
