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


import com.github.microservice.models.gateDoor.OnLineParam;
import com.github.microservice.models.gateDoor.gateDoor.GateDoorIotParam;
import com.github.microservice.net.ResultContent;
import com.zhongshu.card.server.core.service.gateDoor.GateDoorService;
import io.swagger.v3.oas.annotations.Hidden;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("openAPI/gateDoor/v1")
@Tag(name = "门闸")
@Hidden
public class GateDoorController {

    @Autowired
    private GateDoorService gateDoorService;

    /**
     * 设备上线通知
     */
    @Operation(summary = "闸机 设备上线通知")
    @PostMapping(value = "onLine", consumes = MediaType.APPLICATION_JSON_VALUE)
    public ResultContent onLine(@RequestBody OnLineParam param) {
        return gateDoorService.onLine(param);
    }

    /**
     * 设备下线通知
     */
    @Operation(summary = "闸机 设备下线通知")
    @PostMapping(value = "offLine", consumes = MediaType.APPLICATION_JSON_VALUE)
    public ResultContent offLine(@RequestBody OnLineParam param) {
        return gateDoorService.offLine(param);
    }

    @Operation(summary = "门闸 认证识别人员信息上传消息", description = "门闸 认证识别人员信息上传消息")
    @RequestMapping(value = "recPush", method = {RequestMethod.POST})
    public ResultContent recPush(@RequestBody GateDoorIotParam param) {
        return this.gateDoorService.gateDoorUseRecord(param);
    }

    @Operation(summary = "陌生人在线验证", description = "陌生人在线验证")
    @RequestMapping(value = "strSnapPush", method = {RequestMethod.POST})
    public ResultContent strSnapPush(@RequestBody GateDoorIotParam param) {
        return this.gateDoorService.gateDoorOnLineVerify(param);
    }

    @Operation(summary = "门闸刷卡开门失败消息", description = "门闸刷卡开门失败消息")
    @RequestMapping(value = "cardPush", method = {RequestMethod.POST})
    public ResultContent cardPush(@RequestBody GateDoorIotParam param) {
        return this.gateDoorService.gateDoorUseRecord(param);
    }

}
